pkg/controller/deployment: syncRolloutStatus additional unit test case

Added additional test case that exercises fix #53614 or npe when scaling --replicas=0
Moved creation of clientset and deployment controller objects inside test loop since it's mutated every time an API action happens.

Signed-off-by: John Kelly <jekohk@gmail.com>
This commit is contained in:
John Kelly 2017-11-01 14:42:49 -04:00
parent 9bf61e72b8
commit cb98157834

View File

@ -279,6 +279,14 @@ func TestSyncRolloutStatus(t *testing.T) {
conditionStatus: v1.ConditionTrue, conditionStatus: v1.ConditionTrue,
conditionReason: util.NewRSAvailableReason, conditionReason: util.NewRSAvailableReason,
}, },
{
name: "DeploymentComplete: defend against NPE when newRS=nil",
d: currentDeployment(&pds, 0, 3, 3, 3, []extensions.DeploymentCondition{replicaSetUpdated}),
allRSs: []*extensions.ReplicaSet{newRSWithAvailable("foo", 0, 0, 0)},
conditionType: extensions.DeploymentProgressing,
conditionStatus: v1.ConditionTrue,
conditionReason: util.NewRSAvailableReason,
},
{ {
name: "DeploymentTimedOut: update status if rollout exceeds Progress Deadline", name: "DeploymentTimedOut: update status if rollout exceeds Progress Deadline",
d: currentDeployment(&pds, 3, 2, 2, 2, []extensions.DeploymentCondition{replicaSetUpdated}), d: currentDeployment(&pds, 3, 2, 2, 2, []extensions.DeploymentCondition{replicaSetUpdated}),
@ -301,12 +309,12 @@ func TestSyncRolloutStatus(t *testing.T) {
}, },
} }
fake := fake.Clientset{}
dc := &DeploymentController{
client: &fake,
}
for _, test := range tests { for _, test := range tests {
fake := fake.Clientset{}
dc := &DeploymentController{
client: &fake,
}
if test.newRS != nil { if test.newRS != nil {
test.allRSs = append(test.allRSs, test.newRS) test.allRSs = append(test.allRSs, test.newRS)
} }