Skip to content

Commit

Permalink
increased sleep time in RoutedStoreTest
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjiewu committed Sep 19, 2012
1 parent 6b9260f commit c26373f
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions test/unit/voldemort/store/routed/RoutedStoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
public class RoutedStoreTest extends AbstractByteArrayStoreTest {

public static final int BANNAGE_PERIOD = 1000;
public static final int SLEEPY_TIME = 81;
public static final int SLEEPY_TIME = 200;
public static final int OPERATION_TIMEOUT = 60;

private Cluster cluster;
Expand Down Expand Up @@ -204,7 +204,7 @@ else if(count < failing + sleepy)
routedStoreThreadPool = Executors.newFixedThreadPool(threads);
RoutedStoreFactory routedStoreFactory = new RoutedStoreFactory(isPipelineRoutedStoreEnabled,
routedStoreThreadPool,
new TimeoutConfig(1000L,
new TimeoutConfig(BANNAGE_PERIOD,
false));

return routedStoreFactory.create(cluster, storeDef, subStores, true, failureDetector);
Expand Down Expand Up @@ -415,7 +415,7 @@ public void testZoneRouting() throws Exception {
s1.put(new ByteArray("test".getBytes()), versioned, null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 81, elapsed < 81);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
// Putting extra key to test getAll
s1.put(new ByteArray("test2".getBytes()), versioned, null);
Expand All @@ -425,7 +425,7 @@ public void testZoneRouting() throws Exception {
s1.get(new ByteArray("test".getBytes()), null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 130, elapsed < 130);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}

start = System.nanoTime();
Expand All @@ -436,23 +436,21 @@ public void testZoneRouting() throws Exception {
}
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 81, elapsed < 81);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}

// make sure the failure detector adds back any previously failed nodes
Thread.sleep(BANNAGE_PERIOD * 2);
start = System.nanoTime();
try {
s1.delete(new ByteArray("test".getBytes()), versioned.getVersion());
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 81, elapsed < 81);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}

// make sure sleepy stores processed the delete before checking,
// otherwise, we might be bailing
// out of the test too early for the delete to be processed.
Thread.sleep(SLEEPY_TIME);
Thread.sleep(SLEEPY_TIME * 2);
List<ByteArray> keys = Lists.newArrayList(new ByteArray("test".getBytes()),
new ByteArray("test2".getBytes()));

Expand All @@ -474,7 +472,7 @@ public void testZoneRouting() throws Exception {
zoneReplicationFactor,
RoutingStrategyType.ZONE_STRATEGY,
SLEEPY_TIME,
1000,
BANNAGE_PERIOD,
new VoldemortException());

start = System.nanoTime();
Expand All @@ -483,7 +481,7 @@ public void testZoneRouting() throws Exception {
s2.put(new ByteArray("test".getBytes()), versioned, null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " > " + 81, elapsed >= 81);
assertTrue(elapsed + " > " + SLEEPY_TIME, elapsed >= SLEEPY_TIME);
}
s2.put(new ByteArray("test2".getBytes()), versioned, null);

Expand Down Expand Up @@ -534,16 +532,16 @@ public void testZoneRouting() throws Exception {
null,
zoneReplicationFactor,
RoutingStrategyType.ZONE_STRATEGY,
81,
1000,
SLEEPY_TIME,
BANNAGE_PERIOD,
new VoldemortException());

start = System.nanoTime();
try {
s3.put(new ByteArray("test".getBytes()), versioned, null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 81, elapsed < 81);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}
// Putting extra key to test getAll
s3.put(new ByteArray("test2".getBytes()), versioned, null);
Expand All @@ -556,23 +554,23 @@ public void testZoneRouting() throws Exception {
}
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 81, elapsed < 81);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}

start = System.nanoTime();
try {
s3.get(new ByteArray("test".getBytes()), null);
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 81, elapsed < 81);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}

start = System.nanoTime();
try {
s3.delete(new ByteArray("test".getBytes()), versioned.getVersion());
} finally {
long elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 81, elapsed < 81);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}

// Basic put with zone read = 1, zone write = 1 and failures in other
Expand All @@ -587,8 +585,8 @@ public void testZoneRouting() throws Exception {
null,
zoneReplicationFactor,
RoutingStrategyType.ZONE_STRATEGY,
81,
1000,
SLEEPY_TIME,
BANNAGE_PERIOD,
new VoldemortException());

