mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Update error statements
This commit is contained in:
parent
a2c19d7ae0
commit
6e04fbdde1
@ -901,25 +901,27 @@ var _ = framework.KubeDescribe("Pods", func() {
|
|||||||
}
|
}
|
||||||
ginkgo.By("creating a Pod with a static label")
|
ginkgo.By("creating a Pod with a static label")
|
||||||
_, err := f.ClientSet.CoreV1().Pods(testNs).Create(context.TODO(), &testPod, metav1.CreateOptions{})
|
_, 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")
|
ginkgo.By("setting up a watch for the Pod")
|
||||||
podWatchTimeoutSeconds := int64(180)
|
podWatchTimeoutSeconds := int64(180)
|
||||||
podWatch, err := f.ClientSet.CoreV1().Pods(testNs).Watch(context.TODO(), metav1.ListOptions{LabelSelector: testPodLabelsFlat, TimeoutSeconds: &podWatchTimeoutSeconds})
|
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()
|
podWatchChan := podWatch.ResultChan()
|
||||||
ginkgo.By("watching for Pod to be ready")
|
ginkgo.By("watching for Pod to be ready")
|
||||||
eventFound := false
|
eventFound := false
|
||||||
for watchEvent := range podWatchChan {
|
for watchEvent := range podWatchChan {
|
||||||
podWatchEvent, ok := watchEvent.Object.(*v1.Pod)
|
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 {
|
if podWatchEvent.Status.Phase == v1.PodRunning {
|
||||||
eventFound = true
|
eventFound = true
|
||||||
break
|
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")
|
ginkgo.By("patching the Pod with a new Label and updated data")
|
||||||
podPatch, err := json.Marshal(v1.Pod{
|
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")
|
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{})
|
_, 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")
|
ginkgo.By("getting the Pod and ensuring that it's patched")
|
||||||
pod, err := f.ClientSet.CoreV1().Pods(testNs).Get(context.TODO(), testPodName, metav1.GetOptions{})
|
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.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")
|
framework.ExpectEqual(pod.Spec.Containers[0].Image, testPodImage2, "failed to patch Pod - wrong image")
|
||||||
|
|
||||||
ginkgo.By("getting the PodStatus")
|
ginkgo.By("getting the PodStatus")
|
||||||
podStatusUnstructured, err := dc.Resource(podResource).Namespace(testNs).Get(context.TODO(), testPodName, metav1.GetOptions{}, "status")
|
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)
|
podStatusBytes, err := json.Marshal(podStatusUnstructured)
|
||||||
framework.ExpectNoError(err, "failed to marshal unstructured response")
|
framework.ExpectNoError(err, "failed to marshal unstructured response")
|
||||||
var podStatus v1.Pod
|
var podStatus v1.Pod
|
||||||
@ -964,7 +966,7 @@ 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")
|
||||||
podStatusUpdate, 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 of Pod " + testPodName + " in namespace " + testNs)
|
||||||
|
|
||||||
ginkgo.By("check the Pod again to ensure its Ready conditions are False")
|
ginkgo.By("check the Pod again to ensure its Ready conditions are False")
|
||||||
podStatusFieldPatchCount = 0
|
podStatusFieldPatchCount = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user