Update error statements

This commit is contained in:
Caleb Woodbine 2020-04-23 11:58:19 +12:00
parent a2c19d7ae0
commit 6e04fbdde1

View File

@ -901,25 +901,27 @@ var _ = framework.KubeDescribe("Pods", func() {
}
ginkgo.By("creating a Pod with a static label")
_, err := f.ClientSet.CoreV1().Pods(testNs).Create(context.TODO(), &testPod, metav1.CreateOptions{})
framework.ExpectNoError(err, "failed to create Pod")
framework.ExpectNoError(err, "failed to create Pod " + testPodName + " in namespace " + testNs)
ginkgo.By("setting up a watch for the Pod")
podWatchTimeoutSeconds := int64(180)
podWatch, err := f.ClientSet.CoreV1().Pods(testNs).Watch(context.TODO(), metav1.ListOptions{LabelSelector: testPodLabelsFlat, TimeoutSeconds: &podWatchTimeoutSeconds})
framework.ExpectNoError(err, "failed to set up watch")
framework.ExpectNoError(err, "failed to set up watch for Pod " + testPodName + " in namespace " + testNs)
podWatchChan := podWatch.ResultChan()
ginkgo.By("watching for Pod to be ready")
eventFound := false
for watchEvent := range podWatchChan {
podWatchEvent, ok := watchEvent.Object.(*v1.Pod)
framework.ExpectEqual(ok, true, "unable to assert runtime object type to v1.Pod")
if ok == false {
continue
}
if podWatchEvent.Status.Phase == v1.PodRunning {
eventFound = true
break
}
}
framework.ExpectEqual(eventFound, true, "failed to find running Pod")
framework.ExpectEqual(eventFound, true, "failed to find running Pod " + testPodName + " in namespace " + testNs)
ginkgo.By("patching the Pod with a new Label and updated data")
podPatch, err := json.Marshal(v1.Pod{
@ -935,17 +937,17 @@ var _ = framework.KubeDescribe("Pods", func() {
})
framework.ExpectNoError(err, "failed to marshal JSON patch for Pod")
_, err = f.ClientSet.CoreV1().Pods(testNs).Patch(context.TODO(), testPodName, types.StrategicMergePatchType, []byte(podPatch), metav1.PatchOptions{})
framework.ExpectNoError(err, "failed to patch Pod")
framework.ExpectNoError(err, "failed to patch Pod " + testPodName + " in namespace " + testNs)
ginkgo.By("getting the Pod and ensuring that it's patched")
pod, err := f.ClientSet.CoreV1().Pods(testNs).Get(context.TODO(), testPodName, metav1.GetOptions{})
framework.ExpectNoError(err, "failed to fetch Pod")
framework.ExpectNoError(err, "failed to fetch Pod " + testPodName + " in namespace " + testNs)
framework.ExpectEqual(pod.ObjectMeta.Labels["test-pod-static"], "true", "failed to patch Pod - missing label")
framework.ExpectEqual(pod.Spec.Containers[0].Image, testPodImage2, "failed to patch Pod - wrong image")
ginkgo.By("getting the PodStatus")
podStatusUnstructured, err := dc.Resource(podResource).Namespace(testNs).Get(context.TODO(), testPodName, metav1.GetOptions{}, "status")
framework.ExpectNoError(err, "failed to fetch PodStatus")
framework.ExpectNoError(err, "failed to fetch PodStatus of Pod " + testPodName + " in namespace " + testNs)
podStatusBytes, err := json.Marshal(podStatusUnstructured)
framework.ExpectNoError(err, "failed to marshal unstructured response")
var podStatus v1.Pod
@ -964,7 +966,7 @@ var _ = framework.KubeDescribe("Pods", func() {
}
framework.ExpectEqual(podStatusFieldPatchCount, podStatusFieldPatchCountTotal, "failed to patch all relevant Pod conditions")
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 of Pod " + testPodName + " in namespace " + testNs)
ginkgo.By("check the Pod again to ensure its Ready conditions are False")
podStatusFieldPatchCount = 0