Permalink
Browse files

Modified the test and build file to shrink the large tests.

    The large tests are copied to the test/large
    To run short tests for sanity check purpose:
        ant junit
    To run short and long tests:
        ant junit-long
    To run short, long and contrib tests:
        ant junit-all
  • Loading branch information...
1 parent fcf7ed1 commit a3965e78dcc06c3908ce019c23cb5607fe560ed6 @zhongjiewu zhongjiewu committed with vinothchandar Jun 7, 2012
View
@@ -9,6 +9,7 @@ classes.dir=dist/classes
resources.dir=dist/resources
commontestsrc.dir=test/common
unittestsrc.dir=test/unit
+largetestsrc.dir=test/large
inttestsrc.dir=test/integration
testclasses.dir=dist/testclasses
testreport.dir=dist/junit-reports
View
@@ -103,6 +103,7 @@
<src path="${unittestsrc.dir}" />
<src path="${inttestsrc.dir}" />
<src path="${commontestsrc.dir}" />
+ <src path="${largetestsrc.dir}" />
<classpath refid="main-classpath" />
</javac>
</target>
@@ -387,14 +388,34 @@
</junitreport>
</target>
+ <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="${testreport.dir}" />
+ <replace-dir dir="${testhtml.dir}" />
+ <junit printsummary="yes" showoutput="true" maxmemory="1024m">
+ <classpath refid="test-classpath" />
+ <formatter type="xml" />
+ <batchtest fork="yes" todir="${testreport.dir}">
+ <fileset dir="${largetestsrc.dir}">
+ <include name="**/*Test.java" />
+ </fileset>
+ </batchtest>
+ </junit>
+ <junitreport todir="${testhtml.dir}">
+ <fileset dir="${testreport.dir}">
+ <include name="TEST-*.xml" />
+ </fileset>
+ <report todir="${testhtml.dir}" format="frames" />
+ </junitreport>
+ </target>
+
<target name="junit-test" depends="build, buildtest, contrib-jar" description="Run single junit test with -Dtest.name=">
<junit printsummary="yes" showoutput="true" maxmemory="1024m">
<classpath refid="contrib-test-classpath" />
<test name="${test.name}" />
</junit>
</target>
- <target name="junit-all" depends="junit, contrib-junit" description="Run All junit tests including contrib.">
+ <target name="junit-all" depends="junit-long, contrib-junit" description="Run All junit tests including contrib.">
</target>
<macrodef name="make-javadocs">
@@ -0,0 +1,119 @@
+package voldemort.client.rebalance;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import voldemort.ServerTestUtils;
+import voldemort.TestUtils;
+import voldemort.VoldemortException;
+import voldemort.cluster.Cluster;
+import voldemort.server.VoldemortConfig;
+import voldemort.server.VoldemortServer;
+import voldemort.store.metadata.MetadataStore.VoldemortState;
+
+/**
+ * Start VoldemortServer locally using ServerTestUtils and run rebalancing
+ * tests.
+ *
+ *
+ */
+@RunWith(Parameterized.class)
+public class RebalanceLargeTest extends AbstractRebalanceTest {
+
+ Map<Integer, VoldemortServer> serverMap = new HashMap<Integer, VoldemortServer>();
+ private final boolean useNio;
+ private final boolean useDonorBased;
+ protected static int NUM_MANY_KEYS = 10100;
+
+ public RebalanceLargeTest(boolean useNio, boolean useDonorBased) {
+ this.useNio = useNio;
+ this.useDonorBased = useDonorBased;
+ }
+
+ @Parameters
+ public static Collection<Object[]> configs() {
+ return Arrays.asList(new Object[][] { { true, true }, { true, false }, { false, true },
+ { false, false } });
+ }
+
+ @Override
+ protected int getNumKeys() {
+ return NUM_MANY_KEYS;
+ }
+
+ @Override
+ protected VoldemortState getCurrentState(int nodeId) {
+ VoldemortServer server = serverMap.get(nodeId);
+ if(server == null) {
+ throw new VoldemortException("Node id " + nodeId + " does not exist");
+ } else {
+ return server.getMetadataStore().getServerState();
+ }
+ }
+
+ @Override
+ protected Cluster getCurrentCluster(int nodeId) {
+ VoldemortServer server = serverMap.get(nodeId);
+ if(server == null) {
+ throw new VoldemortException("Node id " + nodeId + " does not exist");
+ } else {
+ return server.getMetadataStore().getCluster();
+ }
+ }
+
+ @Override
+ protected Cluster startServers(Cluster cluster,
+ String storeXmlFile,
+ List<Integer> nodeToStart,
+ Map<String, String> configProps) throws IOException {
+ for(int node: nodeToStart) {
+ Properties properties = new Properties();
+ if(null != configProps) {
+ for(Entry<String, String> property: configProps.entrySet()) {
+ properties.put(property.getKey(), property.getValue());
+ }
+ }
+
+ VoldemortConfig config = ServerTestUtils.createServerConfig(useNio,
+ node,
+ TestUtils.createTempDir()
+ .getAbsolutePath(),
+ null,
+ storeXmlFile,
+ properties);
+
+ VoldemortServer server = ServerTestUtils.startVoldemortServer(socketStoreFactory,
+ config,
+ cluster);
+ serverMap.put(node, server);
+ }
+
+ return cluster;
+ }
+
+ @Override
+ protected void stopServer(List<Integer> nodesToStop) throws IOException {
+ for(int node: nodesToStop) {
+ try {
+ ServerTestUtils.stopVoldemortServer(serverMap.get(node));
+ } catch(VoldemortException e) {
+ // ignore these at stop time
+ }
+ }
+ }
+
+ @Override
+ protected boolean useDonorBased() {
+ return this.useDonorBased;
+ }
+}
@@ -29,8 +29,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -86,7 +86,7 @@
public abstract class AbstractRebalanceTest {
- protected static int NUM_KEYS = 10100;
+ protected static int NUM_KEYS = 20;
protected static int NUM_RO_CHUNKS_PER_BUCKET = 10;
protected static String testStoreNameRW = "test";
protected static String testStoreNameRW2 = "test2";
@@ -111,7 +111,7 @@
@Before
public void setUp() throws IOException {
- testEntries = ServerTestUtils.createRandomKeyValueString(NUM_KEYS);
+ testEntries = ServerTestUtils.createRandomKeyValueString(getNumKeys());
socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
// First without replication
@@ -258,6 +258,10 @@ public void checkConsistentMetadata(Cluster targetCluster, List<Integer> serverL
}
}
+ protected int getNumKeys() {
+ return NUM_KEYS;
+ }
+
@Test
public void testRORWRebalance() throws Exception {
Cluster currentCluster = ServerTestUtils.getLocalCluster(2, new int[][] {
@@ -1053,9 +1057,10 @@ protected void populateData(Cluster cluster,
// Create SocketStores for each Node first
Map<Integer, Store<ByteArray, byte[], byte[]>> storeMap = new HashMap<Integer, Store<ByteArray, byte[], byte[]>>();
for(Node node: cluster.getNodes()) {
- storeMap.put(node.getId(), getSocketStore(storeDef.getName(),
- node.getHost(),
- node.getSocketPort()));
+ storeMap.put(node.getId(),
+ getSocketStore(storeDef.getName(),
+ node.getHost(),
+ node.getSocketPort()));
}

0 comments on commit a3965e7

Please sign in to comment.