Skip to content

Commit

Permalink
Fix 1.3 paused deployment test failure against >1.4 cluster
Browse files Browse the repository at this point in the history
Proportionally scale deployments was introduced in v1.4 (kubernetes#20273),
which caused this 1.3 test to fail on 1.4 clusters.
This is cherrypicked into 1.3 merely for fixing test failues on
kubernetes-e2e-gke-1.3-1.4-upgrade-cluster
  • Loading branch information
janetkuo committed Sep 16, 2016
1 parent 7b835a7 commit a941348
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions test/e2e/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ func testPausedDeployment(f *framework.Framework) {
podLabels := map[string]string{"name": nginxImageName}
d := newDeployment(deploymentName, 1, podLabels, nginxImageName, nginxImage, extensions.RollingUpdateDeploymentStrategyType, nil)
d.Spec.Paused = true
tgps := int64(20)
d.Spec.Template.Spec.TerminationGracePeriodSeconds = &tgps
framework.Logf("Creating paused deployment %s", deploymentName)
_, err := c.Extensions().Deployments(ns).Create(d)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -622,21 +624,34 @@ func testPausedDeployment(f *framework.Framework) {
err = framework.WaitForObservedDeployment(c, ns, deploymentName, deployment.Generation)
Expect(err).NotTo(HaveOccurred())

newRS, err := deploymentutil.GetNewReplicaSet(deployment, c)
// Update the deployment template - the new replicaset should stay the same
framework.Logf("Updating paused deployment %q", deploymentName)
newTGPS := int64(40)
deployment, err = framework.UpdateDeploymentWithRetries(c, ns, d.Name, func(update *extensions.Deployment) {
update.Spec.Template.Spec.TerminationGracePeriodSeconds = &newTGPS
})
Expect(err).NotTo(HaveOccurred())
Expect(framework.DeleteReplicaSet(unversionedClient, ns, newRS.Name)).NotTo(HaveOccurred())

deployment, err = c.Extensions().Deployments(ns).Get(deploymentName)
err = framework.WaitForObservedDeployment(c, ns, deploymentName, deployment.Generation)
Expect(err).NotTo(HaveOccurred())

if !deployment.Spec.Paused {
err = fmt.Errorf("deployment %q should be paused", deployment.Name)
framework.Logf("Looking for new replicaset for paused deployment %q (there should be none)", deploymentName)
newRS, err := deploymentutil.GetNewReplicaSet(deployment, c)
Expect(err).NotTo(HaveOccurred())
if newRS != nil {
err = fmt.Errorf("No replica set should match the deployment template but there is %q", newRS.Name)
Expect(err).NotTo(HaveOccurred())
}
shouldBeNil, err := deploymentutil.GetNewReplicaSet(deployment, c)

_, allOldRs, err := deploymentutil.GetOldReplicaSets(deployment, c)
Expect(err).NotTo(HaveOccurred())
if shouldBeNil != nil {
err = fmt.Errorf("deployment %q shouldn't have a replica set but there is %q", deployment.Name, shouldBeNil.Name)
if len(allOldRs) != 1 {
err = fmt.Errorf("expected an old replica set")
Expect(err).NotTo(HaveOccurred())
}
framework.Logf("Comparing deployment diff with old replica set %q", allOldRs[0].Name)
if *allOldRs[0].Spec.Template.Spec.TerminationGracePeriodSeconds == newTGPS {
err = fmt.Errorf("TerminationGracePeriodSeconds on the replica set should be %d but is %d", tgps, newTGPS)
Expect(err).NotTo(HaveOccurred())
}
}
Expand Down

0 comments on commit a941348

Please sign in to comment.