Skip to content

Commit d945370

Browse files
authored
chore: Run Rollouts E2E tests in both namespace/cluster scoped (#823)
Signed-off-by: Jonathan West <[email protected]>
1 parent 70dbaac commit d945370

File tree

1 file changed

+69
-3
lines changed

1 file changed

+69
-3
lines changed

scripts/run-rollouts-e2e-tests.sh

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# The goal of this script is to run the Argo Rollouts operator tests from the argo-rollouts-manager repo against gitops-operator:
44
# - Runs the cluster-scoped/namespace-scoped E2E tests of the Argo Rollouts operator
55
# - Runs the upstream E2E tests from the argo-rollouts repo
6+
# - Run the OpenShift Routes plugin tests
67

78
set -ex
89

@@ -102,24 +103,79 @@ function enable_rollouts_cluster_scoped_namespaces() {
102103

103104
}
104105

106+
function enable_rollouts_namespace_scoped_namespaces() {
107+
108+
if ! [ -z $NON_OLM ]; then
109+
oc set env deployment openshift-gitops-operator-controller-manager -n openshift-gitops-operator CLUSTER_SCOPED_ARGO_ROLLOUTS_NAMESPACES=""
110+
111+
oc set env deployment openshift-gitops-operator-controller-manager -n openshift-gitops-operator NAMESPACE_SCOPED_ARGO_ROLLOUTS="true"
112+
113+
elif [ -z $CI ]; then
114+
115+
oc patch -n openshift-gitops-operator subscription openshift-gitops-operator \
116+
--type merge --patch '{"spec": {"config": {"env": [{"name": "CLUSTER_SCOPED_ARGO_ROLLOUTS_NAMESPACES", "value": ""}]}}}'
117+
118+
oc patch -n openshift-gitops-operator subscription openshift-gitops-operator \
119+
--type merge --patch '{"spec": {"config": {"env": [{"name": "NAMESPACE_SCOPED_ARGO_ROLLOUTS", "value": "true"}]}}}'
120+
121+
122+
else
123+
124+
oc patch -n openshift-gitops-operator subscription `subscription=gitops-operator- && oc get subscription --all-namespaces | grep $subscription | head -1 | awk '{print $2}'` \
125+
--type merge --patch '{"spec": {"config": {"env": [{"name": "CLUSTER_SCOPED_ARGO_ROLLOUTS_NAMESPACES", "value": ""}]}}}'
126+
127+
oc patch -n openshift-gitops-operator subscription `subscription=gitops-operator- && oc get subscription --all-namespaces | grep $subscription | head -1 | awk '{print $2}'` \
128+
--type merge --patch '{"spec": {"config": {"env": [{"name": "NAMESPACE_SCOPED_ARGO_ROLLOUTS", "value": "true"}]}}}'
129+
130+
fi
131+
132+
# Loop to wait until NAMESPACE_SCOPED_ARGO_ROLLOUTS is added to the OpenShift GitOps Operator Deployment
133+
for i in {1..30}; do
134+
if oc get deployment openshift-gitops-operator-controller-manager -n openshift-gitops-operator -o jsonpath='{.spec.template.spec.containers[0].env}' | grep -q '{"name":"NAMESPACE_SCOPED_ARGO_ROLLOUTS","value":"true"}'; then
135+
echo "NAMESPACE_SCOPED_ARGO_ROLLOUTS is now set"
136+
break
137+
else
138+
echo "Waiting for NAMESPACE_SCOPED_ARGO_ROLLOUTS to be set"
139+
sleep 5
140+
fi
141+
done
142+
143+
# Verify the variable is set
144+
if oc get deployment openshift-gitops-operator-controller-manager -n openshift-gitops-operator -o jsonpath='{.spec.template.spec.containers[0].env}' | grep -q '{"name":"NAMESPACE_SCOPED_ARGO_ROLLOUTS","value":"true"}'; then
145+
echo "NAMESPACE_SCOPED_ARGO_ROLLOUTS is set."
146+
else
147+
echo "ERROR: NAMESPACE_SCOPED_ARGO_ROLLOUTS was never set."
148+
exit 1
149+
fi
150+
151+
# Deployment is correct, now wait for Pods to start
152+
wait_until_pods_running "openshift-gitops-operator"
153+
154+
}
155+
156+
157+
105158
function disable_rollouts_cluster_scope_namespaces() {
106159

107160
# Remove the env var we previously added to operator
108161

109162
if ! [ -z $NON_OLM ]; then
110163

111164
oc set env deployment openshift-gitops-operator-controller-manager -n openshift-gitops-operator CLUSTER_SCOPED_ARGO_ROLLOUTS_NAMESPACES=null
112-
165+
166+
oc set env deployment openshift-gitops-operator-controller-manager -n openshift-gitops-operator NAMESPACE_SCOPED_ARGO_ROLLOUTS=null
167+
113168
elif [ -z $CI ]; then
114169

115170
oc patch -n openshift-gitops-operator subscription openshift-gitops-operator \
116171
--type json --patch '[{"op": "remove", "path": "/spec/config"}]'
172+
117173
else
118174

119175
oc patch -n openshift-gitops-operator subscription `subscription=gitops-operator- && oc get subscription --all-namespaces | grep $subscription | head -1 | awk '{print $2}'` \
120176
--type json --patch '[{"op": "remove", "path": "/spec/config"}]'
121-
fi
122177

178+
fi
123179

124180
# Loop to wait until CLUSTER_SCOPED_ARGO_ROLLOUTS_NAMESPACES is removed from the OpenShift GitOps Operator Deplyoment
125181
for i in {1..30}; do
@@ -172,9 +228,19 @@ git checkout $TARGET_ROLLOUT_MANAGER_COMMIT
172228
# 1) Run E2E tests from argo-rollouts-manager repo
173229
# We use 'DISABLE_METRICS=true' since metrics gathering only works when run directly via Rollouts E2E tests
174230

175-
DISABLE_METRICS=true make test-e2e
231+
DISABLE_METRICS=true make test-e2e-cluster-scoped
232+
233+
# Clean up old namespaces created by test
234+
# NOTE: remove this once this is handled by 'make test-e2e' in argo-rollouts-manager repo
235+
kubectl delete rolloutmanagers --all -n test-rom-ns-1 || true
176236

237+
enable_rollouts_namespace_scoped_namespaces
177238

239+
DISABLE_METRICS=true make test-e2e-namespace-scoped
240+
241+
# Enable cluster scoped again, so we can run upstream Rollouts E2E tests
242+
243+
enable_rollouts_cluster_scoped_namespaces
178244

179245
# Clean up old namespaces created by test
180246
# NOTE: remove this once this is handled by 'make test-e2e' in argo-rollouts-manager repo

0 commit comments

Comments
 (0)