try {
Expand Down Expand Up @@ -875,7 +873,7 @@ public void testGetAllWithFailingStore() throws Exception {
routedStoreThreadPool = Executors.newFixedThreadPool(1);
RoutedStoreFactory routedStoreFactory = new RoutedStoreFactory(isPipelineRoutedStoreEnabled,
routedStoreThreadPool,
new TimeoutConfig(1000L,
new TimeoutConfig(BANNAGE_PERIOD,
false));

RoutedStore routedStore = routedStoreFactory.create(cluster,
Expand Down Expand Up @@ -932,7 +930,7 @@ public void testGetAllWithMorePreferredReadsThanNodes() throws Exception {
routedStoreThreadPool = Executors.newFixedThreadPool(1);
RoutedStoreFactory routedStoreFactory = new RoutedStoreFactory(isPipelineRoutedStoreEnabled,
routedStoreThreadPool,
new TimeoutConfig(1000L,
new TimeoutConfig(BANNAGE_PERIOD,
false));

RoutedStore routedStore = routedStoreFactory.create(cluster,
Expand Down Expand Up @@ -1040,7 +1038,7 @@ public void testPutWithOneNodeDownAndOneNodeSlow() throws Exception {
routedStoreThreadPool = Executors.newFixedThreadPool(1);
RoutedStoreFactory routedStoreFactory = new RoutedStoreFactory(isPipelineRoutedStoreEnabled,
routedStoreThreadPool,
new TimeoutConfig(1000L,
new TimeoutConfig(BANNAGE_PERIOD,
false));

RoutedStore routedStore = routedStoreFactory.create(cluster,
Expand Down Expand Up @@ -1247,7 +1245,7 @@ public void testNoReadRepair() throws Exception {
routedStoreThreadPool = Executors.newFixedThreadPool(1);
RoutedStoreFactory routedStoreFactory = new RoutedStoreFactory(isPipelineRoutedStoreEnabled,
routedStoreThreadPool,
new TimeoutConfig(1000L,
new TimeoutConfig(BANNAGE_PERIOD,
false));

RoutedStore routedStore = routedStoreFactory.create(cluster,
Expand Down Expand Up @@ -1392,7 +1390,7 @@ public void testPutDeleteZoneRouting() throws Exception {
Store<ByteArray, byte[], byte[]> subStore = null;

if(sleepy != null && sleepy.contains(n.getId()))
subStore = new SleepyStore<ByteArray, byte[], byte[]>(81,
subStore = new SleepyStore<ByteArray, byte[], byte[]>(SLEEPY_TIME,
new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test"));
else
subStore = new InMemoryStorageEngine<ByteArray, byte[], byte[]>("test");
Expand All @@ -1416,7 +1414,8 @@ public void testPutDeleteZoneRouting() throws Exception {
routedStoreThreadPool = Executors.newFixedThreadPool(8);
RoutedStoreFactory routedStoreFactory = new RoutedStoreFactory(true,
routedStoreThreadPool,
new TimeoutConfig(60, false));
new TimeoutConfig(OPERATION_TIMEOUT,
false));

Store<ByteArray, byte[], byte[]> s1 = routedStoreFactory.create(cluster,
storeDef,
Expand All @@ -1433,10 +1432,10 @@ public void testPutDeleteZoneRouting() throws Exception {
s1.put(new ByteArray("test".getBytes()), versioned, null);
} finally {
elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 81, elapsed < 81);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}

Thread.sleep(81 - elapsed);
Thread.sleep(SLEEPY_TIME - elapsed);

for(Node node: nodesRoutedTo) {
assertEquals(subStores.get(node.getId())
Expand All @@ -1451,10 +1450,10 @@ public void testPutDeleteZoneRouting() throws Exception {
s1.delete(new ByteArray("test".getBytes()), versioned.getVersion());
} finally {
elapsed = (System.nanoTime() - start) / Time.NS_PER_MS;
assertTrue(elapsed + " < " + 81, elapsed < 81);
assertTrue(elapsed + " < " + SLEEPY_TIME, elapsed < SLEEPY_TIME);
}

Thread.sleep(81 - elapsed);
Thread.sleep(SLEEPY_TIME - elapsed);

for(Node node: nodesRoutedTo) {
assertEquals(subStores.get(node.getId())
Expand Down

0 comments on commit c26373f

Please sign in to comment.