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.

fix tests

Chris Lu68775d29e3a2
diff --git a/weed/shell/command_ec_test.go b/weed/shell/command_ec_test.go
index 4fddcbea5a..14235d5655 100644
--- a/weed/shell/command_ec_test.go
+++ b/weed/shell/command_ec_test.go
@@ -127,6 +127,7 @@ func newEcNode(dc string, rack string, dataNodeId string, freeEcSlot int) *EcNod
return &EcNode{
info: &master_pb.DataNodeInfo{
Id: dataNodeId,
+ DiskInfos: make(map[string]*master_pb.DiskInfo),
},
dc: dc,
rack: RackId(rack),
diff --git a/weed/topology/topology_test.go b/weed/topology/topology_test.go
index 1d93792102..ecfe9d8d19 100644
--- a/weed/topology/topology_test.go
+++ b/weed/topology/topology_test.go
@@ -14,11 +14,11 @@ import (
func TestRemoveDataCenter(t *testing.T) {
topo := setup(topologyLayout)
topo.UnlinkChildNode(NodeId("dc2"))
- if topo.GetActiveVolumeCount() != 15 {
+ if topo.diskUsages.usages[types.HardDriveType].activeVolumeCount != 15 {
t.Fail()
}
topo.UnlinkChildNode(NodeId("dc3"))
- if topo.GetActiveVolumeCount() != 12 {
+ if topo.diskUsages.usages[types.HardDriveType].activeVolumeCount != 12 {
t.Fail()
}
}
@@ -28,7 +28,10 @@ func TestHandlingVolumeServerHeartbeat(t *testing.T) {
dc := topo.GetOrCreateDataCenter("dc1")
rack := dc.GetOrCreateRack("rack1")
- dn := rack.GetOrCreateDataNode("127.0.0.1", 34534, "127.0.0.1", 25, 12)
+ maxVolumeCounts := make(map[string]uint32)
+ maxVolumeCounts[""] = 25
+ maxVolumeCounts["ssd"] = 12
+ dn := rack.GetOrCreateDataNode("127.0.0.1", 34534, "127.0.0.1", maxVolumeCounts)
{
volumeCount := 7
@@ -68,9 +71,11 @@ func TestHandlingVolumeServerHeartbeat(t *testing.T) {
topo.SyncDataNodeRegistration(volumeMessages, dn)
- assert(t, "activeVolumeCount1", int(topo.activeVolumeCount), volumeCount*2)
- assert(t, "volumeCount", int(topo.volumeCount), volumeCount)
- assert(t, "ssdVolumeCount", int(topo.ssdVolumeCount), volumeCount)
+ usageCounts := topo.diskUsages.usages[types.HardDriveType]
+
+ assert(t, "activeVolumeCount1", int(usageCounts.activeVolumeCount), volumeCount)
+ assert(t, "volumeCount", int(usageCounts.volumeCount), volumeCount)
+ assert(t, "ssdVolumeCount", int(topo.diskUsages.usages[types.SsdType].volumeCount), volumeCount)
}
{
@@ -97,8 +102,10 @@ func TestHandlingVolumeServerHeartbeat(t *testing.T) {
//layout := topo.GetVolumeLayout("", rp, needle.EMPTY_TTL)
//assert(t, "writables", len(layout.writables), volumeCount)
- assert(t, "activeVolumeCount1", int(topo.activeVolumeCount), volumeCount)
- assert(t, "volumeCount", int(topo.volumeCount), volumeCount)
+ usageCounts := topo.diskUsages.usages[types.HardDriveType]
+
+ assert(t, "activeVolumeCount1", int(usageCounts.activeVolumeCount), volumeCount)
+ assert(t, "volumeCount", int(usageCounts.volumeCount), volumeCount)
}
{
@@ -118,16 +125,18 @@ func TestHandlingVolumeServerHeartbeat(t *testing.T) {
layout := topo.GetVolumeLayout("", rp, needle.EMPTY_TTL, types.HardDriveType)
assert(t, "writables after repeated add", len(layout.writables), volumeCount)
- assert(t, "activeVolumeCount1", int(topo.activeVolumeCount), volumeCount)
- assert(t, "volumeCount", int(topo.volumeCount), volumeCount)
+ usageCounts := topo.diskUsages.usages[types.HardDriveType]
+
+ assert(t, "activeVolumeCount1", int(usageCounts.activeVolumeCount), volumeCount)
+ assert(t, "volumeCount", int(usageCounts.volumeCount), volumeCount)
topo.IncrementalSyncDataNodeRegistration(
nil,
[]*master_pb.VolumeShortInformationMessage{newVolumeShortMessage},
dn)
assert(t, "writables after deletion", len(layout.writables), volumeCount-1)
- assert(t, "activeVolumeCount1", int(topo.activeVolumeCount), volumeCount-1)
- assert(t, "volumeCount", int(topo.volumeCount), volumeCount-1)
+ assert(t, "activeVolumeCount1", int(usageCounts.activeVolumeCount), volumeCount-1)
+ assert(t, "volumeCount", int(usageCounts.volumeCount), volumeCount-1)
topo.IncrementalSyncDataNodeRegistration(
[]*master_pb.VolumeShortInformationMessage{newVolumeShortMessage},
@@ -147,7 +156,9 @@ func TestHandlingVolumeServerHeartbeat(t *testing.T) {
topo.UnRegisterDataNode(dn)
- assert(t, "activeVolumeCount2", int(topo.activeVolumeCount), 0)
+ usageCounts := topo.diskUsages.usages[types.HardDriveType]
+
+ assert(t, "activeVolumeCount2", int(usageCounts.activeVolumeCount), 0)
}
@@ -163,7 +174,10 @@ func TestAddRemoveVolume(t *testing.T) {
dc := topo.GetOrCreateDataCenter("dc1")
rack := dc.GetOrCreateRack("rack1")
- dn := rack.GetOrCreateDataNode("127.0.0.1", 34534, "127.0.0.1", 25, 12)
+ maxVolumeCounts := make(map[string]uint32)
+ maxVolumeCounts[""] = 25
+ maxVolumeCounts["ssd"] = 12
+ dn := rack.GetOrCreateDataNode("127.0.0.1", 34534, "127.0.0.1", maxVolumeCounts)
v := storage.VolumeInfo{
Id: needle.VolumeId(1),
diff --git a/weed/topology/volume_growth_test.go b/weed/topology/volume_growth_test.go
index bc9083fd21..ab30cd43f2 100644
--- a/weed/topology/volume_growth_test.go
+++ b/weed/topology/volume_growth_test.go
@@ -103,7 +103,13 @@ func setup(topologyLayout string) *Topology {
Version: needle.CurrentVersion}
server.AddOrUpdateVolume(vi)
}
- server.UpAdjustMaxVolumeCountDelta(int64(serverMap["limit"].(float64)))
+
+ disk := server.getOrCreateDisk("")
+ deltaDiskUsages := newDiskUsages()
+ deltaDiskUsage := deltaDiskUsages.getOrCreateDisk("")
+ deltaDiskUsage.maxVolumeCount = int64(serverMap["limit"].(float64))
+ disk.UpAdjustDiskUsageDelta(deltaDiskUsages)
+
}
}
}