Skip to content

Commit 7c16ded

Browse files
committed
Add Network Policy to e2e test bundles
Adds a Netwok Policy to the end-to-end test bundles and adds a check to the tests that the Network Policy resources are created. Signed-off-by: Tayler Geiger <tayler@redhat.com>
1 parent 7d4414b commit 7c16ded

File tree

6 files changed

+70
-0
lines changed

6 files changed

+70
-0
lines changed

hack/test/pre-upgrade-setup.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ rules:
102102
- "watch"
103103
- "bind"
104104
- "escalate"
105+
- apiGroups:
106+
- networking.k8s.io
107+
resources:
108+
- networkpolicies
109+
verbs:
110+
- get
111+
- list
112+
- create
113+
- update
114+
- delete
105115
- apiGroups:
106116
- "olm.operatorframework.io"
107117
resources:

test/e2e/cluster_extension_install_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/stretchr/testify/assert"
1212
"github.com/stretchr/testify/require"
1313
corev1 "k8s.io/api/core/v1"
14+
networkingv1 "k8s.io/api/networking/v1"
1415
rbacv1 "k8s.io/api/rbac/v1"
1516
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1617
"k8s.io/apimachinery/pkg/api/errors"
@@ -154,6 +155,23 @@ func createClusterRoleAndBindingForSA(ctx context.Context, name string, sa *core
154155
"escalate",
155156
},
156157
},
158+
{
159+
APIGroups: []string{
160+
"networking.k8s.io",
161+
},
162+
Resources: []string{
163+
"networkpolicies",
164+
},
165+
Verbs: []string{
166+
"get",
167+
"list",
168+
"watch",
169+
"create",
170+
"update",
171+
"patch",
172+
"delete",
173+
},
174+
},
157175
},
158176
}
159177
err := c.Create(ctx, cr)
@@ -377,6 +395,12 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
377395
assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle)
378396
}
379397
}, pollDuration, pollInterval)
398+
399+
t.Log("By eventually creating the NetworkPolicy named 'test-operator-network-policy'")
400+
require.EventuallyWithT(t, func(ct *assert.CollectT) {
401+
var np networkingv1.NetworkPolicy
402+
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: "test-operator-network-policy", Namespace: ns.Name}, &np))
403+
}, pollDuration, pollInterval)
380404
})
381405
}
382406
}

testdata/images/bundles/test-operator/v1.0.0/manifests/testoperator.clusterserviceversion.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ spec:
9696
- update
9797
- patch
9898
- delete
99+
- apiGroups:
100+
- networking.k8s.io
101+
resources:
102+
- networkpolicies
103+
verbs:
104+
- get
105+
- list
106+
- create
107+
- update
108+
- delete
99109
- apiGroups:
100110
- coordination.k8s.io
101111
resources:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: test-operator-network-policy
5+
spec:
6+
podSelector: {}
7+
policyTypes:
8+
- Ingress

testdata/images/bundles/test-operator/v2.0.0/manifests/testoperator.clusterserviceversion.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ spec:
9696
- update
9797
- patch
9898
- delete
99+
- apiGroups:
100+
- networking.k8s.io
101+
resources:
102+
- networkpolicies
103+
verbs:
104+
- get
105+
- list
106+
- create
107+
- update
108+
- delete
99109
- apiGroups:
100110
- coordination.k8s.io
101111
resources:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: test-operator-network-policy
5+
spec:
6+
podSelector: {}
7+
policyTypes:
8+
- Ingress

0 commit comments

Comments
 (0)