Skip to content

Commit

Permalink
added test to support non contiguous zone and node ids in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjiewu authored and singhsiddharth committed Dec 5, 2013
1 parent f77fd06 commit 8299c14
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions test/unit/voldemort/store/system/SystemStoreTest.java
Expand Up @@ -19,13 +19,17 @@
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;

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;
Expand All @@ -49,6 +53,7 @@
* @author csoman
*
*/
@RunWith(Parameterized.class)
public class SystemStoreTest {

private static String storesXmlfile = "test/common/voldemort/config/stores.xml";
Expand All @@ -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<StoreDefinition> storeDefs;


@Parameterized.Parameters
public static Collection<Object[]> 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<StoreDefinition> 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<StoreDefinition> storeDefs = ClusterTestUtils.getZZZ322StoreDefs("bdb");
int i = 0;

for(Integer nodeId: cluster.getNodeIds()) {
Expand Down Expand Up @@ -103,13 +125,14 @@ public void tearDown() throws Exception {
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<String, String> systemStoreFactory = new SystemStoreClientFactory<String, String>(clientConfig);
SystemStoreClient<String, String> sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());

Expand All @@ -128,7 +151,7 @@ public void testBasicStore() {
public void testCustomClusterXmlStore() {
try {
ClientConfig clientConfig = new ClientConfig();
clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.CLIENT_ZONE_ID);
clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.clientZoneId);
SystemStoreClientFactory<String, String> systemStoreFactory = new SystemStoreClientFactory<String, String>(clientConfig);
SystemStoreClient<String, String> sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name(),
this.clusterXml,
Expand All @@ -149,7 +172,7 @@ public void testCustomClusterXmlStore() {
public void testIllegalSystemStore() {
try {
ClientConfig clientConfig = new ClientConfig();
clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.CLIENT_ZONE_ID);
clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.clientZoneId);
SystemStoreClientFactory<String, String> systemStoreFactory = new SystemStoreClientFactory<String, String>(clientConfig);
SystemStoreClient sysVersionStore = systemStoreFactory.createSystemStore("test-store",
this.clusterXml,
Expand Down

0 comments on commit 8299c14

Please sign in to comment.