aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-02-08 01:50:05 -0800
committerchrislu <chris.lu@gmail.com>2022-02-08 01:50:05 -0800
commit13f6ec1c4e7737c1e6aaa486a80247b7cabf0448 (patch)
treec7535430ace4492a3264cd80727314b529621ceb
parentf34c2ff7c5282d371d09288c83f9ff074d04bb1d (diff)
downloadseaweedfs-13f6ec1c4e7737c1e6aaa486a80247b7cabf0448.tar.xz
seaweedfs-13f6ec1c4e7737c1e6aaa486a80247b7cabf0448.zip
test checking ec distribution
-rw-r--r--weed/shell/command_ec_encode_test.go30
-rw-r--r--weed/shell/command_volume_list_test.go3
2 files changed, 33 insertions, 0 deletions
diff --git a/weed/shell/command_ec_encode_test.go b/weed/shell/command_ec_encode_test.go
new file mode 100644
index 000000000..d5e341e5b
--- /dev/null
+++ b/weed/shell/command_ec_encode_test.go
@@ -0,0 +1,30 @@
+package shell
+
+import (
+ "fmt"
+ "github.com/chrislusf/seaweedfs/weed/storage/erasure_coding"
+ "testing"
+)
+
+func TestEcDistribution(t *testing.T) {
+
+ topologyInfo := parseOutput(topoData)
+
+ // find out all volume servers with one slot left.
+ ecNodes, totalFreeEcSlots := collectEcVolumeServersByDc(topologyInfo, "")
+
+ sortEcNodesByFreeslotsDecending(ecNodes)
+
+ if totalFreeEcSlots < erasure_coding.TotalShardsCount {
+ println("not enough free ec shard slots", totalFreeEcSlots)
+ }
+ allocatedDataNodes := ecNodes
+ if len(allocatedDataNodes) > erasure_coding.TotalShardsCount {
+ allocatedDataNodes = allocatedDataNodes[:erasure_coding.TotalShardsCount]
+ }
+
+ for _, dn := range allocatedDataNodes {
+ fmt.Printf("info %+v %+v\n", dn.info, dn)
+ }
+
+}
diff --git a/weed/shell/command_volume_list_test.go b/weed/shell/command_volume_list_test.go
index 109eb5cd6..0bcbb1713 100644
--- a/weed/shell/command_volume_list_test.go
+++ b/weed/shell/command_volume_list_test.go
@@ -65,11 +65,14 @@ func parseOutput(output string) *master_pb.TopologyInfo {
case "Disk":
if disk == nil {
diskType := parts[1][:strings.Index(parts[1], "(")]
+ volumeCountStr := parts[1][strings.Index(parts[1], ":")+1 : strings.Index(parts[1], "/")]
maxVolumeCountStr := parts[1][strings.Index(parts[1], "/")+1:]
maxVolumeCount, _ := strconv.Atoi(maxVolumeCountStr)
+ volumeCount, _ := strconv.Atoi(volumeCountStr)
disk = &master_pb.DiskInfo{
Type: diskType,
MaxVolumeCount: int64(maxVolumeCount),
+ VolumeCount: int64(volumeCount),
}
dn.DiskInfos[types.ToDiskType(diskType).String()] = disk
} else {