Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
None
-
None
-
None
Description
Test BDBHAVirtualHostNodeRestTest.testIntruderBDBHAVHNNotAllowedToConnect(BDBHAVirtualHostNodeRestTest failed recently with the following error:
Unexpected response code from PUT virtualhostnode/node3 expected:<201> but was:<422> Stacktrace java.lang.AssertionError: Unexpected response code from PUT virtualhostnode/node3 expected:<201> but was:<422> at org.junit.Assert.fail(Assert.java:88) at org.junit.Assert.failNotEquals(Assert.java:743) at org.junit.Assert.assertEquals(Assert.java:118) at org.junit.Assert.assertEquals(Assert.java:555) at org.apache.qpid.systest.rest.RestTestHelper.submitRequest(RestTestHelper.java:594) at org.apache.qpid.server.store.berkeleydb.replication.BDBHAVirtualHostNodeRestTest.testIntruderBDBHAVHNNotAllowedToConnect(BDBHAVirtualHostNodeRestTest.java:252)
The test logs contain records of 2 HTTP requests being made to join the HA node to the group whilst test intended to make only one HTTP request.
2016-10-06 22:00:57,857 DEBUG [HttpManagement-http-2022] o.a.q.s.m.p.f.LoggingFilter REQUEST user='null' method='PUT' url='http://localhost:51866/api/latest/virtualhostnode/node3' 2016-10-06 22:00:57,860 DEBUG [HttpManagement-http-2038] o.a.q.s.m.p.f.LoggingFilter REQUEST user='null' method='PUT' url='http://localhost:51866/api/latest/virtualhostnode/node3'
The first request was successfully completed
2016-10-06 22:00:58,210 DEBUG [HttpManagement-http-2022] o.a.q.s.m.p.f.LoggingFilter RESPONSE user='[/127.0.0.1:48747, webadmin]' method='PUT' url='http://localhost:51866/api/latest/virtualhostnode/node3' status='201'
The second spurious request had failed
WARN [HttpManagement-http-2038] o.a.q.s.m.p.s.r.RestServlet IllegalConfigurationException processing request http://localhost:51866/api/latest/virtualhostnode/node3 from user '[/127.0.0.1:48849, webadmin]': Cannot bind to address 'localhost:10002'. Address is already in use. 2016-10-06 22:00:58,221 DEBUG [VirtualHostNode-node3-Config] o.a.q.s.c.u.TaskExecutorImpl Performing Task['create' on 'VirtualHost[id=35bb124e-1e4d-4c06-812e-c92c13b0b4d3, name=BDBHAVirtualHostNodeRestTest.testIntruderBDBHAVHNNotAllowedToConnect, type=BDB_HA_REPLICA]'] 2016-10-06 22:00:58,222 DEBUG [HttpManagement-http-2038] o.a.q.s.m.p.f.LoggingFilter RESPONSE user='[/127.0.0.1:48849, webadmin]' method='PUT' url='http://localhost:51866/api/latest/virtualhostnode/node3' status='422'
The client received response with http status code 422 which caused the test failure.
It looks like the problem lies in the code used to open URLConnection to the broker in RestTestHelper. We need to prevent URLConnection from being opened twice.