mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #119489 from carlory/cleanup-e2e-common-framework-equal
e2e_common: stop using deprecated framework.ExpectEqual
This commit is contained in:
commit
d4d9f7deee
@ -31,6 +31,7 @@ import (
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = SIGDescribe("ConfigMap", func() {
|
||||
@ -157,7 +158,7 @@ var _ = SIGDescribe("ConfigMap", func() {
|
||||
configMapFromUpdate, err := f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Get(ctx, name, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err, "failed to get ConfigMap")
|
||||
ginkgo.By(fmt.Sprintf("Verifying update of ConfigMap %v/%v", f.Namespace.Name, configMap.Name))
|
||||
framework.ExpectEqual(configMapFromUpdate.Data, configMap.Data)
|
||||
gomega.Expect(configMapFromUpdate.Data).To(gomega.Equal(configMap.Data))
|
||||
})
|
||||
|
||||
/*
|
||||
@ -189,8 +190,8 @@ var _ = SIGDescribe("ConfigMap", func() {
|
||||
ginkgo.By("fetching the ConfigMap")
|
||||
configMap, err := f.ClientSet.CoreV1().ConfigMaps(testNamespaceName).Get(ctx, testConfigMapName, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err, "failed to get ConfigMap")
|
||||
framework.ExpectEqual(configMap.Data["valueName"], testConfigMap.Data["valueName"])
|
||||
framework.ExpectEqual(configMap.Labels["test-configmap-static"], testConfigMap.Labels["test-configmap-static"])
|
||||
gomega.Expect(configMap.Data["valueName"]).To(gomega.Equal(testConfigMap.Data["valueName"]))
|
||||
gomega.Expect(configMap.Labels["test-configmap-static"]).To(gomega.Equal(testConfigMap.Labels["test-configmap-static"]))
|
||||
|
||||
configMapPatchPayload, err := json.Marshal(v1.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@ -239,7 +240,7 @@ var _ = SIGDescribe("ConfigMap", func() {
|
||||
LabelSelector: "test-configmap-static=true",
|
||||
})
|
||||
framework.ExpectNoError(err, "failed to list ConfigMap by LabelSelector")
|
||||
framework.ExpectEqual(len(configMapList.Items), 0, "ConfigMap is still present after being deleted by collection")
|
||||
gomega.Expect(configMapList.Items).To(gomega.BeEmpty(), "ConfigMap is still present after being deleted by collection")
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -95,7 +95,7 @@ var _ = SIGDescribe("Probing container", func() {
|
||||
}
|
||||
|
||||
restartCount := getRestartCount(p)
|
||||
framework.ExpectEqual(restartCount, 0, "pod should have a restart count of 0 but got %v", restartCount)
|
||||
gomega.Expect(restartCount).To(gomega.Equal(0), "pod should have a restart count of 0 but got %v", restartCount)
|
||||
})
|
||||
|
||||
/*
|
||||
@ -123,7 +123,7 @@ var _ = SIGDescribe("Probing container", func() {
|
||||
}
|
||||
|
||||
restartCount := getRestartCount(p)
|
||||
framework.ExpectEqual(restartCount, 0, "pod should have a restart count of 0 but got %v", restartCount)
|
||||
gomega.Expect(restartCount).To(gomega.Equal(0), "pod should have a restart count of 0 but got %v", restartCount)
|
||||
})
|
||||
|
||||
/*
|
||||
@ -773,7 +773,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain
|
||||
}
|
||||
|
||||
restartCount := getRestartCount(p)
|
||||
framework.ExpectEqual(restartCount, 0, "pod should have a restart count of 0 but got %v", restartCount)
|
||||
gomega.Expect(restartCount).To(gomega.Equal(0), "pod should have a restart count of 0 but got %v", restartCount)
|
||||
})
|
||||
|
||||
/*
|
||||
@ -802,7 +802,7 @@ var _ = SIGDescribe("[NodeAlphaFeature:SidecarContainers][Feature:SidecarContain
|
||||
}
|
||||
|
||||
restartCount := getRestartCount(p)
|
||||
framework.ExpectEqual(restartCount, 0, "pod should have a restart count of 0 but got %v", restartCount)
|
||||
gomega.Expect(restartCount).To(gomega.Equal(0), "pod should have a restart count of 0 but got %v", restartCount)
|
||||
})
|
||||
|
||||
/*
|
||||
|
@ -230,12 +230,12 @@ var _ = SIGDescribe("InitContainer [NodeConformance]", func() {
|
||||
|
||||
checkInvariants(events, containerInitInvariant)
|
||||
endPod := event.Object.(*v1.Pod)
|
||||
framework.ExpectEqual(endPod.Status.Phase, v1.PodSucceeded)
|
||||
gomega.Expect(endPod.Status.Phase).To(gomega.Equal(v1.PodSucceeded))
|
||||
_, init := podutil.GetPodCondition(&endPod.Status, v1.PodInitialized)
|
||||
gomega.Expect(init).NotTo(gomega.BeNil())
|
||||
framework.ExpectEqual(init.Status, v1.ConditionTrue)
|
||||
gomega.Expect(init.Status).To(gomega.Equal(v1.ConditionTrue))
|
||||
|
||||
framework.ExpectEqual(len(endPod.Status.InitContainerStatuses), 2)
|
||||
gomega.Expect(endPod.Status.InitContainerStatuses).To(gomega.HaveLen(2))
|
||||
for _, status := range endPod.Status.InitContainerStatuses {
|
||||
if !status.Ready {
|
||||
framework.Failf("init container %s should be in Ready status", status.Name)
|
||||
@ -309,12 +309,12 @@ var _ = SIGDescribe("InitContainer [NodeConformance]", func() {
|
||||
|
||||
checkInvariants(events, containerInitInvariant)
|
||||
endPod := event.Object.(*v1.Pod)
|
||||
framework.ExpectEqual(endPod.Status.Phase, v1.PodRunning)
|
||||
gomega.Expect(endPod.Status.Phase).To(gomega.Equal(v1.PodRunning))
|
||||
_, init := podutil.GetPodCondition(&endPod.Status, v1.PodInitialized)
|
||||
gomega.Expect(init).NotTo(gomega.BeNil())
|
||||
framework.ExpectEqual(init.Status, v1.ConditionTrue)
|
||||
gomega.Expect(init.Status).To(gomega.Equal(v1.ConditionTrue))
|
||||
|
||||
framework.ExpectEqual(len(endPod.Status.InitContainerStatuses), 2)
|
||||
gomega.Expect(endPod.Status.InitContainerStatuses).To(gomega.HaveLen(2))
|
||||
for _, status := range endPod.Status.InitContainerStatuses {
|
||||
if !status.Ready {
|
||||
framework.Failf("init container %s should be in Ready status", status.Name)
|
||||
@ -441,13 +441,13 @@ var _ = SIGDescribe("InitContainer [NodeConformance]", func() {
|
||||
|
||||
checkInvariants(events, containerInitInvariant)
|
||||
endPod := event.Object.(*v1.Pod)
|
||||
framework.ExpectEqual(endPod.Status.Phase, v1.PodPending)
|
||||
gomega.Expect(endPod.Status.Phase).To(gomega.Equal(v1.PodPending))
|
||||
_, init := podutil.GetPodCondition(&endPod.Status, v1.PodInitialized)
|
||||
gomega.Expect(init).NotTo(gomega.BeNil())
|
||||
framework.ExpectEqual(init.Status, v1.ConditionFalse)
|
||||
framework.ExpectEqual(init.Reason, "ContainersNotInitialized")
|
||||
framework.ExpectEqual(init.Message, "containers with incomplete status: [init1 init2]")
|
||||
framework.ExpectEqual(len(endPod.Status.InitContainerStatuses), 2)
|
||||
gomega.Expect(init.Status).To(gomega.Equal(v1.ConditionFalse))
|
||||
gomega.Expect(init.Reason).To(gomega.Equal("ContainersNotInitialized"))
|
||||
gomega.Expect(init.Message).To(gomega.Equal("containers with incomplete status: [init1 init2]"))
|
||||
gomega.Expect(endPod.Status.InitContainerStatuses).To(gomega.HaveLen(2))
|
||||
})
|
||||
|
||||
/*
|
||||
@ -557,13 +557,13 @@ var _ = SIGDescribe("InitContainer [NodeConformance]", func() {
|
||||
checkInvariants(events, containerInitInvariant)
|
||||
endPod := event.Object.(*v1.Pod)
|
||||
|
||||
framework.ExpectEqual(endPod.Status.Phase, v1.PodFailed)
|
||||
gomega.Expect(endPod.Status.Phase).To(gomega.Equal(v1.PodFailed))
|
||||
_, init := podutil.GetPodCondition(&endPod.Status, v1.PodInitialized)
|
||||
gomega.Expect(init).NotTo(gomega.BeNil())
|
||||
framework.ExpectEqual(init.Status, v1.ConditionFalse)
|
||||
framework.ExpectEqual(init.Reason, "ContainersNotInitialized")
|
||||
framework.ExpectEqual(init.Message, "containers with incomplete status: [init2]")
|
||||
framework.ExpectEqual(len(endPod.Status.InitContainerStatuses), 2)
|
||||
gomega.Expect(init.Status).To(gomega.Equal(v1.ConditionFalse))
|
||||
gomega.Expect(init.Reason).To(gomega.Equal("ContainersNotInitialized"))
|
||||
gomega.Expect(init.Message).To(gomega.Equal("containers with incomplete status: [init2]"))
|
||||
gomega.Expect(endPod.Status.InitContainerStatuses).To(gomega.HaveLen(2))
|
||||
gomega.Expect(endPod.Status.ContainerStatuses[0].State.Waiting).ToNot(gomega.BeNil())
|
||||
})
|
||||
})
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
@ -169,7 +168,7 @@ var _ = SIGDescribe("Kubelet", func() {
|
||||
hostsFileContent := buf.String()
|
||||
|
||||
errMsg := fmt.Sprintf("expected hosts file to contain entries from HostAliases. Got:\n%+v", hostsFileContent)
|
||||
framework.ExpectEqual(true, strings.Contains(hostsFileContent, "123.45.67.89\tfoo\tbar"), errMsg)
|
||||
gomega.Expect(hostsFileContent).To(gomega.ContainSubstring("123.45.67.89\tfoo\tbar"), errMsg)
|
||||
})
|
||||
})
|
||||
ginkgo.Context("when scheduling a read only busybox container", func() {
|
||||
|
@ -34,6 +34,7 @@ import (
|
||||
"k8s.io/utils/pointer"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func getPatchBytes(oldLease, newLease *coordinationv1.Lease) ([]byte, error) {
|
||||
@ -151,7 +152,7 @@ var _ = SIGDescribe("Lease", func() {
|
||||
|
||||
leases, err := leaseClient.List(ctx, metav1.ListOptions{})
|
||||
framework.ExpectNoError(err, "couldn't list Leases")
|
||||
framework.ExpectEqual(len(leases.Items), 2)
|
||||
gomega.Expect(leases.Items).To(gomega.HaveLen(2))
|
||||
|
||||
selector := labels.Set(map[string]string{"deletecollection": "true"}).AsSelector()
|
||||
err = leaseClient.DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{LabelSelector: selector.String()})
|
||||
@ -159,7 +160,7 @@ var _ = SIGDescribe("Lease", func() {
|
||||
|
||||
leases, err = leaseClient.List(ctx, metav1.ListOptions{})
|
||||
framework.ExpectNoError(err, "couldn't list Leases")
|
||||
framework.ExpectEqual(len(leases.Items), 1)
|
||||
gomega.Expect(leases.Items).To(gomega.HaveLen(1))
|
||||
|
||||
err = leaseClient.Delete(ctx, name, metav1.DeleteOptions{})
|
||||
framework.ExpectNoError(err, "deleting Lease failed")
|
||||
|
@ -105,9 +105,9 @@ var _ = SIGDescribe("NodeLease", func() {
|
||||
for i := range leaseList.Items {
|
||||
lease := &leaseList.Items[i]
|
||||
ownerRefs := lease.ObjectMeta.OwnerReferences
|
||||
framework.ExpectEqual(len(ownerRefs), 1)
|
||||
framework.ExpectEqual(ownerRefs[0].Kind, v1.SchemeGroupVersion.WithKind("Node").Kind)
|
||||
framework.ExpectEqual(ownerRefs[0].APIVersion, v1.SchemeGroupVersion.WithKind("Node").Version)
|
||||
gomega.Expect(ownerRefs).To(gomega.HaveLen(1))
|
||||
gomega.Expect(ownerRefs[0].Kind).To(gomega.Equal(v1.SchemeGroupVersion.WithKind("Node").Kind))
|
||||
gomega.Expect(ownerRefs[0].APIVersion).To(gomega.Equal(v1.SchemeGroupVersion.WithKind("Node").Version))
|
||||
}
|
||||
})
|
||||
|
||||
@ -181,7 +181,7 @@ var _ = SIGDescribe("NodeLease", func() {
|
||||
node, err := f.ClientSet.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
_, readyCondition := testutils.GetNodeCondition(&node.Status, v1.NodeReady)
|
||||
framework.ExpectEqual(readyCondition.Status, v1.ConditionTrue)
|
||||
gomega.Expect(readyCondition.Status).To(gomega.Equal(v1.ConditionTrue))
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -190,7 +190,7 @@ func getHeartbeatTimeAndStatus(ctx context.Context, clientSet clientset.Interfac
|
||||
node, err := clientSet.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
_, readyCondition := testutils.GetNodeCondition(&node.Status, v1.NodeReady)
|
||||
framework.ExpectEqual(readyCondition.Status, v1.ConditionTrue)
|
||||
gomega.Expect(readyCondition.Status).To(gomega.Equal(v1.ConditionTrue))
|
||||
heartbeatTime := readyCondition.LastHeartbeatTime.Time
|
||||
readyCondition.LastHeartbeatTime = metav1.Time{}
|
||||
return heartbeatTime, node.Status
|
||||
|
@ -251,7 +251,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err := podClient.List(ctx, options)
|
||||
framework.ExpectNoError(err, "failed to query for pods")
|
||||
framework.ExpectEqual(len(pods.Items), 0)
|
||||
gomega.Expect(pods.Items).To(gomega.BeEmpty())
|
||||
|
||||
lw := &cache.ListWatch{
|
||||
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
|
||||
@ -281,7 +281,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
options = metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err = podClient.List(ctx, options)
|
||||
framework.ExpectNoError(err, "failed to query for pods")
|
||||
framework.ExpectEqual(len(pods.Items), 1)
|
||||
gomega.Expect(pods.Items).To(gomega.HaveLen(1))
|
||||
|
||||
ginkgo.By("verifying pod creation was observed")
|
||||
select {
|
||||
@ -334,7 +334,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
options = metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err = podClient.List(ctx, options)
|
||||
framework.ExpectNoError(err, "failed to query for pods")
|
||||
framework.ExpectEqual(len(pods.Items), 0)
|
||||
gomega.Expect(pods.Items).To(gomega.BeEmpty())
|
||||
})
|
||||
|
||||
/*
|
||||
@ -372,7 +372,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err := podClient.List(ctx, options)
|
||||
framework.ExpectNoError(err, "failed to query for pods")
|
||||
framework.ExpectEqual(len(pods.Items), 1)
|
||||
gomega.Expect(pods.Items).To(gomega.HaveLen(1))
|
||||
|
||||
ginkgo.By("updating the pod")
|
||||
podClient.Update(ctx, name, func(pod *v1.Pod) {
|
||||
@ -387,7 +387,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
options = metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err = podClient.List(ctx, options)
|
||||
framework.ExpectNoError(err, "failed to query for pods")
|
||||
framework.ExpectEqual(len(pods.Items), 1)
|
||||
gomega.Expect(pods.Items).To(gomega.HaveLen(1))
|
||||
framework.Logf("Pod update OK")
|
||||
})
|
||||
|
||||
@ -426,7 +426,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
pods, err := podClient.List(ctx, options)
|
||||
framework.ExpectNoError(err, "failed to query for pods")
|
||||
framework.ExpectEqual(len(pods.Items), 1)
|
||||
gomega.Expect(pods.Items).To(gomega.HaveLen(1))
|
||||
|
||||
ginkgo.By("updating the pod")
|
||||
podClient.Update(ctx, name, func(pod *v1.Pod) {
|
||||
@ -956,7 +956,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
}
|
||||
p, err := f.ClientSet.CoreV1().Pods(testNamespaceName).Get(ctx, testPodName, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err, "failed to get Pod %v in namespace %v", testPodName, testNamespaceName)
|
||||
framework.ExpectEqual(p.Status.Phase, v1.PodRunning, "failed to see Pod %v in namespace %v running", p.ObjectMeta.Name, testNamespaceName)
|
||||
gomega.Expect(p.Status.Phase).To(gomega.Equal(v1.PodRunning), "failed to see Pod %v in namespace %v running", p.ObjectMeta.Name, testNamespaceName)
|
||||
|
||||
ginkgo.By("patching the Pod with a new Label and updated data")
|
||||
prePatchResourceVersion := p.ResourceVersion
|
||||
@ -997,8 +997,8 @@ var _ = SIGDescribe("Pods", func() {
|
||||
ginkgo.By("getting the Pod and ensuring that it's patched")
|
||||
pod, err := f.ClientSet.CoreV1().Pods(testNamespaceName).Get(ctx, testPodName, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err, "failed to fetch Pod %s in namespace %s", testPodName, testNamespaceName)
|
||||
framework.ExpectEqual(pod.ObjectMeta.Labels["test-pod"], "patched", "failed to patch Pod - missing label")
|
||||
framework.ExpectEqual(pod.Spec.Containers[0].Image, testPodImage2, "failed to patch Pod - wrong image")
|
||||
gomega.Expect(pod.ObjectMeta.Labels).To(gomega.HaveKeyWithValue("test-pod", "patched"), "failed to patch Pod - missing label")
|
||||
gomega.Expect(pod.Spec.Containers[0].Image).To(gomega.Equal(testPodImage2), "failed to patch Pod - wrong image")
|
||||
|
||||
ginkgo.By("replacing the Pod's status Ready condition to False")
|
||||
var podStatusUpdate *v1.Pod
|
||||
@ -1020,7 +1020,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
podStatusFieldPatchCount++
|
||||
}
|
||||
}
|
||||
framework.ExpectEqual(podStatusFieldPatchCount, podStatusFieldPatchCountTotal, "failed to patch all relevant Pod conditions")
|
||||
gomega.Expect(podStatusFieldPatchCount).To(gomega.Equal(podStatusFieldPatchCountTotal), "failed to patch all relevant Pod conditions")
|
||||
podStatusUpdate, err = f.ClientSet.CoreV1().Pods(testNamespaceName).UpdateStatus(ctx, &podStatusUpdated, metav1.UpdateOptions{})
|
||||
return err
|
||||
})
|
||||
@ -1034,7 +1034,7 @@ var _ = SIGDescribe("Pods", func() {
|
||||
podStatusFieldPatchCount++
|
||||
}
|
||||
}
|
||||
framework.ExpectEqual(podStatusFieldPatchCount, podStatusFieldPatchCountTotal, "failed to update PodStatus - field patch count doesn't match the total")
|
||||
gomega.Expect(podStatusFieldPatchCount).To(gomega.Equal(podStatusFieldPatchCountTotal), "failed to update PodStatus - field patch count doesn't match the total")
|
||||
|
||||
ginkgo.By("deleting the Pod via a Collection with a LabelSelector")
|
||||
preDeleteResourceVersion := podStatusUpdate.ResourceVersion
|
||||
@ -1119,8 +1119,8 @@ var _ = SIGDescribe("Pods", func() {
|
||||
[]byte(`{"metadata":{"annotations":{"patchedstatus":"true"}},"status":`+string(pStatusJSON)+`}`),
|
||||
metav1.PatchOptions{}, "status")
|
||||
framework.ExpectNoError(err, "failed to patch pod: %q", podName)
|
||||
framework.ExpectEqual(pStatus.Status.Message, "Patched by e2e test", fmt.Sprintf("Status.Message for %q was %q but expected it to be \"Patched by e2e test\"", podName, pStatus.Status.Message))
|
||||
framework.ExpectEqual(pStatus.Status.Reason, "E2E", fmt.Sprintf("Status.Reason for %q was %q but expected it to be \"E2E\"", podName, pStatus.Status.Reason))
|
||||
gomega.Expect(pStatus.Status.Message).To(gomega.Equal("Patched by e2e test"), "Status.Message for %q was %q but expected it to be \"Patched by e2e test\"", podName, pStatus.Status.Message)
|
||||
gomega.Expect(pStatus.Status.Reason).To(gomega.Equal("E2E"), "Status.Reason for %q was %q but expected it to be \"E2E\"", podName, pStatus.Status.Reason)
|
||||
framework.Logf("Status Message: %q and Reason: %q", pStatus.Status.Message, pStatus.Status.Reason)
|
||||
})
|
||||
})
|
||||
|
@ -34,6 +34,7 @@ import (
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -59,7 +60,7 @@ var _ = SIGDescribe("PodTemplates", func() {
|
||||
LabelSelector: "podtemplate-static=true",
|
||||
})
|
||||
framework.ExpectNoError(err, "failed to list all PodTemplates")
|
||||
framework.ExpectEqual(len(podTemplateList.Items), 0, "unable to find templates")
|
||||
gomega.Expect(podTemplateList.Items).To(gomega.BeEmpty(), "unable to find templates")
|
||||
|
||||
// create a PodTemplate
|
||||
_, err = f.ClientSet.CoreV1().PodTemplates(testNamespaceName).Create(ctx, &v1.PodTemplate{
|
||||
@ -82,7 +83,7 @@ var _ = SIGDescribe("PodTemplates", func() {
|
||||
// get template
|
||||
podTemplateRead, err := f.ClientSet.CoreV1().PodTemplates(testNamespaceName).Get(ctx, podTemplateName, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err, "failed to get created PodTemplate")
|
||||
framework.ExpectEqual(podTemplateRead.ObjectMeta.Name, podTemplateName)
|
||||
gomega.Expect(podTemplateRead.ObjectMeta.Name).To(gomega.Equal(podTemplateName))
|
||||
|
||||
// patch template
|
||||
podTemplatePatch, err := json.Marshal(map[string]interface{}{
|
||||
@ -99,7 +100,7 @@ var _ = SIGDescribe("PodTemplates", func() {
|
||||
// get template (ensure label is there)
|
||||
podTemplateRead, err = f.ClientSet.CoreV1().PodTemplates(testNamespaceName).Get(ctx, podTemplateName, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err, "failed to get PodTemplate")
|
||||
framework.ExpectEqual(podTemplateRead.ObjectMeta.Labels["podtemplate"], "patched", "failed to patch template, new label not found")
|
||||
gomega.Expect(podTemplateRead.ObjectMeta.Labels).To(gomega.HaveKeyWithValue("podtemplate", "patched"), "failed to patch template, new label not found")
|
||||
|
||||
// delete the PodTemplate
|
||||
err = f.ClientSet.CoreV1().PodTemplates(testNamespaceName).Delete(ctx, podTemplateName, metav1.DeleteOptions{})
|
||||
@ -110,7 +111,7 @@ var _ = SIGDescribe("PodTemplates", func() {
|
||||
LabelSelector: "podtemplate-static=true",
|
||||
})
|
||||
framework.ExpectNoError(err, "failed to list PodTemplate")
|
||||
framework.ExpectEqual(len(podTemplateList.Items), 0, "PodTemplate list returned items, failed to delete PodTemplate")
|
||||
gomega.Expect(podTemplateList.Items).To(gomega.BeEmpty(), "PodTemplate list returned items, failed to delete PodTemplate")
|
||||
})
|
||||
|
||||
/*
|
||||
@ -149,7 +150,7 @@ var _ = SIGDescribe("PodTemplates", func() {
|
||||
})
|
||||
framework.ExpectNoError(err, "failed to get a list of pod templates")
|
||||
|
||||
framework.ExpectEqual(len(podTemplateList.Items), len(podTemplateNames), "looking for expected number of pod templates")
|
||||
gomega.Expect(podTemplateList.Items).To(gomega.HaveLen(len(podTemplateNames)), "looking for expected number of pod templates")
|
||||
|
||||
ginkgo.By("delete collection of pod templates")
|
||||
// delete collection
|
||||
@ -205,7 +206,7 @@ var _ = SIGDescribe("PodTemplates", func() {
|
||||
return err
|
||||
})
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectEqual(updatedPT.Annotations["updated"], "true", "updated object should have the applied annotation")
|
||||
gomega.Expect(updatedPT.Annotations).To(gomega.HaveKeyWithValue("updated", "true"), "updated object should have the applied annotation")
|
||||
framework.Logf("Found updated podtemplate annotation: %#v\n", updatedPT.Annotations["updated"])
|
||||
})
|
||||
|
||||
|
@ -118,14 +118,14 @@ while true; do sleep 1; done
|
||||
|
||||
ginkgo.By(fmt.Sprintf("Container '%s': should get the expected 'Ready' condition", testContainer.Name))
|
||||
isReady, err := terminateContainer.IsReady(ctx)
|
||||
framework.ExpectEqual(isReady, testCase.Ready)
|
||||
gomega.Expect(isReady).To(gomega.Equal(testCase.Ready))
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
status, err := terminateContainer.GetStatus(ctx)
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
ginkgo.By(fmt.Sprintf("Container '%s': should get the expected 'State'", testContainer.Name))
|
||||
framework.ExpectEqual(GetContainerState(status.State), testCase.State)
|
||||
gomega.Expect(GetContainerState(status.State)).To(gomega.Equal(testCase.State))
|
||||
|
||||
ginkgo.By(fmt.Sprintf("Container '%s': should be possible to delete [NodeConformance]", testContainer.Name))
|
||||
gomega.Expect(terminateContainer.Delete(ctx)).To(gomega.Succeed())
|
||||
@ -161,7 +161,7 @@ while true; do sleep 1; done
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
ginkgo.By("the container should be terminated")
|
||||
framework.ExpectEqual(GetContainerState(status.State), ContainerStateTerminated)
|
||||
gomega.Expect(GetContainerState(status.State)).To(gomega.Equal(ContainerStateTerminated))
|
||||
|
||||
ginkgo.By("the termination message should be set")
|
||||
framework.Logf("Expected: %v to match Container's Termination Message: %v --", expectedMsg, status.State.Terminated.Message)
|
||||
|
@ -41,6 +41,7 @@ import (
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = SIGDescribe("RuntimeClass", func() {
|
||||
@ -77,7 +78,7 @@ var _ = SIGDescribe("RuntimeClass", func() {
|
||||
// Check the pod is still not running
|
||||
p, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(ctx, pod.Name, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err, "could not re-read the pod after event (or timeout)")
|
||||
framework.ExpectEqual(p.Status.Phase, v1.PodPending, "Pod phase isn't pending")
|
||||
gomega.Expect(p.Status.Phase).To(gomega.Equal(v1.PodPending), "Pod phase isn't pending")
|
||||
})
|
||||
|
||||
// This test requires that the PreconfiguredRuntimeClassHandler has already been set up on nodes.
|
||||
@ -110,12 +111,12 @@ var _ = SIGDescribe("RuntimeClass", func() {
|
||||
pods, err := e2epod.WaitForPodsWithLabelScheduled(ctx, f.ClientSet, f.Namespace.Name, label)
|
||||
framework.ExpectNoError(err, "Failed to schedule Pod with the RuntimeClass")
|
||||
|
||||
framework.ExpectEqual(len(pods.Items), 1)
|
||||
gomega.Expect(pods.Items).To(gomega.HaveLen(1))
|
||||
scheduledPod := &pods.Items[0]
|
||||
framework.ExpectEqual(scheduledPod.Name, pod.Name)
|
||||
gomega.Expect(scheduledPod.Name).To(gomega.Equal(pod.Name))
|
||||
|
||||
// Overhead should not be set
|
||||
framework.ExpectEqual(len(scheduledPod.Spec.Overhead), 0)
|
||||
gomega.Expect(scheduledPod.Spec.Overhead).To(gomega.BeEmpty())
|
||||
})
|
||||
|
||||
/*
|
||||
@ -140,12 +141,12 @@ var _ = SIGDescribe("RuntimeClass", func() {
|
||||
pods, err := e2epod.WaitForPodsWithLabelScheduled(ctx, f.ClientSet, f.Namespace.Name, label)
|
||||
framework.ExpectNoError(err, "Failed to schedule Pod with the RuntimeClass")
|
||||
|
||||
framework.ExpectEqual(len(pods.Items), 1)
|
||||
gomega.Expect(pods.Items).To(gomega.HaveLen(1))
|
||||
scheduledPod := &pods.Items[0]
|
||||
framework.ExpectEqual(scheduledPod.Name, pod.Name)
|
||||
gomega.Expect(scheduledPod.Name).To(gomega.Equal(pod.Name))
|
||||
|
||||
framework.ExpectEqual(scheduledPod.Spec.Overhead[v1.ResourceCPU], resource.MustParse("10m"))
|
||||
framework.ExpectEqual(scheduledPod.Spec.Overhead[v1.ResourceMemory], resource.MustParse("1Mi"))
|
||||
gomega.Expect(scheduledPod.Spec.Overhead[v1.ResourceCPU]).To(gomega.Equal(resource.MustParse("10m")))
|
||||
gomega.Expect(scheduledPod.Spec.Overhead[v1.ResourceMemory]).To(gomega.Equal(resource.MustParse("1Mi")))
|
||||
})
|
||||
|
||||
/*
|
||||
@ -281,24 +282,24 @@ var _ = SIGDescribe("RuntimeClass", func() {
|
||||
ginkgo.By("getting")
|
||||
gottenRC, err := rcClient.Get(ctx, rc.Name, metav1.GetOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectEqual(gottenRC.UID, createdRC.UID)
|
||||
gomega.Expect(gottenRC.UID).To(gomega.Equal(createdRC.UID))
|
||||
|
||||
ginkgo.By("listing")
|
||||
rcs, err := rcClient.List(ctx, metav1.ListOptions{LabelSelector: "test=" + f.UniqueName})
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectEqual(len(rcs.Items), 3, "filtered list should have 3 items")
|
||||
gomega.Expect(rcs.Items).To(gomega.HaveLen(3), "filtered list should have 3 items")
|
||||
|
||||
ginkgo.By("patching")
|
||||
patchedRC, err := rcClient.Patch(ctx, createdRC.Name, types.MergePatchType, []byte(`{"metadata":{"annotations":{"patched":"true"}}}`), metav1.PatchOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectEqual(patchedRC.Annotations["patched"], "true", "patched object should have the applied annotation")
|
||||
gomega.Expect(patchedRC.Annotations).To(gomega.HaveKeyWithValue("patched", "true"), "patched object should have the applied annotation")
|
||||
|
||||
ginkgo.By("updating")
|
||||
csrToUpdate := patchedRC.DeepCopy()
|
||||
csrToUpdate.Annotations["updated"] = "true"
|
||||
updatedRC, err := rcClient.Update(ctx, csrToUpdate, metav1.UpdateOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectEqual(updatedRC.Annotations["updated"], "true", "updated object should have the applied annotation")
|
||||
gomega.Expect(updatedRC.Annotations).To(gomega.HaveKeyWithValue("updated", "true"), "updated object should have the applied annotation")
|
||||
|
||||
framework.Logf("waiting for watch events with expected annotations")
|
||||
for sawAdded, sawPatched, sawUpdated := false, false, false; !sawAdded && !sawPatched && !sawUpdated; {
|
||||
@ -346,14 +347,14 @@ var _ = SIGDescribe("RuntimeClass", func() {
|
||||
}
|
||||
rcs, err = rcClient.List(ctx, metav1.ListOptions{LabelSelector: "test=" + f.UniqueName})
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectEqual(len(rcs.Items), 2, "filtered list should have 2 items")
|
||||
gomega.Expect(rcs.Items).To(gomega.HaveLen(2), "filtered list should have 2 items")
|
||||
|
||||
ginkgo.By("deleting a collection")
|
||||
err = rcClient.DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{LabelSelector: "test=" + f.UniqueName})
|
||||
framework.ExpectNoError(err)
|
||||
rcs, err = rcClient.List(ctx, metav1.ListOptions{LabelSelector: "test=" + f.UniqueName})
|
||||
framework.ExpectNoError(err)
|
||||
framework.ExpectEqual(len(rcs.Items), 0, "filtered list should have 0 items")
|
||||
gomega.Expect(rcs.Items).To(gomega.BeEmpty(), "filtered list should have 0 items")
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -211,7 +212,7 @@ var _ = SIGDescribe("Secrets", func() {
|
||||
secretDecodedstring, err := base64.StdEncoding.DecodeString(string(secret.Data["key"]))
|
||||
framework.ExpectNoError(err, "failed to decode secret from Base64")
|
||||
|
||||
framework.ExpectEqual(string(secretDecodedstring), "value1", "found secret, but the data wasn't updated from the patch")
|
||||
gomega.Expect(string(secretDecodedstring)).To(gomega.Equal("value1"), "found secret, but the data wasn't updated from the patch")
|
||||
|
||||
ginkgo.By("deleting the secret using a LabelSelector")
|
||||
err = f.ClientSet.CoreV1().Secrets(f.Namespace.Name).DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{
|
||||
|
@ -405,7 +405,7 @@ var _ = SIGDescribe("Security Context", func() {
|
||||
ev, err := podClient.WaitForErrorEventOrSuccess(ctx, pod)
|
||||
framework.ExpectNoError(err)
|
||||
gomega.Expect(ev).NotTo(gomega.BeNil())
|
||||
framework.ExpectEqual(ev.Reason, events.FailedToCreateContainer)
|
||||
gomega.Expect(ev.Reason).To(gomega.Equal(events.FailedToCreateContainer))
|
||||
})
|
||||
ginkgo.It("should run with an image specified user ID", func(ctx context.Context) {
|
||||
name := "implicit-nonroot-uid"
|
||||
@ -423,7 +423,7 @@ var _ = SIGDescribe("Security Context", func() {
|
||||
ev, err := podClient.WaitForErrorEventOrSuccess(ctx, pod)
|
||||
framework.ExpectNoError(err)
|
||||
gomega.Expect(ev).NotTo(gomega.BeNil())
|
||||
framework.ExpectEqual(ev.Reason, events.FailedToCreateContainer)
|
||||
gomega.Expect(ev.Reason).To(gomega.Equal(events.FailedToCreateContainer))
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -104,7 +104,7 @@ var _ = SIGDescribe("Sysctls [LinuxOnly] [NodeConformance]", func() {
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
ginkgo.By("Checking that the pod succeeded")
|
||||
framework.ExpectEqual(pod.Status.Phase, v1.PodSucceeded)
|
||||
gomega.Expect(pod.Status.Phase).To(gomega.Equal(v1.PodSucceeded))
|
||||
|
||||
ginkgo.By("Getting logs from the pod")
|
||||
log, err := e2epod.GetPodLogs(ctx, f.ClientSet, f.Namespace.Name, pod.Name, pod.Spec.Containers[0].Name)
|
||||
@ -213,7 +213,7 @@ var _ = SIGDescribe("Sysctls [LinuxOnly] [NodeConformance]", func() {
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
ginkgo.By("Checking that the pod succeeded")
|
||||
framework.ExpectEqual(pod.Status.Phase, v1.PodSucceeded)
|
||||
gomega.Expect(pod.Status.Phase).To(gomega.Equal(v1.PodSucceeded))
|
||||
|
||||
ginkgo.By("Getting logs from the pod")
|
||||
log, err := e2epod.GetPodLogs(ctx, f.ClientSet, f.Namespace.Name, pod.Name, pod.Spec.Containers[0].Name)
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -288,7 +289,7 @@ var _ = SIGDescribe("EmptyDir volumes", func() {
|
||||
|
||||
ginkgo.By("Reading file content from the nginx-container")
|
||||
result := e2epod.ExecShellInContainer(f, pod.Name, busyBoxMainContainerName, fmt.Sprintf("cat %s", busyBoxMainVolumeFilePath))
|
||||
framework.ExpectEqual(result, message, "failed to match expected string %s with %s", message, resultString)
|
||||
gomega.Expect(result).To(gomega.Equal(message), "failed to match expected string %s with %s", message, resultString)
|
||||
})
|
||||
|
||||
/*
|
||||
@ -355,7 +356,7 @@ var _ = SIGDescribe("EmptyDir volumes", func() {
|
||||
|
||||
ginkgo.By("Reading empty dir size")
|
||||
result := e2epod.ExecShellInContainer(f, pod.Name, busyBoxMainContainerName, fmt.Sprintf("df | grep %s | awk '{print $2}'", busyBoxMainVolumeMountPath))
|
||||
framework.ExpectEqual(result, expectedResult, "failed to match expected string %s with %s", expectedResult, result)
|
||||
gomega.Expect(result).To(gomega.Equal(expectedResult), "failed to match expected string %s with %s", expectedResult, result)
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user