Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jzacsh opened this issue Jun 30, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jzacsh
Copy link
Collaborator

jzacsh commented Jun 30, 2022

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)

@jzacsh jzacsh added the bug Something isn't working label Jun 30, 2022
@jzacsh jzacsh self-assigned this Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant