Permalink
Browse files

Fixed unit test for gossip.

  • Loading branch information...
1 parent cad759a commit 3205dfda70206fbf29895b80ba03a95fd927feaa @afeinberg afeinberg committed Feb 1, 2010
Showing with 22 additions and 26 deletions.
  1. +22 −26 test/unit/voldemort/server/gossip/GossiperTest.java
@@ -29,27 +29,40 @@
private List<VoldemortServer> servers = new ArrayList<VoldemortServer>();
private Cluster cluster;
+ private Properties props = new Properties();
private static String testStoreName = "test-replication-memory";
private static String storesXmlfile = "test/common/voldemort/config/stores.xml";
+
+
@Override
public void setUp() throws IOException {
+ props.put("enable.gossip", "true");
+ props.put("gossip.interval.ms", "250");
+
cluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0, 1, 2, 3 }, { 4, 5, 6, 7 },
- { 8, 9, 10, 11 } });
+ { 8, 9, 10, 11 } });
servers.add(ServerTestUtils.startVoldemortServer(ServerTestUtils.createServerConfig(0,
TestUtils.createTempDir()
.getAbsolutePath(),
null,
storesXmlfile,
- new Properties()),
+ props),
cluster));
servers.add(ServerTestUtils.startVoldemortServer(ServerTestUtils.createServerConfig(1,
TestUtils.createTempDir()
.getAbsolutePath(),
null,
storesXmlfile,
- new Properties()),
+ props),
+ cluster));
+ servers.add(ServerTestUtils.startVoldemortServer(ServerTestUtils.createServerConfig(2,
+ TestUtils.createTempDir()
+ .getAbsolutePath(),
+ null,
+ storesXmlfile,
+ props),
cluster));
}
@@ -77,18 +90,18 @@ public void testGossiper() throws Exception {
// Create a new partitioning scheme with room for a new server
final Cluster newCluster = ServerTestUtils.getLocalCluster(cluster.getNumberOfNodes() + 1,
ports,
- new int[][] { { 0, 1, 2 },
- { 3, 4, 5 },
- { 6, 7, 8 },
- { 9, 10, 11 } });
-
+ new int[][] {{ 0, 4, 8 },
+ { 1, 5, 9 },
+ { 2, 6, 10 },
+ { 3, 7, 11 }});
+
// Start the new server
VoldemortServer newServer = ServerTestUtils.startVoldemortServer(ServerTestUtils.createServerConfig(3,
TestUtils.createTempDir()
.getAbsolutePath(),
null,
storesXmlfile,
- new Properties()),
+ props),
newCluster);
servers.add(newServer);
@@ -121,20 +134,6 @@ public void testGossiper() throws Exception {
Thread.currentThread().interrupt();
}
- // Start a thread pool for gossipers and start gossiping
- ExecutorService executorService = Executors.newFixedThreadPool(newCluster.getNumberOfNodes() + 1);
-
- List<Gossiper> gossipers = new ArrayList<Gossiper>(newCluster.getNumberOfNodes());
- for(VoldemortServer server: servers) {
- Gossiper gossiper = new Gossiper(server.getMetadataStore(),
- getAdminClient(server.getMetadataStore().getCluster(),
- server.getVoldemortConfig()),
- 50);
- gossiper.start();
- executorService.submit(gossiper);
- gossipers.add(gossiper);
- }
-
// Wait up to a second for gossip to spread
try {
TestUtils.assertWithBackoff(1000, new Attempt() {
@@ -160,9 +159,6 @@ public void checkCondition() {
});
} catch(InterruptedException e) {
Thread.currentThread().interrupt();
- } finally {
- for(Gossiper gossiper: gossipers)
- gossiper.stop();
}
}
}

0 comments on commit 3205dfd

Please sign in to comment.