Skip to content

Commit

Permalink
Fixed minor issue with tests in AdminServiceBasicTest. They were not …
Browse files Browse the repository at this point in the history
…including an appropriate zone list when constructing a cluster.
  • Loading branch information
jayjwylie committed Mar 20, 2013
1 parent b8f93b2 commit 10d57ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/java/voldemort/cluster/Cluster.java
Expand Up @@ -74,9 +74,10 @@ public Cluster(String name, List<Node> nodes, List<Zone> zones) {
} else {
// Add default zone
zonesById = new LinkedHashMap<Integer, Zone>(1);
zonesById.put(Zone.DEFAULT_ZONE_ID, new Zone());
nodesPerZone.put(new Zone(), new ArrayList<Integer>());
partitionsPerZone.put(new Zone(), new ArrayList<Integer>());
Zone defaultZone = new Zone();
zonesById.put(defaultZone.getId(), defaultZone);
nodesPerZone.put(defaultZone, new ArrayList<Integer>());
partitionsPerZone.put(defaultZone, new ArrayList<Integer>());
}

this.nodesById = new LinkedHashMap<Integer, Node>(nodes.size());
Expand Down
16 changes: 9 additions & 7 deletions test/unit/voldemort/client/AdminServiceBasicTest.java
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2012 LinkedIn, Inc
* Copyright 2008-2013 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -288,6 +288,8 @@ public void testAddStore() throws Exception {

@Test
public void testReplicationMapping() {
List<Zone> zones = ServerTestUtils.getZones(2);

List<Node> nodes = Lists.newArrayList();
nodes.add(new Node(0, "localhost", 1, 2, 3, 0, Lists.newArrayList(0, 4, 8)));
nodes.add(new Node(1, "localhost", 1, 2, 3, 0, Lists.newArrayList(1, 5, 9)));
Expand All @@ -302,7 +304,7 @@ public void testReplicationMapping() {
1,
1,
RoutingStrategyType.CONSISTENT_STRATEGY);
Cluster newCluster = new Cluster("single_zone_cluster", nodes);
Cluster newCluster = new Cluster("single_zone_cluster", nodes, zones);

try {
adminClient.helperOps.getReplicationMapping(0, newCluster, storeDef);
Expand Down Expand Up @@ -383,7 +385,6 @@ public void testReplicationMapping() {
}

// Test 2 - With zone routing strategy
List<Zone> zones = ServerTestUtils.getZones(2);
HashMap<Integer, Integer> zoneReplicationFactors = Maps.newHashMap();
for(int zoneIds = 0; zoneIds < 2; zoneIds++) {
zoneReplicationFactors.put(zoneIds, 1);
Expand Down Expand Up @@ -467,7 +468,7 @@ public void testReplicationMapping() {
1,
1,
RoutingStrategyType.CONSISTENT_STRATEGY);
newCluster = new Cluster("single_zone_cluster", nodes);
newCluster = new Cluster("single_zone_cluster", nodes, zones);

{
replicationMapping = adminClient.helperOps.getReplicationMapping(0,
Expand Down Expand Up @@ -646,6 +647,8 @@ public void testReplicationMapping() {

@Test
public void testReplicationMappingWithZonePreference() {
List<Zone> zones = ServerTestUtils.getZones(2);

List<Node> nodes = Lists.newArrayList();
nodes.add(new Node(0, "localhost", 1, 2, 3, 0, Lists.newArrayList(0, 4, 8)));
nodes.add(new Node(1, "localhost", 1, 2, 3, 0, Lists.newArrayList(1, 5, 9)));
Expand All @@ -660,7 +663,7 @@ public void testReplicationMappingWithZonePreference() {
1,
1,
RoutingStrategyType.CONSISTENT_STRATEGY);
Cluster newCluster = new Cluster("single_zone_cluster", nodes);
Cluster newCluster = new Cluster("single_zone_cluster", nodes, zones);

try {
adminClient.helperOps.getReplicationMapping(0, newCluster, storeDef, 1);
Expand All @@ -675,7 +678,7 @@ public void testReplicationMappingWithZonePreference() {
1,
1,
RoutingStrategyType.CONSISTENT_STRATEGY);
newCluster = new Cluster("single_zone_cluster", nodes);
newCluster = new Cluster("single_zone_cluster", nodes, zones);

try {
adminClient.helperOps.getReplicationMapping(0, newCluster, storeDef, 0);
Expand Down Expand Up @@ -726,7 +729,6 @@ public void testReplicationMappingWithZonePreference() {
}

// Test 2 - With zone routing strategy, and zone replication factor 1
List<Zone> zones = ServerTestUtils.getZones(2);
HashMap<Integer, Integer> zoneReplicationFactors = Maps.newHashMap();
for(int zoneIds = 0; zoneIds < 2; zoneIds++) {
zoneReplicationFactors.put(zoneIds, 1);
Expand Down

0 comments on commit 10d57ac

Please sign in to comment.