Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

test for multi dc replication

Chris Lu12a8f5294d24
diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.go
index 4f96c3e08d..3e36c7fd5b 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 7919d60c07..4f46648c00 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",