@@ -2,7 +2,6 @@ package sequential
22
33import (
44 "context"
5- "time"
65
76 . "github.com/onsi/ginkgo/v2"
87 . "github.com/onsi/gomega"
@@ -22,7 +21,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
2221 fixture .EnsureSequentialCleanSlate ()
2322 })
2423
25- It ("verifies openshift-gitops: operator sets podSecurityLabelSync and OpenShift populates pod-security label keys " , func () {
24+ It ("verifies openshift-gitops: operator sets podSecurityLabelSync and OpenShift populates pod-security labels " , func () {
2625 gitopsNS := & corev1.Namespace {
2726 ObjectMeta : metav1.ObjectMeta {
2827 Name : "openshift-gitops" ,
@@ -34,27 +33,37 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
3433 Eventually (gitopsNS , "5m" , "5s" ).Should (
3534 k8sFixture .HaveLabelWithValue ("security.openshift.io/scc.podSecurityLabelSync" , "true" ))
3635
37- By ("OpenShift pod security label syncer sets pod-security.kubernetes.io/* (values depend on OCP version; only non-empty keys are asserted) " )
38- for _ , key := range []string {
36+ By ("OpenShift populates at least one pod-security.kubernetes.io/* label " )
37+ pssLabelKeys := []string {
3938 "pod-security.kubernetes.io/audit" ,
4039 "pod-security.kubernetes.io/audit-version" ,
4140 "pod-security.kubernetes.io/enforce" ,
4241 "pod-security.kubernetes.io/enforce-version" ,
4342 "pod-security.kubernetes.io/warn" ,
4443 "pod-security.kubernetes.io/warn-version" ,
45- } {
46- labelKey := key
47- Eventually (func () bool {
48- k8sClient , _ := fixtureUtils .GetE2ETestKubeClient ()
49- ns := & corev1.Namespace {}
50- if err := k8sClient .Get (context .Background (), client.ObjectKey {Name : "openshift-gitops" }, ns ); err != nil {
51- return false
52- }
53- if ns .Labels == nil {
54- return false
44+ }
45+ Eventually (func () bool {
46+ k8sClient , _ := fixtureUtils .GetE2ETestKubeClient ()
47+ ns := & corev1.Namespace {}
48+ if err := k8sClient .Get (context .Background (), client.ObjectKey {Name : "openshift-gitops" }, ns ); err != nil {
49+ return false
50+ }
51+ if ns .Labels == nil {
52+ return false
53+ }
54+ for _ , key := range pssLabelKeys {
55+ if ns .Labels [key ] != "" {
56+ return true
5557 }
56- return ns .Labels [labelKey ] != ""
57- }).WithTimeout (5 * time .Minute ).WithPolling (5 * time .Second ).Should (BeTrue (), "expected label %s to be set by OpenShift" , labelKey )
58+ }
59+ return false
60+ }, "5m" , "5s" ).Should (BeTrue (), "expected at least one pod-security.kubernetes.io/* label to be set by OpenShift" )
61+
62+ k8sClient , _ := fixtureUtils .GetE2ETestKubeClient ()
63+ ns := & corev1.Namespace {}
64+ Expect (k8sClient .Get (context .Background (), client.ObjectKey {Name : "openshift-gitops" }, ns )).To (Succeed ())
65+ for _ , key := range pssLabelKeys {
66+ GinkgoWriter .Printf ("observed namespace label %s=%q\n " , key , ns .Labels [key ])
5867 }
5968 })
6069
0 commit comments