diff --git a/test/e2e/gangway-bridge-template.yml b/test/e2e/gangway-bridge-template.yml new file mode 100644 index 00000000..ec701e6d --- /dev/null +++ b/test/e2e/gangway-bridge-template.yml @@ -0,0 +1,99 @@ +# THIS FILE IS GENERATED BY BOILERPLATE. DO NOT EDIT. +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + name: gangway-bridge-e2e +parameters: + - name: JOB_NAME + required: true + description: Prow periodic job name to trigger via Gangway + - name: POLL_INTERVAL + value: "60" + description: Seconds between status polls + - name: TIMEOUT + value: "7200" + description: Maximum seconds to wait for job completion + - name: JOB_ENVS + value: "" + description: Comma-separated KEY=VALUE pairs passed to the Prow job + - name: JOBID + generate: expression + from: "[0-9a-z]{7}" + - name: IMAGE_TAG + value: '' + required: true +objects: + - apiVersion: batch/v1 + kind: Job + metadata: + name: gangway-bridge-${IMAGE_TAG}-${JOBID} + spec: + backoffLimit: 0 + activeDeadlineSeconds: ${{TIMEOUT}} + template: + spec: + automountServiceAccountToken: false + restartPolicy: Never + containers: + - name: gangway-bridge + image: quay.io/openshift/origin-tools:latest + command: + - /bin/bash + - -ceu + - | + GW="https://gangway-ci.apps.ci.l2s4.p1.openshiftapps.com/v1/executions" + log() { echo "$(date +%H:%M:%S) $*" >&2; } + + [[ "${TIMEOUT}" =~ ^[1-9][0-9]*$ ]] || { log "ERROR: TIMEOUT must be a positive integer"; exit 1; } + [[ "${POLL_INTERVAL}" =~ ^[1-9][0-9]*$ ]] || { log "ERROR: POLL_INTERVAL must be a positive integer"; exit 1; } + + BODY='{"job_execution_type":"1"}' + if [[ -n "${JOB_ENVS:-}" ]]; then + ENVS=$(echo "${JOB_ENVS}" | jq -Rn '[inputs // input | split(",")[] | split("=") | {(.[0]): .[1:] | join("=")}] | add' <<< "${JOB_ENVS}") + BODY=$(jq -cn --argjson e "$ENVS" '{"job_execution_type":"1","pod_spec_options":{"envs":$e}}') + fi + + RESP=$(curl -sfSL --retry 3 --retry-delay 10 -X POST -H "Authorization: Bearer ${GANGWAY_TOKEN}" -H "Content-Type: application/json" -d "${BODY}" "${GW}/${JOB_NAME}") + ID=$(echo "$RESP" | jq -re .id) + PROW_URL="https://prow.ci.openshift.org/view/gs/test-platform-results/logs/${JOB_NAME}/${ID}" + log "Triggered ${JOB_NAME} -> ${ID}" + log "Prow logs: ${PROW_URL}" + + END=$((SECONDS + ${TIMEOUT})) + while [[ $SECONDS -lt $END ]]; do + sleep "${POLL_INTERVAL}" + S=$(curl -sfSL -H "Authorization: Bearer ${GANGWAY_TOKEN}" "${GW}/${ID}" | jq -r .job_status) || S=UNKNOWN + log "${S} ($((SECONDS))s)" + case $S in SUCCESS) log "Prow logs: ${PROW_URL}"; exit 0;; FAILURE|ABORTED|ERROR) log "Prow logs: ${PROW_URL}"; exit 1;; esac + done + log "Prow logs: ${PROW_URL}" + log "Timeout"; exit 1 + env: + - name: JOB_NAME + value: ${JOB_NAME} + - name: GANGWAY_TOKEN + valueFrom: + secretKeyRef: + name: gangway-api-token + key: token + - name: POLL_INTERVAL + value: ${POLL_INTERVAL} + - name: TIMEOUT + value: ${TIMEOUT} + - name: JOB_ENVS + value: ${JOB_ENVS} + resources: + requests: + cpu: "50m" + memory: "64Mi" + limits: + cpu: "100m" + memory: "128Mi" + securityContext: + runAsNonRoot: true + readOnlyRootFilesystem: true + allowPrivilegeEscalation: false + capabilities: + drop: ["ALL"] + seccompProfile: + type: RuntimeDefault