aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-09-11 01:21:17 -0700
committerChris Lu <chris.lu@gmail.com>2020-09-11 01:21:17 -0700
commit12a8f5294d2479fada6988b2639c1f75f02c1ab2 (patch)
tree162c98ccdcd4ad3b2badefb20d9e6769a101d94a
parente60b2117c3bf36f9a5ff4a1cf1b9216124546f8b (diff)
downloadseaweedfs-12a8f5294d2479fada6988b2639c1f75f02c1ab2.tar.xz
seaweedfs-12a8f5294d2479fada6988b2639c1f75f02c1ab2.zip
test for multi dc replication
-rw-r--r--weed/shell/command_volume_balance.go2
-rw-r--r--weed/shell/command_volume_balance_test.go18
2 files changed, 19 insertions, 1 deletions
diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.go
index 4f96c3e08..3e36c7fd5 100644
--- a/weed/shell/command_volume_balance.go
+++ b/weed/shell/command_volume_balance.go
@@ -299,7 +299,7 @@ func isGoodMove(placement *super_block.ReplicaPlacement, existingReplicas []*Vol
return false
}
- if len(racks) > placement.DiffRackCount+1 {
+ if len(racks) > placement.DiffRackCount+placement.DiffDataCenterCount+1 {
return false
}
diff --git a/weed/shell/command_volume_balance_test.go b/weed/shell/command_volume_balance_test.go
index 7919d60c0..4f46648c0 100644
--- a/weed/shell/command_volume_balance_test.go
+++ b/weed/shell/command_volume_balance_test.go
@@ -19,6 +19,24 @@ type testMoveCase struct {
func TestIsGoodMove(t *testing.T) {
var tests = []testMoveCase{
+
+
+ {
+ name: "test 100 move to spread into proper data centers",
+ replication: "100",
+ replicas: []*VolumeReplica{
+ {
+ location: &location{"dc1", "r1", &master_pb.DataNodeInfo{Id: "dn1"}},
+ },
+ {
+ location: &location{"dc1", "r2", &master_pb.DataNodeInfo{Id: "dn2"}},
+ },
+ },
+ sourceLocation: location{"dc1", "r2", &master_pb.DataNodeInfo{Id: "dn2"}},
+ targetLocation: location{"dc2", "r2", &master_pb.DataNodeInfo{Id: "dn3"}},
+ expected: true,
+ },
+
{
name: "test move to the same node",
replication: "001",