diff options
| author | Chris Lu <chris.lu@gmail.com> | 2014-03-02 22:16:54 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2014-03-02 22:16:54 -0800 |
| commit | 27c74a7e66558a4f9ce0d10621606dfed98a3abb (patch) | |
| tree | f16eef19480fd51ccbef54c05d39c2eacf309e56 /go/replication/volume_growth_test.go | |
| parent | edae676913363bdd1e5a50bf0778fdcc3c6d6051 (diff) | |
| download | seaweedfs-27c74a7e66558a4f9ce0d10621606dfed98a3abb.tar.xz seaweedfs-27c74a7e66558a4f9ce0d10621606dfed98a3abb.zip | |
Major:
change replication_type to ReplicaPlacement, hopefully cleaner code
works for 9 possible ReplicaPlacement
xyz
x : number of copies on other data centers
y : number of copies on other racks
z : number of copies on current rack
x y z each can be 0,1,2
Minor:
weed server "-mdir" default to "-dir" if empty
Diffstat (limited to 'go/replication/volume_growth_test.go')
| -rw-r--r-- | go/replication/volume_growth_test.go | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/go/replication/volume_growth_test.go b/go/replication/volume_growth_test.go index 99f82a7fa..bb6cbe90e 100644 --- a/go/replication/volume_growth_test.go +++ b/go/replication/volume_growth_test.go @@ -13,7 +13,7 @@ var topologyLayout = ` { "dc1":{ "rack1":{ - "server1":{ + "server111":{ "volumes":[ {"id":1, "size":12312}, {"id":2, "size":12312}, @@ -21,7 +21,7 @@ var topologyLayout = ` ], "limit":3 }, - "server2":{ + "server112":{ "volumes":[ {"id":4, "size":12312}, {"id":5, "size":12312}, @@ -31,7 +31,7 @@ var topologyLayout = ` } }, "rack2":{ - "server1":{ + "server121":{ "volumes":[ {"id":4, "size":12312}, {"id":5, "size":12312}, @@ -39,17 +39,17 @@ var topologyLayout = ` ], "limit":4 }, - "server2":{ + "server122":{ "volumes":[], "limit":4 }, - "server3":{ + "server123":{ "volumes":[ {"id":2, "size":12312}, {"id":3, "size":12312}, {"id":4, "size":12312} ], - "limit":2 + "limit":5 } } }, @@ -57,7 +57,7 @@ var topologyLayout = ` }, "dc3":{ "rack2":{ - "server1":{ + "server321":{ "volumes":[ {"id":1, "size":12312}, {"id":3, "size":12312}, @@ -113,14 +113,16 @@ func setup(topologyLayout string) *topology.Topology { return topo } -func TestRemoveDataCenter(t *testing.T) { +func TestFindEmptySlotsForOneVolume(t *testing.T) { topo := setup(topologyLayout) - topo.UnlinkChildNode(topology.NodeId("dc2")) - if topo.GetActiveVolumeCount() != 15 { + vg := NewDefaultVolumeGrowth() + rp, _ := storage.NewReplicaPlacementFromString("002") + servers, err := vg.findEmptySlotsForOneVolume(topo, "dc1", rp) + if err != nil { + fmt.Println("finding empty slots error :", err) t.Fail() } - topo.UnlinkChildNode(topology.NodeId("dc3")) - if topo.GetActiveVolumeCount() != 12 { - t.Fail() + for _, server := range servers { + fmt.Println("assigned node :", server.Id()) } } |
