Skip to content

Commit 000dd09

Browse files
trgeigeropenshift-merge-bot[bot]
authored andcommitted
UPSTREAM: 2078: 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 <[email protected]>
1 parent de72c1c commit 000dd09

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"gopkg.in/yaml.v2"
1717
appsv1 "k8s.io/api/apps/v1"
1818
corev1 "k8s.io/api/core/v1"
19+
networkingv1 "k8s.io/api/networking/v1"
1920
rbacv1 "k8s.io/api/rbac/v1"
2021
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2122
"k8s.io/apimachinery/pkg/api/errors"
@@ -162,6 +163,23 @@ func createClusterRoleAndBindingForSA(ctx context.Context, name string, sa *core
162163
"escalate",
163164
},
164165
},
166+
{
167+
APIGroups: []string{
168+
"networking.k8s.io",
169+
},
170+
Resources: []string{
171+
"networkpolicies",
172+
},
173+
Verbs: []string{
174+
"get",
175+
"list",
176+
"watch",
177+
"create",
178+
"update",
179+
"patch",
180+
"delete",
181+
},
182+
},
165183
},
166184
}
167185
err := c.Create(ctx, cr)
@@ -360,6 +378,11 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
360378
require.NoError(t, c.Get(context.Background(), types.NamespacedName{Namespace: ns.Name, Name: "test-configmap"}, &cm))
361379
require.Contains(t, cm.Annotations, "shouldNotTemplate")
362380
require.Contains(t, cm.Annotations["shouldNotTemplate"], "{{ $labels.namespace }}")
381+
t.Log("By eventually creating the NetworkPolicy named 'test-operator-network-policy'")
382+
require.EventuallyWithT(t, func(ct *assert.CollectT) {
383+
var np networkingv1.NetworkPolicy
384+
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: "test-operator-network-policy", Namespace: ns.Name}, &np))
385+
}, pollDuration, pollInterval)
363386
})
364387
}
365388
}

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
@@ -95,6 +95,16 @@ spec:
9595
- update
9696
- patch
9797
- delete
98+
- apiGroups:
99+
- networking.k8s.io
100+
resources:
101+
- networkpolicies
102+
verbs:
103+
- get
104+
- list
105+
- create
106+
- update
107+
- delete
98108
- apiGroups:
99109
- coordination.k8s.io
100110
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)