-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Test case for scalling down before scale up finished #34454
Conversation
Includes #32868 @bprashanth PTAL |
@janetkuo PTAL |
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) |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 }) |
There was a problem hiding this comment.
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{} |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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:
- Scale up petset to 3
- Before scaling up finishes, set 2nd pet to be not ready
- Scale down petset to 1
- 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) |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 thanks! let me know if you need help, otherwise I'll assume you got this |
Ping @dshulyak for rebasing and addressing comments |
8863691
to
cf69b1e
Compare
@janetkuo fixed comments and rebased, please take a look when you will have time |
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stateful set
There was a problem hiding this comment.
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"}, "") |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
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
cf69b1e
to
b46a36e
Compare
b46a36e
to
d9ea8c0
Compare
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
d9ea8c0
to
c09e969
Compare
@k8s-bot kops aws e2e test this |
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 |
Jenkins GKE smoke e2e failed for commit c09e969. Full PR test history. The magic incantation to run this job again is |
Jenkins kops AWS 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 |
@k8s-bot kops aws e2e test this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Adding do-not-merge since this needs to wait for #32868 |
#32868 is merged |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Jenkins Bazel Build failed for commit c09e969. Full PR test history. The magic incantation to run this job again is |
Automatic merge from submit-queue |
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