Modify

Opened 6 years ago

Closed 3 years ago

Last modified 3 years ago

#16637 closed defect (fixed)

Rework unit tests to not depend on external website

Reported by: Don-vip Owned by: team
Priority: normal Milestone: 20.11
Component: Unit tests Version:
Keywords: Cc: ris

Description (last modified by simon04)

We still have some unit tests making real network connections, failing when the website is slow or unreachable:

  1. ✔ org.openstreetmap.josm.gui.oauth.OsmOAuthAuthorizationClientTest.testCookieHandlingMock
  2. org.openstreetmap.josm.gui.oauth.OsmOAuthAuthorizationClientTest.testCookieHandlingCookieManager
  3. ✔ org.openstreetmap.josm.gui.preferences.server.ApiUrlTestTaskTest.testNominalUrl
  4. ✔ org.openstreetmap.josm.gui.preferences.server.ApiUrlTestTaskTest.testAlertInvalidServerResult
  5. ✔ org.openstreetmap.josm.io.OsmServerHistoryReaderTest.testWay
  6. ✔ org.openstreetmap.josm.io.OsmServerHistoryReaderTest.testNode
  7. ✔ org.openstreetmap.josm.tools.HttpClientTest.testOpenUrlBzip
  8. ✔ org.openstreetmap.josm.tools.HttpClientTest.testOpenUrlGzip
  9. ✔ org.openstreetmap.josm.tools.HttpClientTest.testTicket9660

Attachments (0)

Change History (19)

comment:1 by ris, 6 years ago

There also those that unintentionally make network requests, e.g. fetching the "start page" from the wiki.

comment:2 by Don-vip, 6 years ago

In 14191/josm:

see #16637 - javadoc

comment:3 by simon04, 4 years ago

Related: #15102

comment:4 by Don-vip, 4 years ago

In 17075/josm:

see #15102 - see #16637 - get rid of real HTTP calls to http://httpstat.us in unit tests, mock them

comment:5 by Don-vip, 4 years ago

In 17154/josm:

see #15102 - see #16637 - get rid of real HTTP calls to https://httpbin(go).org in unit tests, mock them

comment:6 by simon04, 4 years ago

In 17189/josm:

see #15102 - see #16637 - get rid of real HTTP calls to https://josm.openstreetmap.de/josmticket in unit tests, mock them

comment:7 by simon04, 4 years ago

Milestone: 20.10

comment:8 by simon04, 4 years ago

In 17192/josm:

see #15102 - see #16637 - get rid of real HTTP calls to https://api.openstreetmap.org in ApiUrlTestTaskTest, mock them

comment:9 by simon04, 4 years ago

In 17194/josm:

see #15102 - see #16637 - get rid of real HTTP calls to https://api.openstreetmap.org in OsmServerHistoryReaderTest, mock them

comment:10 by simon04, 4 years ago

In 17195/josm:

see #15102 - see #16637 - Use WireMockServer.url()

comment:11 by simon04, 4 years ago

In 17196/josm:

see #15102 - see #16637 - get rid of real HTTP calls to https://www.openstreetmap.org/login in OsmOAuthAuthorizationClientTest, mock them

comment:12 by simon04, 4 years ago

Description: modified (diff)

comment:13 by simon04, 4 years ago

In 17197/josm:

see #15102 - see #16637 - get rid of real HTTP calls to https://www.openstreetmap.org/trace in HttpClientTest, mock them

comment:14 by simon04, 4 years ago

Description: modified (diff)

in reply to:  13 comment:15 by skyper, 4 years ago

Replying to simon04:

In 17197/josm:

see #15102 - see #16637 - get rid of real HTTP calls to https://www.openstreetmap.org/trace in HttpClientTest, mock them

This broke some other test.
Are failing tests a reason for not building the ubuntu package?

comment:16 by simon04, 4 years ago

In 17211/josm:

see #15102 - see #16637 - Fix HttpClientTest

comment:17 by Don-vip, 3 years ago

Resolution: fixed
Status: newclosed

comment:18 by Don-vip, 3 years ago

Milestone: 20.1020.11

Milestone renamed

comment:19 by Don-vip, 3 years ago

Two tests seem to still use the API directly, which is currently down:

 org.openstreetmap.josm.actions.downloadtasks.DownloadNotesTaskTest.testDownloadExternalFile
 org.openstreetmap.josm.data.oauth.SignpostAdaptersTest.testHttpResponseGetReasonPhrase

They failed with "connect time out" error.

java.lang.Exception: Test timed out after 10 000ms
	at org.openstreetmap.josm.testutils.JOSMTestRules$FailOnTimeoutStatement.evaluate(JOSMTestRules.java:778)
	at org.openstreetmap.josm.testutils.JOSMTestRules$CreateJosmEnvironment.evaluate(JOSMTestRules.java:733)
	at com.github.tomakehurst.wiremock.junit.WireMockRule$1.evaluate(WireMockRule.java:79)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
	at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
	at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at org.apache.tools.ant.taskdefs.optional.junitlauncher.LauncherSupport.launch(LauncherSupport.java:144)
	at org.apache.tools.ant.taskdefs.optional.junitlauncher.StandaloneLauncher.main(StandaloneLauncher.java:114)

{{
java.net.SocketTimeoutException: connect timed out
...

at java.base/java.net.Socket.connect(Socket.java:609)
at org.openstreetmap.josm.tools.Http1Client.performConnection(Http1Client.java:78)
at org.openstreetmap.josm.tools.HttpClient.connect(HttpClient.java:148)
at org.openstreetmap.josm.tools.HttpClient.connect(HttpClient.java:124)
at org.openstreetmap.josm.data.oauth.SignpostAdaptersTest.testHttpResponseGetReasonPhrase(SignpostAdaptersTest.java:97)

}}}

Version 1, edited 3 years ago by Don-vip (previous) (next) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.