From 19952dec477a2d58ddd09a8a7e3c10baca0de0b2 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 27 Nov 2012 21:06:23 -0500 Subject: [PATCH] Refactoring ConcurrentOpenSocketFinderTest.testChecksSocketsConcurrently to try to prevent timeouts --- .../compute/util/ConcurrentOpenSocketFinderTest.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/compute/src/test/java/org/jclouds/compute/util/ConcurrentOpenSocketFinderTest.java b/compute/src/test/java/org/jclouds/compute/util/ConcurrentOpenSocketFinderTest.java index 5421f4cf67..8857bc8fe6 100644 --- a/compute/src/test/java/org/jclouds/compute/util/ConcurrentOpenSocketFinderTest.java +++ b/compute/src/test/java/org/jclouds/compute/util/ConcurrentOpenSocketFinderTest.java @@ -111,25 +111,18 @@ public class ConcurrentOpenSocketFinderTest { @Test public void testChecksSocketsConcurrently() throws Exception { - long delayForReachableMs = 25; - expect(nodeRunning.apply(EasyMock.>anyObject())).andReturn(true); replay(nodeRunning); // Can't use mock+answer for concurrency tests; EasyMock uses lock in ReplayState ControllableSocketOpen socketTester = new ControllableSocketOpen(ImmutableMap.of( - HostAndPort.fromParts("1.2.3.4", 22), new SlowCallable(false, 1000), - HostAndPort.fromParts("1.2.3.5", 22), new SlowCallable(true, delayForReachableMs))); + HostAndPort.fromParts("1.2.3.4", 22), new SlowCallable(true, 1500), + HostAndPort.fromParts("1.2.3.5", 22), new SlowCallable(true, 1000))); OpenSocketFinder finder = new ConcurrentOpenSocketFinder(socketTester, null, threadPool); - Stopwatch stopwatch = new Stopwatch(); - stopwatch.start(); HostAndPort result = finder.findOpenSocketOnNode(node, 22, 2000, TimeUnit.MILLISECONDS); - long timetaken = stopwatch.elapsedMillis(); - assertEquals(result, HostAndPort.fromParts("1.2.3.5", 22)); - assertTrue(timetaken >= delayForReachableMs-EARLY_GRACE && timetaken <= delayForReachableMs+SLOW_GRACE, "timetaken="+timetaken); verify(node); }