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

Automated cherry pick of #15044 upstream release 1.1 #15397

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
1 change: 1 addition & 0 deletions hack/jenkins/e2e.sh
Expand Up @@ -509,6 +509,7 @@ case ${JOB_NAME} in
: ${E2E_UP:="true"}
: ${E2E_TEST:="false"}
: ${E2E_DOWN:="false"}
: ${ENABLE_DEPLOYMENTS:=true}
;;

kubernetes-upgrade-gce-step2-upgrade)
Expand Down
35 changes: 23 additions & 12 deletions test/e2e/deployment.go
Expand Up @@ -95,18 +95,23 @@ func testRollingUpdateDeployment(f *Framework) {
ns := f.Namespace.Name
c := f.Client
// Create nginx pods.
podLabels := map[string]string{"name": "sample-pod"}
deploymentPodLabels := map[string]string{"name": "sample-pod"}
rcPodLabels := map[string]string{
"name": "sample-pod",
"pod": "nginx",
}

rcName := "nginx-controller"
_, err := c.ReplicationControllers(ns).Create(&api.ReplicationController{
ObjectMeta: api.ObjectMeta{
Name: rcName,
},
Spec: api.ReplicationControllerSpec{
Replicas: 3,
Selector: podLabels,
Selector: rcPodLabels,
Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: podLabels,
Labels: rcPodLabels,
},
Spec: api.PodSpec{
Containers: []api.Container{
Expand Down Expand Up @@ -140,11 +145,11 @@ func testRollingUpdateDeployment(f *Framework) {
},
Spec: experimental.DeploymentSpec{
Replicas: 3,
Selector: podLabels,
Selector: deploymentPodLabels,
UniqueLabelKey: "deployment.kubernetes.io/podTemplateHash",
Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: podLabels,
Labels: deploymentPodLabels,
},
Spec: api.PodSpec{
Containers: []api.Container{
Expand All @@ -164,25 +169,30 @@ func testRollingUpdateDeployment(f *Framework) {
Expect(c.Deployments(ns).Delete(deploymentName, nil)).NotTo(HaveOccurred())
}()

waitForDeploymentStatus(c, ns, deploymentName, 3, 2, 4)
err = waitForDeploymentStatus(c, ns, deploymentName, 3, 2, 4)
Expect(err).NotTo(HaveOccurred())
}

func testRollingUpdateDeploymentEvents(f *Framework) {
ns := f.Namespace.Name
c := f.Client
// Create nginx pods.
podLabels := map[string]string{"name": "sample-pod"}
deploymentPodLabels := map[string]string{"name": "sample-pod"}
rcPodLabels := map[string]string{
"name": "sample-pod",
"pod": "nginx",
}
rcName := "nginx-controller"
_, err := c.ReplicationControllers(ns).Create(&api.ReplicationController{
ObjectMeta: api.ObjectMeta{
Name: rcName,
},
Spec: api.ReplicationControllerSpec{
Replicas: 1,
Selector: podLabels,
Selector: rcPodLabels,
Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: podLabels,
Labels: rcPodLabels,
},
Spec: api.PodSpec{
Containers: []api.Container{
Expand Down Expand Up @@ -216,11 +226,11 @@ func testRollingUpdateDeploymentEvents(f *Framework) {
},
Spec: experimental.DeploymentSpec{
Replicas: 1,
Selector: podLabels,
Selector: deploymentPodLabels,
UniqueLabelKey: "deployment.kubernetes.io/podTemplateHash",
Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: podLabels,
Labels: deploymentPodLabels,
},
Spec: api.PodSpec{
Containers: []api.Container{
Expand All @@ -240,7 +250,8 @@ func testRollingUpdateDeploymentEvents(f *Framework) {
Expect(c.Deployments(ns).Delete(deploymentName, nil)).NotTo(HaveOccurred())
}()

waitForDeploymentStatus(c, ns, deploymentName, 1, 0, 2)
err = waitForDeploymentStatus(c, ns, deploymentName, 1, 0, 2)
Expect(err).NotTo(HaveOccurred())
// Verify that the pods were scaled up and down as expected. We use events to verify that.
deployment, err := c.Deployments(ns).Get(deploymentName)
Expect(err).NotTo(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/util.go
Expand Up @@ -1530,7 +1530,7 @@ func waitForRCPodsGone(c *client.Client, rc *api.ReplicationController) error {
// Waits for the deployment to reach desired state.
// Returns an error if minAvailable or maxCreated is broken at any times.
func waitForDeploymentStatus(c *client.Client, ns, deploymentName string, desiredUpdatedReplicas, minAvailable, maxCreated int) error {
return wait.Poll(poll, 2*time.Minute, func() (bool, error) {
return wait.Poll(poll, 5*time.Minute, func() (bool, error) {

deployment, err := c.Deployments(ns).Get(deploymentName)
if err != nil {
Expand Down