|
2 | 2 | apiVersion: tekton.dev/v1 |
3 | 3 | kind: Pipeline |
4 | 4 | metadata: |
5 | | - name: builds-e2e-tests |
| 5 | + name: e2e-openshift-builds |
6 | 6 | spec: |
7 | 7 | description: | |
8 | 8 | An integration test which provisions an ephemeral Hypershift cluster and deploys an Operator |
|
14 | 14 | type: string |
15 | 15 | - description: Namespace where the the Operator bundle will be deployed. |
16 | 16 | name: NAMESPACE |
17 | | - default: openshift-builds |
| 17 | + default: default |
18 | 18 | type: string |
19 | 19 | tasks: |
20 | 20 | - name: parse-metadata |
|
98 | 98 | value: "$(steps.pick-version.results.version)" |
99 | 99 | - name: instanceType |
100 | 100 | value: m5.2xlarge |
| 101 | + - name: imageContentSources |
| 102 | + value: | |
| 103 | + - source: registry.redhat.io/openshift-builds/openshift-builds-rhel9-operator |
| 104 | + mirrors: |
| 105 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-operator |
| 106 | + - source: registry.redhat.io/openshift-builds/openshift-builds-operator-bundle |
| 107 | + mirrors: |
| 108 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-operator-bundle |
| 109 | + - source: registry.redhat.io/openshift-builds/openshift-builds-controller-rhel9 |
| 110 | + mirrors: |
| 111 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-controller |
| 112 | + - source: registry.redhat.io/openshift-builds/openshift-builds-image-processing-rhel9 |
| 113 | + mirrors: |
| 114 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-image-processing |
| 115 | + - source: registry.redhat.io/openshift-builds/openshift-builds-image-bundler-rhel9 |
| 116 | + mirrors: |
| 117 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-image-bundler |
| 118 | + - source: registry.redhat.io/openshift-builds/openshift-builds-git-cloner-rhel9 |
| 119 | + mirrors: |
| 120 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-git-cloner |
| 121 | + - source: registry.redhat.io/openshift-builds/openshift-builds-waiters-rhel9 |
| 122 | + mirrors: |
| 123 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-waiter |
| 124 | + - source: registry.redhat.io/openshift-builds/openshift-builds-webhook-rhel9 |
| 125 | + mirrors: |
| 126 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-webhook |
| 127 | + - source: registry.redhat.io/openshift-builds/openshift-builds-shared-resource-rhel9 |
| 128 | + mirrors: |
| 129 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-shared-resource |
| 130 | + - source: registry.redhat.io/openshift-builds/openshift-builds-shared-resource-webhook-rhel9 |
| 131 | + mirrors: |
| 132 | + - quay.io/redhat-user-workloads/rh-openshift-builds-tenant/openshift-builds-shared-resource-webhook |
| 133 | +
|
101 | 134 | - name: deploy-operator |
102 | 135 | runAfter: |
103 | 136 | - provision-cluster |
@@ -146,6 +179,8 @@ spec: |
146 | 179 | - bundle |
147 | 180 | - --namespace |
148 | 181 | - "$(params.namespace)" |
| 182 | + - --timeout |
| 183 | + - "10m0s" |
149 | 184 | - "$(params.bundleImage)" |
150 | 185 | - name: e2e-test |
151 | 186 | description: Placeholder task that prints the Snapshot and outputs standard TEST_OUTPUT |
@@ -194,5 +229,84 @@ spec: |
194 | 229 | script: | |
195 | 230 | #!/usr/bin/env bash |
196 | 231 | set -ex -u -o pipefail |
| 232 | +
|
| 233 | + # TODO: remove this hack for getting cluster credentials for debugging |
| 234 | + cat /credentials/cluster-*-password |
197 | 235 | |
198 | | - oc get all -n openshift-builds |
| 236 | + NAMESPACE="default" # using default since openshift-builds NS is not available |
| 237 | + DEPLOYMENTS=("openshift-builds-operator" "openshift-pipelines-operator" "shipwright-build-controller" "shipwright-build-webhook" "tekton-operator-webhook" "shared-resource-csi-driver-webhook") |
| 238 | + BUILDS=("buildah-golang-buildrun") |
| 239 | +
|
| 240 | + oc get all -n $NAMESPACE |
| 241 | + for DEPLOYMENT in "${DEPLOYMENTS[@]}"; do |
| 242 | + oc wait deployment "$DEPLOYMENT" --namespace="$NAMESPACE" --for="condition=available" --timeout="180s" |
| 243 | + done |
| 244 | +
|
| 245 | + echo "All specified deployments are running and ready." |
| 246 | +
|
| 247 | + # Check running builds |
| 248 | + oc apply -f - <<EOF |
| 249 | + apiVersion: shipwright.io/v1beta1 |
| 250 | + kind: Build |
| 251 | + metadata: |
| 252 | + name: buildah-golang-build |
| 253 | + spec: |
| 254 | + source: |
| 255 | + type: Git |
| 256 | + git: |
| 257 | + url: https://github.com/redhat-openshift-builds/samples |
| 258 | + contextDir: buildah-build |
| 259 | + strategy: |
| 260 | + name: buildah |
| 261 | + kind: ClusterBuildStrategy |
| 262 | + paramValues: |
| 263 | + - name: dockerfile |
| 264 | + value: Dockerfile |
| 265 | + output: |
| 266 | + image: ttl.sh/build-examples-golang:30m |
| 267 | + EOF |
| 268 | +
|
| 269 | + oc apply -f - <<EOF |
| 270 | + apiVersion: shipwright.io/v1beta1 |
| 271 | + kind: BuildRun |
| 272 | + metadata: |
| 273 | + name: buildah-golang-buildrun |
| 274 | + spec: |
| 275 | + build: |
| 276 | + name: buildah-golang-build |
| 277 | + EOF |
| 278 | +
|
| 279 | + # Wait for builds to succeed (with a 10-minute timeout) |
| 280 | + TIMEOUT=600 # 10 minutes |
| 281 | + INTERVAL=30 # Check every 30 seconds |
| 282 | +
|
| 283 | + for BUILD in "${BUILDS[@]}"; do |
| 284 | + START_TIME=$(date +%s) |
| 285 | +
|
| 286 | + while true; do |
| 287 | + CURRENT_TIME=$(date +%s) |
| 288 | + ELAPSED=$((CURRENT_TIME - START_TIME)) |
| 289 | +
|
| 290 | + if [[ $ELAPSED -ge $TIMEOUT ]]; then |
| 291 | + echo "Timeout waiting for build $BUILD. Exiting..." |
| 292 | + exit 1 |
| 293 | + fi |
| 294 | +
|
| 295 | + STATUS=$(kubectl get buildrun "$BUILD" -n "$NAMESPACE" -o jsonpath="{.status.conditions[?(@.type=='Succeeded')].status}" 2>/dev/null || echo "Unknown") |
| 296 | +
|
| 297 | + if [[ "$STATUS" == "True" ]]; then |
| 298 | + echo "Build $BUILD succeeded!" |
| 299 | + break |
| 300 | + elif [[ "$STATUS" == "False" ]]; then |
| 301 | + echo "Build $BUILD failed!" |
| 302 | + exit 1 |
| 303 | + else |
| 304 | + echo "Waiting for build $BUILD to complete... ($ELAPSED/$TIMEOUT seconds)" |
| 305 | + sleep $INTERVAL |
| 306 | + fi |
| 307 | + done |
| 308 | + done |
| 309 | +
|
| 310 | + echo "All builds completed successfully." |
| 311 | +
|
| 312 | +
|
0 commit comments