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 case for scalling down before scale up finished #34454

Merged
merged 2 commits into from
Nov 22, 2016

Conversation

dshulyak
Copy link
Contributor

@dshulyak dshulyak commented Oct 10, 2016

Verifies that current pet (one which was created last by scale up action)
will enter running before scale down will take place

related: #30082


This change is Reviewable

@dshulyak
Copy link
Contributor Author

Includes #32868

@bprashanth PTAL

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Oct 10, 2016
@erictune
Copy link
Member

@janetkuo PTAL

@janetkuo janetkuo self-assigned this Oct 10, 2016
@fejta fejta removed their assignment Oct 10, 2016
It("scaling down before scale up is finished will wait until current pod will be running and ready", func() {
By("creating petset " + psName + " in namespace " + ns)
testProbe := &api.Probe{Handler: api.Handler{HTTPGet: &api.HTTPGetAction{Path: "/index.html", Port: intstr.IntOrString{IntVal: 80}}}}
ps := newPetSet(psName, ns, headlessSvcName, 1, nil, nil, labels, testProbe)
Copy link
Member

@janetkuo janetkuo Oct 11, 2016

Choose a reason for hiding this comment

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

nit: group these input arguments of newPetSet to make it more clear

ps := newPetSet(psName, ns, headlessSvcName, 1, nil, nil, labels, testProbe)
ps, err := c.Apps().PetSets(ns).Create(ps)
pst := &petSetTester{c: c}
Expect(err).NotTo(HaveOccurred())
Copy link
Member

@janetkuo janetkuo Oct 11, 2016

Choose a reason for hiding this comment

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

move the error check to right after it's returned

@@ -341,6 +341,41 @@ var _ = framework.KubeDescribe("PetSet [Slow] [Feature:PetSet]", func() {
previous = event.pod.Name
}
})

It("scaling down before scale up is finished will wait until current pod will be running and ready", func() {
Copy link
Member

Choose a reason for hiding this comment

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

suggest changing it to: "scaling down before scale up is finished should wait until current pod to be running and ready"

pst.waitForRunningAndReady(1, ps)

By("verifying that scaling down before scale up is finished will wait until current pod will be running and ready")
// pet-2 should be the last pet scale up will create before will start scale down
Copy link
Member

Choose a reason for hiding this comment

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

rephrase the comment?


By("verifying that scaling down before scale up is finished will wait until current pod will be running and ready")
// pet-2 should be the last pet scale up will create before will start scale down
lastPet := "pet-2"
Copy link
Member

Choose a reason for hiding this comment

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

consider renaming it to expectedLastPetName

lastPet := "pet-2"
podTracker = []podEvent{}
pst.setHealthy(ps)
pst.update(ps.Namespace, ps.Name, func(ps *apps.PetSet) { ps.Spec.Replicas = 3 })
Copy link
Member

@janetkuo janetkuo Oct 11, 2016

Choose a reason for hiding this comment

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

consider wrapping this to something like pst.scaleWithoutCheck (or better name, to differentiate from pst.scale)

By("verifying that scaling down before scale up is finished will wait until current pod will be running and ready")
// pet-2 should be the last pet scale up will create before will start scale down
lastPet := "pet-2"
podTracker = []podEvent{}
Copy link
Member

Choose a reason for hiding this comment

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

podEventTracker

pst.waitForRunningAndNotReady(2, ps)
pst.setHealthy(ps)
pst.update(ps.Namespace, ps.Name, func(ps *apps.PetSet) { ps.Spec.Replicas = 1 })
pst.restoreProbe(ps, testProbe)
Copy link
Member

@janetkuo janetkuo Oct 11, 2016

Choose a reason for hiding this comment

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

I'd add more By steps in here, for example:

  1. Scale up petset to 3
  2. Before scaling up finishes, set 2nd pet to be not ready
  3. Scale down petset to 1
  4. Verify ...

}
isReady := api.IsPodReady(event.pod)
if event.pod.Status.Phase != api.PodRunning || !isReady {
framework.Failf("%v expected to be running != %v and ready != %v", event.pod.Name, event.pod.Status.Phase, isReady)
Copy link
Member

Choose a reason for hiding this comment

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

since it's OR, it not necessary be "the running != %v and ready != %v"

pst.update(ps.Namespace, ps.Name, func(ps *apps.PetSet) { ps.Spec.Replicas = 1 })
pst.restoreProbe(ps, testProbe)
for i := len(podTracker) - 1; i >= 0; i-- {
event := podTracker[i]
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain more on what this loop is doing? Is it looking at the last (and only the last) event on pet-2 to see if the pod is ready? Do we need to wait before the check?

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 wanted to verify that lastPet entered running before scale down started. Will rewrite with watcher

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and it is in opposite direction because i wanted to find last event for this pod

@janetkuo janetkuo added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Oct 12, 2016
@bprashanth
Copy link
Contributor

@janetkuo thanks! let me know if you need help, otherwise I'll assume you got this

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 20, 2016
@janetkuo janetkuo added this to the v1.5 milestone Nov 14, 2016
@janetkuo janetkuo mentioned this pull request Nov 16, 2016
19 tasks
@janetkuo
Copy link
Member

janetkuo commented Nov 16, 2016

Ping @dshulyak for rebasing and addressing comments

@dshulyak
Copy link
Contributor Author

@janetkuo fixed comments and rebased, please take a look when you will have time

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2016
@@ -212,6 +212,64 @@ var _ = framework.KubeDescribe("StatefulSet [Slow] [Feature:PetSet]", func() {
pst.verifyPodAtIndex(updateIndex, ps, verify)
})

It("scaling down before scale up is finished should wait until current pod will be running and ready before it will be removed", func() {
By("creating petset " + psName + " in namespace " + ns)
Copy link
Member

Choose a reason for hiding this comment

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

stateful set

Copy link
Member

Choose a reason for hiding this comment

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

"Creating stateful set " + psName + " in namespace " + ns + ", and pausing scale operations after each pod"


By("verifying that 2nd pod will not be removed if it is not healthy")
pst.confirmPetCount(2, ps, 10*time.Second)
expectedPodName := strings.Join([]string{ps.Name, "-1"}, "")
Copy link
Member

Choose a reason for hiding this comment

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

ps.Name + "-1" or fmt.Sprintf("%s-%d", ps.Name, 1) is more readable

@@ -212,6 +212,64 @@ var _ = framework.KubeDescribe("StatefulSet [Slow] [Feature:PetSet]", func() {
pst.verifyPodAtIndex(updateIndex, ps, verify)
})

It("scaling down before scale up is finished should wait until current pod will be running and ready before it will be removed", func() {
Copy link
Member

Choose a reason for hiding this comment

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

"Scaling down before scaling up finishes should wait until current pod to be running"

Copy link
Member

Choose a reason for hiding this comment

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

Capitalize the first words of It and By steps

pst.breakProbe(ps, testProbe)
pst.waitForRunningAndNotReady(2, ps)

By("scaling down to 1 replica and restoring health of 2nd pod")
Copy link
Member

Choose a reason for hiding this comment

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

"Continue scale operations after the 2nd pod, and scaling down to 1 replica"

pst := &statefulSetTester{c: c}
pst.waitForRunningAndReady(1, ps)

By("scaling up stateful set " + psName + " to 3 replicas")
Copy link
Member

Choose a reason for hiding this comment

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

... and pausing after the 2nd pod

pst.setHealthy(ps)
pst.updateReplicas(ps, 1)

By("verifying that 2nd pod will not be removed if it is not healthy")
Copy link
Member

Choose a reason for hiding this comment

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

"Verifying that the 2nd pod will not be removed if it's not running and ready"

Expect(err).NotTo(HaveOccurred())
pst.restoreProbe(ps, testProbe)

By("verifying that 2nd pod will enter running and ready before it will be removed by scale down")
Copy link
Member

Choose a reason for hiding this comment

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

"Verifying the 2nd pod is not removed by scaling down until it becomes running and ready"

},
))
Expect(err).NotTo(HaveOccurred())
pst.restoreProbe(ps, testProbe)
Copy link
Member

Choose a reason for hiding this comment

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

Move this down to the below By

@janetkuo
Copy link
Member

Only nits, LGTM otherwise. This needs to wait for #32868

This change implements test cases to validate that:

    scale up will be done in order
    scale down in reverse order
    if any of the pets will be unhealthy, scale up/down will halt

Change-Id: I4487a7c9823d94a2995bbb06accdfd8f3001354c
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 21, 2016
Verifies that current pet (one which was created last by scale up action)
will enter running before scale down will take place

Change-Id: Ib47644c22b3b097bc466f68c5cac46c78dd44552
@dshulyak
Copy link
Contributor Author

@k8s-bot kops aws e2e test this

@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GKE smoke e2e failed for commit c09e969. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@dshulyak
Copy link
Contributor Author

@k8s-bot gci gke e2e test this

@k8s-ci-robot
Copy link
Contributor

Jenkins GKE smoke e2e failed for commit c09e969. Full PR test history.

The magic incantation to run this job again is @k8s-bot cvm gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins kops AWS e2e failed for commit c09e969. Full PR test history.

The magic incantation to run this job again is @k8s-bot kops aws e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@dshulyak
Copy link
Contributor Author

@k8s-bot cvm gke e2e test this

@dshulyak
Copy link
Contributor Author

@k8s-bot kops aws e2e test this

Copy link
Member

@janetkuo janetkuo left a comment

Choose a reason for hiding this comment

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

/lgtm

@janetkuo janetkuo added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Nov 21, 2016
@janetkuo
Copy link
Member

Adding do-not-merge since this needs to wait for #32868

@janetkuo janetkuo added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. labels Nov 21, 2016
@janetkuo
Copy link
Member

#32868 is merged

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-ci-robot
Copy link
Contributor

Jenkins Bazel Build failed for commit c09e969. Full PR test history.

The magic incantation to run this job again is @k8s-bot bazel test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 88a8094 into kubernetes:master Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants