Permalink
Browse files

Wrapped tests that hang because of my changes with timeouts. This

is necessary for me to debug these tests and easily run all the
other tests. (By 'hang', I mean get into a state where clients
run forever complaining that there are not enough servers.)
Wrapping with timeouts is done both at the Junit
level (i.e., "@Test(timeout = ...")  and at the ant level (i.e.,
for an entire unit test).

Switched the tests I was touching to use Junit4 idiom rather than
Junit3 idiom. I.e., removed the 'extends TestCase' from the class
declaration.

Upped the memory allowed for all junit tets in ant from 1024m to
2048m since I ran into ant out of memory errors.
  • Loading branch information...
jayjwylie committed Sep 7, 2012
1 parent 4afb8c4 commit 3dfd81f441893b2227b8399638623bf2bf178867
View
@@ -381,7 +381,7 @@
<target name="junit" depends="build, buildtest" description="Run junit tests.">
<replace-dir dir="${testreport.dir}" />
<replace-dir dir="${testhtml.dir}" />
- <junit printsummary="yes" showoutput="true" maxmemory="1024m">
+ <junit printsummary="yes" showoutput="true" maxmemory="2048m" timeout="1200000">
<classpath refid="test-classpath" />
<formatter type="xml" />
<batchtest fork="yes" todir="${testreport.dir}">
@@ -402,7 +402,7 @@
<target name="junit-long" depends="build, buildtest, junit" description="Run long junit tests that uses larger data sets than normal junit tests.">
<replace-dir dir="${longtestreport.dir}" />
<replace-dir dir="${longtesthtml.dir}" />
- <junit printsummary="yes" showoutput="true" maxmemory="1024m">
+ <junit printsummary="yes" showoutput="true" maxmemory="2048m">
<classpath refid="test-classpath" />
<formatter type="xml" />
<batchtest fork="yes" todir="${longtestreport.dir}">
@@ -422,7 +422,7 @@
<target name="junit-test" depends="build, buildtest, contrib-jar" description="Run single junit test for class ClassName with -Dtest.name=[ClassName] (Note: Use the class name, not the file name with the .java extension)">
<replace-dir dir="${singletestreport.dir}" />
<replace-dir dir="${singletesthtml.dir}" />
- <junit printsummary="on" showoutput="true" maxmemory="1024m">
+ <junit printsummary="on" showoutput="true" maxmemory="2048m">
<classpath refid="contrib-test-classpath" />
<classpath path="${log4j.properties.dir}" />
<formatter type="plain" />
@@ -16,6 +16,12 @@
package voldemort.client;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
@@ -34,8 +40,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import junit.framework.TestCase;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -47,6 +51,7 @@
import voldemort.TestUtils;
import voldemort.VoldemortException;
import voldemort.client.protocol.admin.AdminClient;
+import voldemort.client.protocol.admin.AdminClientConfig;
import voldemort.cluster.Cluster;
import voldemort.cluster.Node;
import voldemort.cluster.Zone;
@@ -84,7 +89,7 @@
/**
*/
@RunWith(Parameterized.class)
-public class AdminServiceBasicTest extends TestCase {
+public class AdminServiceBasicTest {
private static int NUM_RUNS = 100;
private static int TEST_STREAM_KEYS_SIZE = 10000;
@@ -111,22 +116,24 @@ public AdminServiceBasicTest(boolean useNio) {
return Arrays.asList(new Object[][] { { true }, { false } });
}
- @Override
@Before
public void setUp() throws IOException {
cluster = ServerTestUtils.getLocalCluster(2, new int[][] { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } });
servers = new VoldemortServer[2];
storeDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile));
+ Properties serverProperties = new Properties();
+ serverProperties.setProperty("client.max.connections.per.node", "20");
+
servers[0] = ServerTestUtils.startVoldemortServer(socketStoreFactory,
ServerTestUtils.createServerConfig(useNio,
0,
TestUtils.createTempDir()
.getAbsolutePath(),
null,
storesXmlfile,
- new Properties()),
+ serverProperties),
cluster);
servers[1] = ServerTestUtils.startVoldemortServer(socketStoreFactory,
ServerTestUtils.createServerConfig(useNio,
@@ -135,10 +142,12 @@ public void setUp() throws IOException {
.getAbsolutePath(),
null,
storesXmlfile,
- new Properties()),
+ serverProperties),
cluster);
- adminClient = ServerTestUtils.getAdminClient(cluster);
+ Properties adminProperties = new Properties();
+ adminProperties.setProperty("max_connections", "20");
+ adminClient = new AdminClient(cluster, new AdminClientConfig(adminProperties));
}
/**
@@ -151,9 +160,8 @@ private VoldemortServer getServer(int nodeId) {
return servers[nodeId];
}
- @Override
@After
- public void tearDown() throws IOException, InterruptedException {
+ public void tearDown() throws IOException {
adminClient.stop();
for(VoldemortServer server: servers) {
ServerTestUtils.stopVoldemortServer(server);
@@ -1121,6 +1129,7 @@ private void generateAndFetchFiles(int numChunks, long versionId, long indexSize
@Test
public void testGetROStorageFormat() {
+
Map<String, String> storesToStorageFormat = getAdminClient().getROStorageFormat(0,
Lists.newArrayList("test-readonly-fetchfiles",
"test-readonly-versions"));
@@ -262,7 +262,7 @@ protected int getNumKeys() {
return NUM_KEYS;
}
- @Test
+ @Test(timeout = 60000)
public void testRORWRebalance() throws Exception {
Cluster currentCluster = ServerTestUtils.getLocalCluster(2, new int[][] {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8 }, {} });
@@ -310,7 +310,7 @@ public void testRORWRebalance() throws Exception {
}
}
- @Test
+ @Test(timeout = 60000)
public void testRORWRebalanceWithReplication() throws Exception {
Cluster currentCluster = ServerTestUtils.getLocalCluster(2, new int[][] {
{ 0, 1, 2, 3, 4, 5, 6 }, { 7, 8 } });
@@ -354,7 +354,7 @@ public void testRORWRebalanceWithReplication() throws Exception {
}
}
- @Test
+ @Test(timeout = 60000)
public void testRORebalanceWithReplication() throws Exception {
Cluster currentCluster = ServerTestUtils.getLocalCluster(2, new int[][] {
{ 0, 1, 2, 3, 4, 5, 6 }, { 7, 8 } });
@@ -395,7 +395,7 @@ public void testRORebalanceWithReplication() throws Exception {
}
}
- @Test
+ @Test(timeout = 60000)
public void testRWRebalanceWithReplication() throws Exception {
Cluster currentCluster = ServerTestUtils.getLocalCluster(2, new int[][] {
{ 0, 1, 2, 3, 4, 5, 6 }, { 7, 8 } });
@@ -437,7 +437,7 @@ public void testRWRebalanceWithReplication() throws Exception {
}
}
- @Test
+ @Test(timeout = 60000)
public void testRebalanceCleanPrimary() throws Exception {
Cluster currentCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0 }, { 1, 3 },
{ 2 } });
@@ -538,7 +538,7 @@ public void testRebalanceCleanPrimary() throws Exception {
}
}
- @Test
+ @Test(timeout = 60000)
public void testRebalanceCleanSecondary() throws Exception {
Cluster currentCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0, 3 }, { 1 },
{ 2 } });
@@ -640,7 +640,7 @@ public void testRebalanceCleanSecondary() throws Exception {
}
}
- @Test
+ @Test(timeout = 60000)
public void testRWRebalanceFourNodes() throws Exception {
Cluster currentCluster = ServerTestUtils.getLocalCluster(4, new int[][] {
{ 0, 1, 4, 7, 9 }, { 2, 3, 5, 6, 8 }, {}, {} });
@@ -700,7 +700,7 @@ public void testRWRebalanceFourNodes() throws Exception {
}
}
- @Test
+ @Test(timeout = 60000)
public void testRWRebalanceSerial() throws Exception {
Cluster currentCluster = ServerTestUtils.getLocalCluster(4, new int[][] {
{ 0, 1, 4, 7, 9 }, { 2, 3, 5, 6, 8 }, {}, {} });
@@ -762,7 +762,7 @@ public void testRWRebalanceSerial() throws Exception {
}
}
- @Test
+ @Test(timeout = 60000)
public void testProxyGetDuringRebalancing() throws Exception {
final Cluster currentCluster = ServerTestUtils.getLocalCluster(2, new int[][] {
{ 0, 1, 2, 3, 4, 5, 6 }, { 7, 8 } });
@@ -823,14 +823,12 @@ public void run() {
try {
List<String> keys = new ArrayList<String>(testEntries.keySet());
- int nRequests = 0;
while(!rebalancingToken.get()) {
// should always able to get values.
int index = (int) (Math.random() * keys.size());
// should get a valid value
try {
- nRequests++;
Versioned<String> value = storeClientRW.get(keys.get(index));
assertNotSame("StoreClient get() should not return null.", null, value);
assertEquals("Value returned should be good",
@@ -898,7 +896,7 @@ public void run() {
}
}
- @Test
+ @Test(timeout = 60000)
public void testServerSideRouting() throws Exception {
final Cluster currentCluster = ServerTestUtils.getLocalCluster(2, new int[][] {
{ 0, 1, 2, 3, 4, 5, 6 }, { 7, 8 } });
@@ -956,14 +954,12 @@ public void run() {
try {
List<String> keys = new ArrayList<String>(testEntries.keySet());
- int nRequests = 0;
while(!rebalancingToken.get()) {
// should always able to get values.
int index = (int) (Math.random() * keys.size());
// should get a valid value
try {
- nRequests++;
List<Versioned<byte[]>> values = serverSideRoutingStoreRW.get(new ByteArray(ByteUtils.getBytes(keys.get(index),
"UTF-8")),
null);
Oops, something went wrong.

0 comments on commit 3dfd81f

Please sign in to comment.