Modify

Opened 5 years ago

Closed 3 years ago

Last modified 23 months 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 Changed 5 years ago by ris

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

comment:2 Changed 5 years ago by Don-vip

In 14191/josm:

see #16637 - javadoc

comment:3 Changed 3 years ago by simon04

Related: #15102

comment:4 Changed 3 years ago by Don-vip

In 17075/josm:

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

comment:5 Changed 3 years ago by Don-vip

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 Changed 3 years ago by simon04

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 Changed 3 years ago by simon04

Milestone: 20.10

comment:8 Changed 3 years ago by simon04

In 17192/josm:

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

comment:9 Changed 3 years ago by simon04

In 17194/josm:

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

comment:10 Changed 3 years ago by simon04

In 17195/josm:

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

comment:11 Changed 3 years ago by simon04

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 Changed 3 years ago by simon04

Description: modified (diff)

comment:13 Changed 3 years ago by simon04

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 Changed 3 years ago by simon04

Description: modified (diff)

comment:15 in reply to:  13 Changed 3 years ago by skyper

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 Changed 3 years ago by simon04

In 17211/josm:

see #15102 - see #16637 - Fix HttpClientTest

comment:17 Changed 3 years ago by Don-vip

Resolution: fixed
Status: newclosed

comment:18 Changed 3 years ago by Don-vip

Milestone: 20.1020.11

Milestone renamed

comment:19 Changed 23 months ago by Don-vip

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)
Last edited 23 months ago by Don-vip (previous) (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.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.