Https test hang forever
See original GitHub issueWiremock version: 2.1.11 I have a simple test like this
@Rule
public final WireMockRule service = new WireMockRule(wireMockConfig().httpsPort(8443));
@Before
public void setup() {
service.stubFor(post(urlEqualTo("/some/endpoint"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")));
}
@Test
public void test() {
// sending request to https://myserver.com:8443/some/endpoint
Response response = client.request();
Assert.assertEquals(200, response.getStatus());
}
However, the test hangs forever at the requesting step.
The test will eventually timeout with this stacktrace
testSendMessage(com.opower.dyn.TestSendApi) Time elapsed: 75.409 sec <<< ERROR!
javax.ws.rs.ProcessingException: java.net.ConnectException: Operation timed out
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:184)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:227)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:652)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:422)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:652)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:412)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:321)
at com.opower.dyn.SendApi.sendMessage(SendApi.java:55)
at com.opower.dyn.TestSendApi.testSendMessage(TestSendApi.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at com.github.tomakehurst.wiremock.junit.WireMockRule$1.evaluate(WireMockRule.java:72)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.net.ConnectException: Operation timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
Issue Analytics
- State:
- Created 7 years ago
- Comments:19
Top Results From Across the Web
Https test hang forever · Issue #485 · wiremock ... - GitHub
Wiremock version: 2.1.11 I have a simple test like this @Rule public final WireMockRule service = new WireMockRule(wireMockConfig().
Read more >node.js - jest hangs indefinitely, runs no tests - Stack Overflow
Running watchman version hangs indefinitely. do this to fix the watchman from hanging: launchctl unload ~/Library/LaunchAgents/com.github.
Read more >Gradle test hangs forever - Help/Discuss
I have suite of tests which successfully run and complete in maven. However with gradle I find that its just hung forever at...
Read more >Build hangs forever when starting REPL or test first time for sbt ...
Build hangs forever when starting REPL or test first time for sbt project. Steps to reproduce the issue: Create simple sbt project with...
Read more >Pester task hangs and runs forever - Visual Studio Feedback
As far as I understand, the Pester test runner task was upgraded by MS till 9.4.0 and now our releases are just hanging...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I also came across this kind of problem where Wiremock starts to hang when multiple tests are ran in a suite. I realized at some point that the stub definition of my responses didn’t include the
Connection: Close
http header. I tried adding it and it seems to have fixed the issue.Since I’m lazy and don’t want to forget adding it somewhere, I wrote a simple extension that I add to my WireMockRule:
I hope this helps!
Just spent all day trying to figure out why a wiremock rule (using Wiremock 1.57) was failing to respond after about 35 tests using it from multiple classes (a Wireshark trace showed that HTTP GET responses were getting no response when tests started failing). I am running tests from multiple xxxIT classes using failsafe with a test suite class: ITestSuite, which names the IT classes. All the IT classes extend a common base class which contained the rule, declared as a static ClassRule: @ClassRule public static WireMockClassRule configRule = new WireMockClassRule(CONFIG_PORT); The rule failed to return results once tests from the 3rd class were executing. SOLUTION was to declare the rule in the test suite and reference it in the common base class: ITestSuite: @ClassRule public static final WireMockClassRule CONFIG_RULE = new WireMockClassRule(19690); Base class: @ClassRule public static final WireMockClassRule configRule = ITestSuite.CONFIG_RULE;
For the curious I just debugged to understand more. The apply method in the outer WiremockClassRule in ITestSuite sets it into the running state, then the rule in the class sees it as already in running state in its apply execution. Take a look at the WiremockClassRule.apply method. Since it’s already running it doesn’t need to start and stop the (Jetty http) server for each test method. I think continually starting and stopping the server was the root cause of the issue.