Skip to content

Commit af5e95e

Browse files
Merge pull request #1334 from hongkailiu/check-network-policy
OCPBUGS-77762: Add an e2e to check the default network polocy
2 parents 86b0305 + 5dcd2bc commit af5e95e

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

.openshift-tests-extension/openshift_payload_cluster-version-operator.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
"lifecycle": "blocking",
4242
"environmentSelector": {}
4343
},
44+
{
45+
"name": "[Jira:\"Cluster Version Operator\"] cluster-version-operator should have a network policy",
46+
"labels": {
47+
"OCPBUGS-77762": {}
48+
},
49+
"resources": {
50+
"isolation": {}
51+
},
52+
"source": "openshift:payload:cluster-version-operator",
53+
"lifecycle": "blocking",
54+
"environmentSelector": {}
55+
},
4456
{
4557
"name": "[Jira:\"Cluster Version Operator\"] cluster-version-operator should have correct runlevel and scc",
4658
"labels": {},

test/cvo/cvo.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ var _ = g.Describe(`[Jira:"Cluster Version Operator"] cluster-version-operator`,
5757
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to create Kubernetes client")
5858
})
5959

60+
g.It("should have a network policy", g.Label("OCPBUGS-77762"), func() {
61+
ctx := context.Background()
62+
err := util.SkipIfHypershift(ctx, restCfg)
63+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is HyperShift")
64+
err = util.SkipIfMicroshift(ctx, restCfg)
65+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to determine if cluster is MicroShift")
66+
67+
g.By("Checking if the default network policy exists on the namespace")
68+
if _, err := kubeClient.NetworkingV1().NetworkPolicies(external.DefaultCVONamespace).
69+
Get(ctx, "default-deny", metav1.GetOptions{}); err != nil {
70+
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to get the default network policy")
71+
}
72+
})
73+
6074
// Migrated from case NonHyperShiftHOST-Author:jiajliu-Low-46922-check runlevel and scc in cvo ns
6175
// Refer to https://github.com/openshift/openshift-tests-private/blob/40374cf20946ff03c88712839a5626af2c88ab31/test/extended/ota/cvo/cvo.go#L1081
6276
g.It("should have correct runlevel and scc", func() {

0 commit comments

Comments
 (0)