Skip to content

Commit

Permalink
Fixed unittests.
Browse files Browse the repository at this point in the history
  • Loading branch information
maierlars committed Oct 26, 2018
1 parent d862e71 commit 1a6101c
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pkg/deployment/reconcile/plan_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,9 @@ func TestCreatePlanActiveFailoverScale(t *testing.T) {
}
newPlan, changed = createPlan(log, depl, nil, spec, status, nil, c)
assert.True(t, changed)
require.Len(t, newPlan, 2) // Note: Downscaling is only down 1 at a time
assert.Equal(t, api.ActionTypeShutdownMember, newPlan[0].Type)
assert.Equal(t, api.ActionTypeRemoveMember, newPlan[1].Type)
require.Len(t, newPlan, 1) // Note: Downscaling is only down 1 at a time
assert.Equal(t, api.ActionTypeRemoveMember, newPlan[0].Type)
assert.Equal(t, api.ServerGroupSingle, newPlan[0].Group)
assert.Equal(t, api.ServerGroupSingle, newPlan[1].Group)
}

// TestCreatePlanClusterScale creates a `cluster` deployment to test the creating of scaling plan.
Expand Down Expand Up @@ -263,6 +261,12 @@ func TestCreatePlanClusterScale(t *testing.T) {
api.MemberStatus{
ID: "cr1",
PodName: "coordinator1",
Conditions: api.ConditionList{
api.Condition{
Type: api.ConditionTypeReady,
Status: v1.ConditionTrue,
},
},
},
api.MemberStatus{
ID: "cr2",
Expand All @@ -273,15 +277,14 @@ func TestCreatePlanClusterScale(t *testing.T) {
spec.Coordinators.Count = util.NewInt(1)
newPlan, changed = createPlan(log, depl, nil, spec, status, nil, c)
assert.True(t, changed)
require.Len(t, newPlan, 5) // Note: Downscaling is done 1 at a time
assert.Equal(t, api.ActionTypeCleanOutMember, newPlan[0].Type)

fmt.Printf("%v", newPlan)

require.Len(t, newPlan, 3) // Note: Downscaling is done 1 at a time
assert.Equal(t, api.ActionTypeRemoveMember, newPlan[0].Type)
assert.Equal(t, api.ActionTypeShutdownMember, newPlan[1].Type)
assert.Equal(t, api.ActionTypeRemoveMember, newPlan[2].Type)
assert.Equal(t, api.ActionTypeShutdownMember, newPlan[3].Type)
assert.Equal(t, api.ActionTypeRemoveMember, newPlan[4].Type)
assert.Equal(t, api.ServerGroupDBServers, newPlan[0].Group)
assert.Equal(t, api.ServerGroupDBServers, newPlan[1].Group)
assert.Equal(t, api.ServerGroupDBServers, newPlan[2].Group)
assert.Equal(t, api.ServerGroupCoordinators, newPlan[3].Group)
assert.Equal(t, api.ServerGroupCoordinators, newPlan[4].Group)
assert.Equal(t, api.ServerGroupCoordinators, newPlan[1].Group)
assert.Equal(t, api.ServerGroupCoordinators, newPlan[2].Group)
}

0 comments on commit 1a6101c

Please sign in to comment.