You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.7 KiB

  1. package shell
  2. import (
  3. "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
  4. "os"
  5. "testing"
  6. )
  7. type testCommandVolumeCheckDisk struct {
  8. commandVolumeCheckDisk
  9. }
  10. type shouldSkipVolume struct {
  11. a VolumeReplica
  12. b VolumeReplica
  13. pulseTimeAtSecond int64
  14. shouldSkipVolume bool
  15. }
  16. func TestShouldSkipVolume(t *testing.T) {
  17. cmdVolumeCheckDisk := testCommandVolumeCheckDisk{}
  18. cmdVolumeCheckDisk.writer = os.Stdout
  19. var tests = []shouldSkipVolume{
  20. {
  21. VolumeReplica{nil, &master_pb.VolumeInformationMessage{
  22. FileCount: 1000,
  23. DeleteCount: 100,
  24. ModifiedAtSecond: 1696583300},
  25. },
  26. VolumeReplica{nil, &master_pb.VolumeInformationMessage{
  27. FileCount: 1000,
  28. DeleteCount: 100,
  29. ModifiedAtSecond: 1696583300},
  30. },
  31. 1696583400,
  32. true,
  33. },
  34. {
  35. VolumeReplica{nil, &master_pb.VolumeInformationMessage{
  36. FileCount: 1001,
  37. DeleteCount: 100,
  38. ModifiedAtSecond: 1696583300},
  39. },
  40. VolumeReplica{nil, &master_pb.VolumeInformationMessage{
  41. FileCount: 1000,
  42. DeleteCount: 100,
  43. ModifiedAtSecond: 1696583300},
  44. },
  45. 1696583400,
  46. false,
  47. },
  48. {
  49. VolumeReplica{nil, &master_pb.VolumeInformationMessage{
  50. FileCount: 1000,
  51. DeleteCount: 100,
  52. ModifiedAtSecond: 1696583300},
  53. },
  54. VolumeReplica{nil, &master_pb.VolumeInformationMessage{
  55. FileCount: 1000,
  56. DeleteCount: 101,
  57. ModifiedAtSecond: 1696583300},
  58. },
  59. 1696583400,
  60. false,
  61. },
  62. }
  63. for num, tt := range tests {
  64. if isShould := cmdVolumeCheckDisk.shouldSkipVolume(&tt.a, &tt.b, tt.pulseTimeAtSecond, true, true); isShould != tt.shouldSkipVolume {
  65. t.Fatalf("result of should skip volume is unexpected for %d test", num)
  66. }
  67. }
  68. }