Skip to content

Commit

Permalink
test(repair): add tests with deprecated float intensity
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal-Leszczynski committed Jan 15, 2024
1 parent cfd12fc commit 9067fba
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions pkg/service/repair/service_repair_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func (h *repairTestHelper) assertParallelIntensity(parallel, intensity int) {
if err != nil {
h.T.Fatal(err)
}

if p.Parallel != parallel || int(p.Intensity) != intensity {
h.T.Fatalf("Expected parallel %d, intensity %d, got parallel %d, intensity %d", parallel, intensity, p.Parallel, int(p.Intensity))
}
Expand Down Expand Up @@ -1416,10 +1417,18 @@ func TestServiceRepairIntegration(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

const (
propParallel = 0
propIntensity = 0
controlParallel = 1
controlIntensity = 1
deprecatedControlIntensity = 0.5
)

Print("When: run repair")
props := singleUnit(map[string]any{
"parallel": 1,
"intensity": 1,
"parallel": propParallel,
"intensity": propIntensity,
"small_table_threshold": -1,
})
h.runRepair(ctx, props)
Expand All @@ -1428,18 +1437,18 @@ func TestServiceRepairIntegration(t *testing.T) {
h.assertRunning(shortWait)

Print("Then: assert parallel/intensity from properties")
h.assertParallelIntensity(1, 1)
h.assertParallelIntensity(propParallel, propIntensity)

Print("And: control parallel and intensity")
if err := h.service.SetParallel(ctx, h.ClusterID, 0); err != nil {
if err := h.service.SetParallel(ctx, h.ClusterID, controlParallel); err != nil {
t.Fatal(err)
}
if err := h.service.SetIntensity(ctx, h.ClusterID, 0); err != nil {
if err := h.service.SetIntensity(ctx, h.ClusterID, deprecatedControlIntensity); err != nil {
t.Fatal(err)
}

Print("Then: assert parallel/intensity from control")
h.assertParallelIntensity(0, 0)
h.assertParallelIntensity(controlParallel, controlIntensity)

Print("And: repair is stopped")
cancel()
Expand All @@ -1458,13 +1467,13 @@ func TestServiceRepairIntegration(t *testing.T) {
h.assertRunning(shortWait)

Print("Then: assert resumed, running parallel/intensity from control")
h.assertParallelIntensity(0, 0)
h.assertParallelIntensity(controlParallel, controlIntensity)

Print("Then: repair is done")
h.assertDone(3 * longWait)

Print("Then: assert resumed, finished parallel/intensity from control")
h.assertParallelIntensity(0, 0)
h.assertParallelIntensity(controlParallel, controlIntensity)

Print("And: run fresh repair")
h.RunID = uuid.NewTime()
Expand All @@ -1474,13 +1483,13 @@ func TestServiceRepairIntegration(t *testing.T) {
h.assertRunning(shortWait)

Print("Then: assert fresh, running parallel/intensity from properties")
h.assertParallelIntensity(1, 1)
h.assertParallelIntensity(propParallel, propIntensity)

Print("Then: repair is done")
h.assertDone(3 * longWait)

Print("Then: assert fresh, finished repair parallel/intensity from control")
h.assertParallelIntensity(1, 1)
h.assertParallelIntensity(propParallel, propIntensity)
})

t.Run("repair restart no continue", func(t *testing.T) {
Expand Down Expand Up @@ -1907,6 +1916,31 @@ func TestServiceRepairIntegration(t *testing.T) {
}
})

t.Run("deprecated float intensity", func(t *testing.T) {
h := newRepairTestHelper(t, session, defaultConfig())
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Print("When: run repair")
h.runRepair(ctx, multipleUnits(map[string]any{
"intensity": 0.5,
}))

Print("Then: repair is running")
h.assertRunning(shortWait)

p, err := h.service.GetProgress(ctx, h.ClusterID, h.TaskID, h.RunID)
if err != nil {
t.Fatal(err)
}
if p.Intensity != 1 {
t.Fatalf("Expected default intensity (1) when using float value, got: %v", p.Intensity)
}

Print("And: repair is done")
h.assertDone(longWait)
})

t.Run("repair status context timeout", func(t *testing.T) {
h := newRepairTestHelper(t, session, defaultConfig())
ctx, cancel := context.WithCancel(context.Background())
Expand Down

0 comments on commit 9067fba

Please sign in to comment.