|
3 | 3 | # The goal of this script is to run the Argo Rollouts operator tests from the argo-rollouts-manager repo against gitops-operator: |
4 | 4 | # - Runs the cluster-scoped/namespace-scoped E2E tests of the Argo Rollouts operator |
5 | 5 | # - Runs the upstream E2E tests from the argo-rollouts repo |
| 6 | +# - Run the OpenShift Routes plugin tests |
6 | 7 |
|
7 | 8 | set -ex |
8 | 9 |
|
@@ -102,24 +103,79 @@ function enable_rollouts_cluster_scoped_namespaces() { |
102 | 103 |
|
103 | 104 | } |
104 | 105 |
|
| 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 | + |
105 | 158 | function disable_rollouts_cluster_scope_namespaces() { |
106 | 159 |
|
107 | 160 | # Remove the env var we previously added to operator |
108 | 161 |
|
109 | 162 | if ! [ -z $NON_OLM ]; then |
110 | 163 |
|
111 | 164 | 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 | + |
113 | 168 | elif [ -z $CI ]; then |
114 | 169 |
|
115 | 170 | oc patch -n openshift-gitops-operator subscription openshift-gitops-operator \ |
116 | 171 | --type json --patch '[{"op": "remove", "path": "/spec/config"}]' |
| 172 | + |
117 | 173 | else |
118 | 174 |
|
119 | 175 | oc patch -n openshift-gitops-operator subscription `subscription=gitops-operator- && oc get subscription --all-namespaces | grep $subscription | head -1 | awk '{print $2}'` \ |
120 | 176 | --type json --patch '[{"op": "remove", "path": "/spec/config"}]' |
121 | | - fi |
122 | 177 |
|
| 178 | + fi |
123 | 179 |
|
124 | 180 | # Loop to wait until CLUSTER_SCOPED_ARGO_ROLLOUTS_NAMESPACES is removed from the OpenShift GitOps Operator Deplyoment |
125 | 181 | for i in {1..30}; do |
@@ -172,9 +228,19 @@ git checkout $TARGET_ROLLOUT_MANAGER_COMMIT |
172 | 228 | # 1) Run E2E tests from argo-rollouts-manager repo |
173 | 229 | # We use 'DISABLE_METRICS=true' since metrics gathering only works when run directly via Rollouts E2E tests |
174 | 230 |
|
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 |
176 | 236 |
|
| 237 | +enable_rollouts_namespace_scoped_namespaces |
177 | 238 |
|
| 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 |
178 | 244 |
|
179 | 245 | # Clean up old namespaces created by test |
180 | 246 | # NOTE: remove this once this is handled by 'make test-e2e' in argo-rollouts-manager repo |
|
0 commit comments