|
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 |
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 |
@@ -175,6 +231,19 @@ git checkout $TARGET_ROLLOUT_MANAGER_COMMIT |
175 | 231 | DISABLE_METRICS=true make test-e2e |
176 | 232 |
|
177 | 233 |
|
| 234 | +make test-e2e-cluster-scoped |
| 235 | + |
| 236 | +# Clean up old namespaces created by test |
| 237 | +# NOTE: remove this once this is handled by 'make test-e2e' in argo-rollouts-manager repo |
| 238 | +kubectl delete rolloutmanagers --all -n test-rom-ns-1 || true |
| 239 | + |
| 240 | +enable_rollouts_namespace_scoped_namespaces |
| 241 | + |
| 242 | +make test-e2e-namespace-scoped |
| 243 | + |
| 244 | +# Enable cluster scoped again, so we can run upstream Rollouts E2E tests |
| 245 | + |
| 246 | +enable_rollouts_cluster_scoped_namespaces |
178 | 247 |
|
179 | 248 | # Clean up old namespaces created by test |
180 | 249 | # NOTE: remove this once this is handled by 'make test-e2e' in argo-rollouts-manager repo |
|
0 commit comments