diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2023-10-09 21:57:26 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-09 09:57:26 -0700 |
| commit | 2b3e39397e03c86ddbabe8d4ba7509e6638bf8bf (patch) | |
| tree | b8dfdb25eb37caca540316151186a6eff7e94b84 /weed/shell/command_volume_check_disk_test.go | |
| parent | 3fe00996b244886e4a89f3aa4250a391919db106 (diff) | |
| download | seaweedfs-2b3e39397e03c86ddbabe8d4ba7509e6638bf8bf.tar.xz seaweedfs-2b3e39397e03c86ddbabe8d4ba7509e6638bf8bf.zip | |
fix: skipping checking active volumes with the same number of files at the moment (#4893)
* fix: skipping checking active volumes with the same number of files at the moment
https://github.com/seaweedfs/seaweedfs/issues/4140
* refactor with comments
https://github.com/seaweedfs/seaweedfs/issues/4140
* add TestShouldSkipVolume
---------
Co-authored-by: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.co>
Diffstat (limited to 'weed/shell/command_volume_check_disk_test.go')
| -rw-r--r-- | weed/shell/command_volume_check_disk_test.go | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/weed/shell/command_volume_check_disk_test.go b/weed/shell/command_volume_check_disk_test.go new file mode 100644 index 000000000..ab9832bd4 --- /dev/null +++ b/weed/shell/command_volume_check_disk_test.go @@ -0,0 +1,72 @@ +package shell + +import ( + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" + "os" + "testing" +) + +type testCommandVolumeCheckDisk struct { + commandVolumeCheckDisk +} + +type shouldSkipVolume struct { + a VolumeReplica + b VolumeReplica + pulseTimeAtSecond int64 + shouldSkipVolume bool +} + +func TestShouldSkipVolume(t *testing.T) { + cmdVolumeCheckDisk := testCommandVolumeCheckDisk{} + cmdVolumeCheckDisk.writer = os.Stdout + var tests = []shouldSkipVolume{ + { + VolumeReplica{nil, &master_pb.VolumeInformationMessage{ + FileCount: 1000, + DeleteCount: 100, + ModifiedAtSecond: 1696583300}, + }, + VolumeReplica{nil, &master_pb.VolumeInformationMessage{ + FileCount: 1000, + DeleteCount: 100, + ModifiedAtSecond: 1696583300}, + }, + 1696583400, + true, + }, + { + VolumeReplica{nil, &master_pb.VolumeInformationMessage{ + FileCount: 1001, + DeleteCount: 100, + ModifiedAtSecond: 1696583300}, + }, + VolumeReplica{nil, &master_pb.VolumeInformationMessage{ + FileCount: 1000, + DeleteCount: 100, + ModifiedAtSecond: 1696583300}, + }, + 1696583400, + false, + }, + { + VolumeReplica{nil, &master_pb.VolumeInformationMessage{ + FileCount: 1000, + DeleteCount: 100, + ModifiedAtSecond: 1696583300}, + }, + VolumeReplica{nil, &master_pb.VolumeInformationMessage{ + FileCount: 1000, + DeleteCount: 101, + ModifiedAtSecond: 1696583300}, + }, + 1696583400, + false, + }, + } + for num, tt := range tests { + if isShould := cmdVolumeCheckDisk.shouldSkipVolume(&tt.a, &tt.b, tt.pulseTimeAtSecond, true, true); isShould != tt.shouldSkipVolume { + t.Fatalf("result of should skip volume is unexpected for %d test", num) + } + } +} |
