Commit cb981578 authored by John Kelly's avatar John Kelly

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: 's avatarJohn Kelly <jekohk@gmail.com>
parent 9bf61e72
...@@ -280,6 +280,14 @@ func TestSyncRolloutStatus(t *testing.T) { ...@@ -280,6 +280,14 @@ func TestSyncRolloutStatus(t *testing.T) {
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}),
allRSs: []*extensions.ReplicaSet{}, allRSs: []*extensions.ReplicaSet{},
...@@ -301,12 +309,12 @@ func TestSyncRolloutStatus(t *testing.T) { ...@@ -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)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment