Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: wait for complete rollouts in WaitForDeploymentStatusValid #34942

Merged
merged 1 commit into from
Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions test/e2e/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,10 +1134,12 @@ func testScaledRolloutDeployment(f *framework.Framework) {
Expect(err).NotTo(HaveOccurred())

firstCond := client.ReplicaSetHasDesiredReplicas(c.Extensions(), first)
wait.PollImmediate(10*time.Millisecond, 1*time.Minute, firstCond)
err = wait.PollImmediate(10*time.Millisecond, 1*time.Minute, firstCond)
Expect(err).NotTo(HaveOccurred())

secondCond := client.ReplicaSetHasDesiredReplicas(c.Extensions(), second)
wait.PollImmediate(10*time.Millisecond, 1*time.Minute, secondCond)
err = wait.PollImmediate(10*time.Millisecond, 1*time.Minute, secondCond)
Expect(err).NotTo(HaveOccurred())

By(fmt.Sprintf("Updating the size (up) and template at the same time for deployment %q", deploymentName))
newReplicas := int32(20)
Expand Down Expand Up @@ -1193,10 +1195,12 @@ func testScaledRolloutDeployment(f *framework.Framework) {
Expect(err).NotTo(HaveOccurred())

oldCond := client.ReplicaSetHasDesiredReplicas(c.Extensions(), oldRs)
wait.PollImmediate(10*time.Millisecond, 1*time.Minute, oldCond)
err = wait.PollImmediate(10*time.Millisecond, 1*time.Minute, oldCond)
Expect(err).NotTo(HaveOccurred())

newCond := client.ReplicaSetHasDesiredReplicas(c.Extensions(), newRs)
wait.PollImmediate(10*time.Millisecond, 1*time.Minute, newCond)
err = wait.PollImmediate(10*time.Millisecond, 1*time.Minute, newCond)
Expect(err).NotTo(HaveOccurred())

By(fmt.Sprintf("Updating the size (down) and template at the same time for deployment %q", deploymentName))
newReplicas = int32(5)
Expand Down
17 changes: 13 additions & 4 deletions test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2896,7 +2896,18 @@ func WaitForDeploymentStatusValid(c clientset.Interface, d *extensions.Deploymen
Logf(reason)
return false, nil
}
return true, nil

// When the deployment status and its underlying resources reach the desired state, we're done
if deployment.Status.Replicas == deployment.Spec.Replicas &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought we have helper method for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's somewhere in the perma-failed PR i think:) I will refactor this once I get the API merged (so the impl will get its turn)

deployment.Status.UpdatedReplicas == deployment.Spec.Replicas &&
deployment.Status.AvailableReplicas == deployment.Spec.Replicas {
return true, nil
}

reason = fmt.Sprintf("deployment status: %#v", deployment.Status)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need this var, just Logf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need it in case we timeout. Will be printed instead of "timed out waiting for the condition".

Logf(reason)

return false, nil
})

if err == wait.ErrWaitTimeout {
Expand Down Expand Up @@ -2960,9 +2971,7 @@ func WaitForDeploymentStatus(c clientset.Interface, d *extensions.Deployment) er

// When the deployment status and its underlying resources reach the desired state, we're done
if deployment.Status.Replicas == deployment.Spec.Replicas &&
deployment.Status.UpdatedReplicas == deployment.Spec.Replicas &&
deploymentutil.GetReplicaCountForReplicaSets(oldRSs) == 0 &&
deploymentutil.GetReplicaCountForReplicaSets([]*extensions.ReplicaSet{newRS}) == deployment.Spec.Replicas {
deployment.Status.UpdatedReplicas == deployment.Spec.Replicas {
return true, nil
}
return false, nil
Expand Down