Skip to content

Commit

Permalink
Wrapped tests that hang because of my changes with timeouts. This
Browse files Browse the repository at this point in the history
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 Oct 9, 2012
1 parent 4afb8c4 commit 3dfd81f
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 66 deletions.
6 changes: 3 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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}">
Expand All @@ -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}">
Expand All @@ -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" />
Expand Down
27 changes: 18 additions & 9 deletions test/unit/voldemort/client/AdminServiceBasicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -111,22 +116,24 @@ public static Collection<Object[]> configs() {
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,
Expand All @@ -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));
}

/**
Expand All @@ -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);
Expand Down Expand Up @@ -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"));
Expand Down
24 changes: 10 additions & 14 deletions test/unit/voldemort/client/rebalance/AbstractRebalanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 }, {} });
Expand Down Expand Up @@ -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 } });
Expand Down Expand Up @@ -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 } });
Expand Down Expand Up @@ -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 } });
Expand Down Expand Up @@ -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 } });
Expand Down Expand Up @@ -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 } });
Expand Down Expand Up @@ -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 }, {}, {} });
Expand Down Expand Up @@ -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 }, {}, {} });
Expand Down Expand Up @@ -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 } });
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 } });
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 3dfd81f

Please sign in to comment.