Merge pull request #119463 from Songjoy/cleanup-e2e-windows-framework-equal

e2e_windows: stop using deprecated framework.ExpectEqual
This commit is contained in:
Kubernetes Prow Robot 2023-08-30 00:36:47 -07:00 committed by GitHub
commit c723f46603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 19 deletions

View File

@ -724,15 +724,9 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
framework.Logf("Logs: %s\n", logs)
framework.ExpectEqual(
strings.Contains(logs, "calling /healthz"),
true,
"app logs should contain 'calling /healthz'")
gomega.Expect(logs).Should(gomega.ContainSubstring("calling /healthz"), "app logs should contain 'calling /healthz'")
framework.ExpectEqual(
strings.Contains(logs, "status=failed"),
false,
"app logs should not contain 'status=failed")
gomega.Expect(logs).ShouldNot(gomega.ContainSubstring("status=failed"), "app logs should not contain 'status=failed'")
})
ginkgo.It("should run as localgroup accounts", func(ctx context.Context) {
@ -802,12 +796,7 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
logs, err := e2epod.GetPodLogs(ctx, f.ClientSet, f.Namespace.Name, podName, "localgroup-container")
framework.ExpectNoError(err, "error retrieving container logs")
framework.Logf("Pod logs: %s", logs)
framework.ExpectEqual(
strings.Contains(
strings.ToLower(logs),
"nt authority"),
false,
"Container runs 'whoami' and logs should not contain 'nt authority'")
gomega.Expect(strings.ToLower(logs)).ShouldNot(gomega.ContainSubstring("nt authority"), "Container runs 'whoami' and logs should not contain 'nt authority'")
})
})

View File

@ -21,6 +21,7 @@ import (
"time"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/test/e2e/framework"
@ -140,6 +141,6 @@ var _ = SIGDescribe("[Feature:WindowsHyperVContainers] HyperV containers", func(
framework.Logf("Pod phase: %v\nlogs:\n%s", p.Status.Phase, logs)
}
framework.ExpectEqual(p.Status.Phase, v1.PodSucceeded, "pod should have succeeded")
gomega.Expect(p.Status.Phase).To(gomega.Equal(v1.PodSucceeded), "pod should have succeeded")
})
})

View File

@ -34,6 +34,7 @@ import (
admissionapi "k8s.io/pod-security-admission/api"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
)
var _ = SIGDescribe("[Feature:Windows] Kubelet-Stats [Serial]", func() {
@ -97,7 +98,7 @@ var _ = SIGDescribe("[Feature:Windows] Kubelet-Stats [Serial]", func() {
}
}
}
framework.ExpectEqual(statsChecked, 10, "Should find stats for 10 pods in kubelet stats")
gomega.Expect(statsChecked).To(gomega.Equal(10), "Should find stats for 10 pods in kubelet stats")
time.Sleep(5 * time.Second)
}
@ -188,7 +189,7 @@ var _ = SIGDescribe("[Feature:Windows] Kubelet-Stats", func() {
}
}
}
framework.ExpectEqual(statsChecked, 3, "Should find stats for 10 pods in kubelet stats")
gomega.Expect(statsChecked).To(gomega.Equal(3), "Should find stats for 3 pods in kubelet stats")
time.Sleep(5 * time.Second)
}

View File

@ -170,7 +170,7 @@ var _ = SIGDescribe("[Feature:Windows] SecurityContext", func() {
framework.ExpectNotEqual(event, nil, "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"
framework.ExpectEqual(true, strings.Contains(event.Message, expectedEventError), "Event error should indicate non-root policy caused container to not start")
gomega.Expect(event.Message).Should(gomega.ContainSubstring(expectedEventError), "Event error should indicate non-root policy caused container to not start")
})
ginkgo.It("should not be able to create pods with containers running as CONTAINERADMINISTRATOR when runAsNonRoot is true", func(ctx context.Context) {
@ -188,7 +188,7 @@ var _ = SIGDescribe("[Feature:Windows] SecurityContext", func() {
framework.ExpectNotEqual(event, nil, "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"
framework.ExpectEqual(true, strings.Contains(event.Message, expectedEventError), "Event error should indicate non-root policy caused container to not start")
gomega.Expect(event.Message).Should(gomega.ContainSubstring(expectedEventError), "Event error should indicate non-root policy caused container to not start")
})
})