From ebe6d5060e60f2bdbff4eb811028a7b9e6e50e53 Mon Sep 17 00:00:00 2001 From: Matthew Nesbit Date: Fri, 11 May 2018 11:44:51 +0100 Subject: [PATCH] Fix flaky integration test Reenable broken smokeTest so I can investigate Testing testing Testing testing remove debug --- .../corda/bridge/smoketest/BridgeSmokeTest.kt | 9 +++++---- .../net/corda/bridge/BridgeIntegrationTest.kt | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/bridge/bridgecapsule/src/smoke-test/kotlin/net/corda/bridge/smoketest/BridgeSmokeTest.kt b/bridge/bridgecapsule/src/smoke-test/kotlin/net/corda/bridge/smoketest/BridgeSmokeTest.kt index 5e4efac98d..5f3688b48b 100644 --- a/bridge/bridgecapsule/src/smoke-test/kotlin/net/corda/bridge/smoketest/BridgeSmokeTest.kt +++ b/bridge/bridgecapsule/src/smoke-test/kotlin/net/corda/bridge/smoketest/BridgeSmokeTest.kt @@ -28,7 +28,10 @@ import net.corda.testing.internal.rigorousMock import org.apache.activemq.artemis.api.core.RoutingType import org.apache.activemq.artemis.api.core.SimpleString import org.apache.curator.test.TestingServer -import org.junit.* +import org.junit.After +import org.junit.Before +import org.junit.Rule +import org.junit.Test import org.junit.rules.TemporaryFolder import java.net.Socket import java.nio.file.Path @@ -39,7 +42,6 @@ import java.util.concurrent.Executors import java.util.concurrent.TimeUnit import kotlin.streams.toList -@Ignore class BridgeSmokeTest { companion object { val log = contextLogger() @@ -89,7 +91,6 @@ class BridgeSmokeTest { artemisClient.stop() artemisServer.stop() } - } private fun copyBridgeResource(resourceName: String) { @@ -184,7 +185,7 @@ class BridgeSmokeTest { throw e } finally { executor.shutdownNow() - process.destroyForcibly() + process.destroy() } } diff --git a/bridge/src/integration-test/kotlin/net/corda/bridge/BridgeIntegrationTest.kt b/bridge/src/integration-test/kotlin/net/corda/bridge/BridgeIntegrationTest.kt index 2735a32dd6..9c1969e1d8 100644 --- a/bridge/src/integration-test/kotlin/net/corda/bridge/BridgeIntegrationTest.kt +++ b/bridge/src/integration-test/kotlin/net/corda/bridge/BridgeIntegrationTest.kt @@ -274,6 +274,8 @@ class BridgeIntegrationTest { val (artemisServer, artemisClient) = createArtemis() val (artemisServer2, artemisClient2) = createArtemis2() try { + artemisServer2.start() + artemisClient2.start() installBridgeControlResponder(artemisClient) installBridgeControlResponder(artemisClient2) val bridge = BridgeInstance(config, BridgeVersionInfo(1, "1.1", "Dummy", "Test")) @@ -323,7 +325,6 @@ class BridgeIntegrationTest { val (artemisServer2, artemisClient2) = createArtemis2() try { installBridgeControlResponder(artemisClient) - installBridgeControlResponder(artemisClient2) val bridge = BridgeInstance(bridgeConfig, BridgeVersionInfo(1, "1.1", "Dummy", "Test")) val bridgeStateFollower = bridge.activeChange.toBlocking().iterator val float = BridgeInstance(floatConfig, BridgeVersionInfo(1, "1.1", "Dummy", "Test")) @@ -344,7 +345,17 @@ class BridgeIntegrationTest { assertEquals(false, bridgeStateFollower.next()) assertEquals(false, bridge.active) assertEquals(true, float.active) - assertEquals(false, serverListening("localhost", 10005)) // now activated + var timeout = 0 + var listeningState = serverListening("localhost", 10005) + while (listeningState && timeout < 10) { // Allow a short while for close down to propagate + ++timeout + Thread.sleep(1000L) + listeningState = serverListening("localhost", 10005) + } + assertEquals(false, listeningState) // now not activated + artemisServer2.start() // Now enable second artemis to failover to + artemisClient2.start() + installBridgeControlResponder(artemisClient2) assertEquals(true, bridgeStateFollower.next()) assertEquals(true, bridge.active) assertEquals(true, float.active) @@ -403,8 +414,6 @@ class BridgeIntegrationTest { } val artemisServer = ArtemisMessagingServer(artemisConfig, NetworkHostAndPort("0.0.0.0", 12005), MAX_MESSAGE_SIZE) val artemisClient = ArtemisMessagingClient(artemisConfig, NetworkHostAndPort("localhost", 12005), MAX_MESSAGE_SIZE) - artemisServer.start() - artemisClient.start() return Pair(artemisServer, artemisClient) }