Merge pull request #120408 from Penguin-zlh/cleanup-e2e-framework-ExpectNotEqual
e2e: stop using deprecated framework.ExpectNotEqual
This commit is contained in:
		@@ -34,6 +34,7 @@ import (
 | 
			
		||||
	admissionapi "k8s.io/pod-security-admission/api"
 | 
			
		||||
 | 
			
		||||
	"github.com/onsi/ginkgo/v2"
 | 
			
		||||
	"github.com/onsi/gomega"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var loggingSoak struct {
 | 
			
		||||
@@ -85,7 +86,7 @@ func RunLogPodsWithSleepOf(ctx context.Context, f *framework.Framework, sleep ti
 | 
			
		||||
	nodes, err := e2enode.GetReadySchedulableNodes(ctx, f.ClientSet)
 | 
			
		||||
	framework.ExpectNoError(err)
 | 
			
		||||
	totalPods := len(nodes.Items)
 | 
			
		||||
	framework.ExpectNotEqual(totalPods, 0)
 | 
			
		||||
	gomega.Expect(nodes.Items).ToNot(gomega.BeEmpty())
 | 
			
		||||
 | 
			
		||||
	kilobyte := strings.Repeat("logs-123", 128) // 8*128=1024 = 1KB of text.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1183,6 +1183,6 @@ func getNodeHostIP(ctx context.Context, f *framework.Framework, nodeName string)
 | 
			
		||||
	node, err := f.ClientSet.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
 | 
			
		||||
	framework.ExpectNoError(err)
 | 
			
		||||
	ips := e2enode.GetAddressesByTypeAndFamily(node, v1.NodeInternalIP, family)
 | 
			
		||||
	framework.ExpectNotEqual(len(ips), 0)
 | 
			
		||||
	gomega.Expect(ips).ToNot(gomega.BeEmpty())
 | 
			
		||||
	return ips[0]
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -328,7 +328,7 @@ var _ = SIGDescribe("SchedulerPreemption [Serial]", func() {
 | 
			
		||||
		podRes := v1.ResourceList{testExtendedResource: resource.MustParse("1")}
 | 
			
		||||
 | 
			
		||||
		ginkgo.By("Select a node to run the lower and higher priority pods")
 | 
			
		||||
		framework.ExpectNotEqual(len(nodeList.Items), 0, "We need at least one node for the test to run")
 | 
			
		||||
		gomega.Expect(nodeList.Items).ToNot(gomega.BeEmpty(), "We need at least one node for the test to run")
 | 
			
		||||
		node := nodeList.Items[0]
 | 
			
		||||
		nodeCopy := node.DeepCopy()
 | 
			
		||||
		nodeCopy.Status.Capacity[testExtendedResource] = resource.MustParse("1")
 | 
			
		||||
 
 | 
			
		||||
@@ -199,7 +199,7 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
 | 
			
		||||
		labelPod, err := cs.CoreV1().Pods(ns).Get(ctx, labelPodName, metav1.GetOptions{})
 | 
			
		||||
		framework.ExpectNoError(err)
 | 
			
		||||
		ginkgo.By("Verify the pod was scheduled to the expected node.")
 | 
			
		||||
		framework.ExpectNotEqual(labelPod.Spec.NodeName, nodeName)
 | 
			
		||||
		gomega.Expect(labelPod.Spec.NodeName).ToNot(gomega.Equal(nodeName))
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	ginkgo.It("Pod should be preferably scheduled to nodes pod can tolerate", func(ctx context.Context) {
 | 
			
		||||
 
 | 
			
		||||
@@ -167,7 +167,7 @@ var _ = sigDescribe("[Feature:Windows] SecurityContext", skipUnlessWindows(func(
 | 
			
		||||
		ginkgo.By("Waiting for pod to finish")
 | 
			
		||||
		event, err := e2epod.NewPodClient(f).WaitForErrorEventOrSuccess(ctx, podInvalid)
 | 
			
		||||
		framework.ExpectNoError(err)
 | 
			
		||||
		framework.ExpectNotEqual(event, nil, "event should not be empty")
 | 
			
		||||
		gomega.Expect(event).ToNot(gomega.BeNil(), "event should not be empty")
 | 
			
		||||
		framework.Logf("Got event: %v", event)
 | 
			
		||||
		expectedEventError := "container's runAsUserName (ContainerAdministrator) which will be regarded as root identity and will break non-root policy"
 | 
			
		||||
		gomega.Expect(event.Message).Should(gomega.ContainSubstring(expectedEventError), "Event error should indicate non-root policy caused container to not start")
 | 
			
		||||
@@ -185,7 +185,7 @@ var _ = sigDescribe("[Feature:Windows] SecurityContext", skipUnlessWindows(func(
 | 
			
		||||
		ginkgo.By("Waiting for pod to finish")
 | 
			
		||||
		event, err := e2epod.NewPodClient(f).WaitForErrorEventOrSuccess(ctx, podInvalid)
 | 
			
		||||
		framework.ExpectNoError(err)
 | 
			
		||||
		framework.ExpectNotEqual(event, nil, "event should not be empty")
 | 
			
		||||
		gomega.Expect(event).ToNot(gomega.BeNil(), "event should not be empty")
 | 
			
		||||
		framework.Logf("Got event: %v", event)
 | 
			
		||||
		expectedEventError := "container's runAsUserName (CONTAINERADMINISTRATOR) which will be regarded as root identity and will break non-root policy"
 | 
			
		||||
		gomega.Expect(event.Message).Should(gomega.ContainSubstring(expectedEventError), "Event error should indicate non-root policy caused container to not start")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user