Update to check response data of UpdateStatus instead of listing after updating the status

This commit is contained in:
Caleb Woodbine 2020-04-02 10:26:43 +13:00
parent 19e9368eb8
commit 47cd8dde56

View File

@ -962,19 +962,15 @@ var _ = framework.KubeDescribe("Pods", func() {
} }
} }
framework.ExpectEqual(podStatusFieldPatchCount, podStatusFieldPatchCountTotal, "failed to patch all relevant Pod conditions") framework.ExpectEqual(podStatusFieldPatchCount, podStatusFieldPatchCountTotal, "failed to patch all relevant Pod conditions")
_, err = f.ClientSet.CoreV1().Pods(testNs).UpdateStatus(context.TODO(), &podStatusUpdated, metav1.UpdateOptions{}) podStatusUpdate, err := f.ClientSet.CoreV1().Pods(testNs).UpdateStatus(context.TODO(), &podStatusUpdated, metav1.UpdateOptions{})
framework.ExpectNoError(err, "failed to update PodStatus") framework.ExpectNoError(err, "failed to update PodStatus")
ginkgo.By("list all Pods and get their status to ensure it's Ready condition is False") ginkgo.By("check the PodStatus updates's return status to ensure it's Ready condition is False")
podsList, err := f.ClientSet.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{LabelSelector: "test-pod-static=true"})
framework.ExpectNoError(err, "failed to list Pods")
podStatusFieldPatchCount = 0 podStatusFieldPatchCount = 0
podStatusFieldPatchCountTotal = 2 podStatusFieldPatchCountTotal = 2
for _, podItem := range podsList.Items { for _, cond := range podStatusUpdate.Status.Conditions {
for _, cond := range podItem.Status.Conditions { if (cond.Type == "Ready" && cond.Status == "False") || (cond.Type == "ContainersReady" && cond.Status == "False") {
if (cond.Type == "Ready" && cond.Status == "False") || (cond.Type == "ContainersReady" && cond.Status == "False") { podStatusFieldPatchCount++
podStatusFieldPatchCount++
}
} }
} }
framework.ExpectEqual(podStatusFieldPatchCount, podStatusFieldPatchCountTotal, "failed to update PodStatus - field patch count doesn't match the total") framework.ExpectEqual(podStatusFieldPatchCount, podStatusFieldPatchCountTotal, "failed to update PodStatus - field patch count doesn't match the total")