From 8299c146eaacda54d1ab07dc3ca57e06cc822cbd Mon Sep 17 00:00:00 2001 From: Zhongjie Wu Date: Mon, 2 Dec 2013 16:34:32 -0800 Subject: [PATCH] added test to support non contiguous zone and node ids in test cases --- .../voldemort/store/system/SystemStoreTest.java | 37 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/test/unit/voldemort/store/system/SystemStoreTest.java b/test/unit/voldemort/store/system/SystemStoreTest.java index 5f8e2c610..47b783de8 100644 --- a/test/unit/voldemort/store/system/SystemStoreTest.java +++ b/test/unit/voldemort/store/system/SystemStoreTest.java @@ -19,6 +19,8 @@ package voldemort.store.system; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Properties; @@ -26,6 +28,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; import voldemort.ClusterTestUtils; import voldemort.ServerTestUtils; import voldemort.TestUtils; @@ -49,6 +53,7 @@ import voldemort.store.socket.clientrequest.ClientRequestExecutorPool; * @author csoman * */ +@RunWith(Parameterized.class) public class SystemStoreTest { private static String storesXmlfile = "test/common/voldemort/config/stores.xml"; @@ -62,15 +67,32 @@ public class SystemStoreTest { private VoldemortServer[] servers; private Cluster cluster; public static String socketUrl = ""; - protected final int CLIENT_ZONE_ID = 0; + private final Integer clientZoneId; + private StoreDefinition storeDef; + private List storeDefs; + + + @Parameterized.Parameters + public static Collection configs() { + return Arrays.asList(new Object[][]{ + {0, ClusterTestUtils.getZZZCluster(), ClusterTestUtils.getZZZ322StoreDefs("memory")}, + {1, ClusterTestUtils.getZZZCluster(), ClusterTestUtils.getZZZ322StoreDefs("memory")}, + {2, ClusterTestUtils.getZZZCluster(), ClusterTestUtils.getZZZ322StoreDefs("memory")}, + {1, ClusterTestUtils.getZ1Z3ClusterWithNonContiguousNodeIds(), ClusterTestUtils.getZ1Z3322StoreDefs("memory")}, + {3, ClusterTestUtils.getZ1Z3ClusterWithNonContiguousNodeIds(), ClusterTestUtils.getZ1Z3322StoreDefs("memory")}}); + } + + public SystemStoreTest(Integer clientZoneId, Cluster cluster, List storeDefs) { + this.clientZoneId = clientZoneId; + this.cluster = cluster; + this.storeDefs = storeDefs; + this.storeDef = storeDefs.get(0); + } @Before public void setUp() throws Exception { - - cluster = ClusterTestUtils.getZZZCluster(); servers = new VoldemortServer[cluster.getNodeIds().size()]; - List storeDefs = ClusterTestUtils.getZZZ322StoreDefs("bdb"); int i = 0; for(Integer nodeId: cluster.getNodeIds()) { @@ -103,13 +125,14 @@ public class SystemStoreTest { for(VoldemortServer server: servers) { ServerTestUtils.stopVoldemortServer(server); } + ClusterTestUtils.reset(); } @Test public void testBasicStore() { try { ClientConfig clientConfig = new ClientConfig(); - clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.CLIENT_ZONE_ID); + clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.clientZoneId); SystemStoreClientFactory systemStoreFactory = new SystemStoreClientFactory(clientConfig); SystemStoreClient sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name()); @@ -128,7 +151,7 @@ public class SystemStoreTest { public void testCustomClusterXmlStore() { try { ClientConfig clientConfig = new ClientConfig(); - clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.CLIENT_ZONE_ID); + clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.clientZoneId); SystemStoreClientFactory systemStoreFactory = new SystemStoreClientFactory(clientConfig); SystemStoreClient sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name(), this.clusterXml, @@ -149,7 +172,7 @@ public class SystemStoreTest { public void testIllegalSystemStore() { try { ClientConfig clientConfig = new ClientConfig(); - clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.CLIENT_ZONE_ID); + clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.clientZoneId); SystemStoreClientFactory systemStoreFactory = new SystemStoreClientFactory(clientConfig); SystemStoreClient sysVersionStore = systemStoreFactory.createSystemStore("test-store", this.clusterXml, -- 2.11.4.GIT