Ensure current Replica check is from ReplicationController watch

This commit is contained in:
Caleb Woodbine 2020-03-04 14:55:11 +13:00
parent c715fec47d
commit 3fa4acb9b7

View File

@ -192,18 +192,20 @@ var _ = SIGDescribe("ReplicationController", func() {
// Patch the ReplicationController's scale // Patch the ReplicationController's scale
ginkgo.By("patching ReplicationController scale") ginkgo.By("patching ReplicationController scale")
rcScale, err := f.ClientSet.CoreV1().ReplicationControllers(testRcNamespace).Patch(context.TODO(), testRcName, types.StrategicMergePatchType, []byte(rcScalePatchPayload), metav1.PatchOptions{}, "scale") _, err = f.ClientSet.CoreV1().ReplicationControllers(testRcNamespace).Patch(context.TODO(), testRcName, types.StrategicMergePatchType, []byte(rcScalePatchPayload), metav1.PatchOptions{}, "scale")
framework.ExpectNoError(err, "Failed to patch ReplicationControllerScale") framework.ExpectNoError(err, "Failed to patch ReplicationControllerScale")
var rcFromWatch *v1.ReplicationController
ginkgo.By("waiting for ReplicationController's scale to be the max amount")
for event := range rcWatchChan { for event := range rcWatchChan {
rc, ok := event.Object.(*v1.ReplicationController) rc, ok := event.Object.(*v1.ReplicationController)
framework.ExpectEqual(ok, true, "Unable to convert type of ReplicationController watch event") framework.ExpectEqual(ok, true, "Unable to convert type of ReplicationController watch event")
if rc.Status.Replicas == testRcMaxReplicaCount && rc.Status.ReadyReplicas == testRcMaxReplicaCount { if rc.Status.Replicas == testRcMaxReplicaCount && rc.Status.ReadyReplicas == testRcMaxReplicaCount {
rcScale = rc rcFromWatch = rc
break break
} }
} }
framework.ExpectEqual(rcScale.Status.Replicas, testRcMaxReplicaCount, "ReplicationController ReplicasSet Scale does not match the expected scale") framework.ExpectEqual(rcFromWatch.Status.Replicas, testRcMaxReplicaCount, "ReplicationController ReplicasSet Scale does not match the expected scale")
// Get the ReplicationController // Get the ReplicationController
ginkgo.By("fetching ReplicationController; ensuring that it's patched") ginkgo.By("fetching ReplicationController; ensuring that it's patched")