google / data-transfer-project

The Data Transfer Project makes it easy for people to transfer their data between online service providers. We are establishing a common framework, including data models and protocols, to enable direct transfer of data both into and out of participating online service providers.

Home Page:http://datatransferproject.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unit tests not hermetic: actual network dns lookup appears to happen (and maybe more) for imgur

jzacsh opened this issue · comments

unlike #1104 I think this set of failures isn't actually my fault but is a real bug. the problem is there's a lack of test double being put in place so I'm seeing java.net.UnknownHostException: i.imgur.com errors.

steps to reproduce

step 1: prime gradle cache and prove things are passing

gradle test is passing with your network turned on

step 2: try offline

gradle test with your network off (eg: you're traveling) or force it via gradle --offline test (edit: nope, that applies to gradle's fetching build resources, not cutting off its subprocesses) and you'll get:

$ gradle test
> Task :extensions:data-transfer:portability-data-transfer-imgur:test FAILED

org.datatransferproject.transfer.imgur.photos.ImgurPhotoExporterTest > testAlbumPhotosExport FAILED
    java.net.UnknownHostException at ImgurPhotoExporterTest.java:148

org.datatransferproject.transfer.imgur.photos.ImgurPhotoExporterTest > testPagination FAILED
    java.net.UnknownHostException at ImgurPhotoExporterTest.java:213

org.datatransferproject.transfer.imgur.photos.ImgurPhotoExporterTest > testAlbumAndNonAlbumPhotoExport FAILED
    java.net.UnknownHostException at ImgurPhotoExporterTest.java:169

org.datatransferproject.transfer.imgur.photos.ImgurPhotoExporterTest > testNonAlbumPhotoExport FAILED
    java.net.UnknownHostException at ImgurPhotoExporterTest.java:196

5 tests completed, 4 failed

and the locally-generated gradle test webpage shows failures for Class org.datatransferproject.transfer.imgur.photos.ImgurPhotoExporterTest with i.imgur.com unknown; specifically:

ImgurPhotoExporterTest. testAlbumAndNonAlbumPhotoExport
ImgurPhotoExporterTest. testAlbumPhotosExport
ImgurPhotoExporterTest. testNonAlbumPhotoExport
ImgurPhotoExporterTest. testPagination

and here's sample stacktrace from that first failing test in the list:

testAlbumAndNonAlbumPhotoExport

java.net.UnknownHostException: i.imgur.com
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:607)
	at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:288)
	at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
	at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
	at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:203)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:189)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:167)
	at org.datatransferproject.datatransfer.imgur.photos.ImgurPhotosExporter.getImageAsStream(ImgurPhotosExporter.java:312)
	at org.datatransferproject.datatransfer.imgur.photos.ImgurPhotosExporter.requestPhotos(ImgurPhotosExporter.java:205)
	at org.datatransferproject.datatransfer.imgur.photos.ImgurPhotosExporter.export(ImgurPhotosExporter.java:105)
	at org.datatransferproject.transfer.imgur.photos.ImgurPhotoExporterTest.testAlbumAndNonAlbumPhotoExport(ImgurPhotoExporterTest.java:169)