Merge pull request #33983 from janetkuo/check-petset-status

Automatic merge from submit-queue

Add status check in PetSet e2e tests

<!--  Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md and developer guide https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md
2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/faster_reviews.md
3. Follow the instructions for writing a release note: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes
-->

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**: cc @erictune @foxish @kubernetes/sig-apps

**Release note**:
<!--  Steps to write your release note:
1. Use the release-note-* labels to set the release note state (if you have access) 
2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`. 
-->
```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2016-10-06 02:51:26 -07:00 committed by GitHub
commit 392f6f4757

View File

@ -157,6 +157,8 @@ var _ = framework.KubeDescribe("PetSet [Slow] [Feature:PetSet]", func() {
By("Waiting for pet at index 1 to enter running.")
pst.waitForRunning(2, ps)
// TODO: verify petset status.replicas
// Now we have 1 healthy and 1 unhealthy pet. Deleting the healthy pet should *not*
// create a new pet till the remaining pet becomes healthy, which won't happen till
// we set the healthy bit.
@ -577,6 +579,8 @@ func (p *petSetTester) saturate(ps *apps.PetSet) {
framework.Logf("Marking pet at index " + fmt.Sprintf("%v", i) + " healthy")
p.setHealthy(ps)
}
framework.Logf("Waiting for pet set status.replicas updated to %d", ps.Spec.Replicas)
p.waitForStatus(ps, ps.Spec.Replicas)
}
func (p *petSetTester) deletePetAtIndex(index int, ps *apps.PetSet) {
@ -708,6 +712,25 @@ func (p *petSetTester) setHealthy(ps *apps.PetSet) {
}
}
func (p *petSetTester) waitForStatus(ps *apps.PetSet, expectedReplicas int) {
ns, name := ps.Namespace, ps.Name
pollErr := wait.PollImmediate(petsetPoll, petsetTimeout,
func() (bool, error) {
psGet, err := p.c.Apps().PetSets(ns).Get(name)
if err != nil {
return false, err
}
if psGet.Status.Replicas != expectedReplicas {
framework.Logf("Waiting for pet set status to become %d, currently %d", expectedReplicas, ps.Status.Replicas)
return false, nil
}
return true, nil
})
if pollErr != nil {
framework.Failf("Failed waiting for pet set status.replicas updated to %d, got %d: %v", expectedReplicas, ps.Status.Replicas, pollErr)
}
}
func deleteAllPetSets(c *client.Client, ns string) {
pst := &petSetTester{c: c}
psList, err := c.Apps().PetSets(ns).List(api.ListOptions{LabelSelector: labels.Everything()})