From 2c7e6dbec2791132f07c9239453b1f7adf03d6ef Mon Sep 17 00:00:00 2001 From: Reid Vandewiele Date: Wed, 11 Dec 2024 11:26:47 -0800 Subject: [PATCH] Change StormForge test from Job to CronJob --- .../StormForge/stormforge-test-cronjob.yaml | 67 +++++++++++++++++++ .../StormForge/stormforge-test-job.yaml | 64 ------------------ 2 files changed, 67 insertions(+), 64 deletions(-) create mode 100644 eks-anywhere-common/Testers/StormForge/stormforge-test-cronjob.yaml delete mode 100644 eks-anywhere-common/Testers/StormForge/stormforge-test-job.yaml diff --git a/eks-anywhere-common/Testers/StormForge/stormforge-test-cronjob.yaml b/eks-anywhere-common/Testers/StormForge/stormforge-test-cronjob.yaml new file mode 100644 index 00000000..016b5dc8 --- /dev/null +++ b/eks-anywhere-common/Testers/StormForge/stormforge-test-cronjob.yaml @@ -0,0 +1,67 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: stormforge-test-cronjob + namespace: stormforge +spec: + schedule: "30 */6 * * *" # Every six hours, at half-past. + jobTemplate: + spec: + backoffLimit: 4 + template: + spec: + activeDeadlineSeconds: 1800 + restartPolicy: Never + containers: + - name: stormforge-test-job + image: badouralix/curl-jq:alpine + env: + - name: CLI_VERSION + value: "5.1.9" + envFrom: + - secretRef: + name: stormforge-agent-auth + - secretRef: + name: stormforge-agent-env + command: + - '/bin/sh' + - '-c' + - | + # Setup: Fetch the StormForge CLI tool + while :; do + [ "$(uname -sm)" = "Linux aarch64" ] && arch=arm64 || arch=amd64 + curl -L "https://downloads.stormforge.io/stormforge-cli/v${CLI_VERSION}/stormforge_${CLI_VERSION}_linux_${arch}.tar.gz" | tar -xz + if [ $? = 0 ]; then + chmod a+x ./stormforge + mv ./stormforge /usr/local/bin + break + fi + sleep 5 + done + + # Tidy: delete any old and inactive eksa test clusters that may still be registered + stormforge get clusters --state Inactive -o json \ + | jq -r '.items[].name | select(. | test("^eksa-test-"))' \ + | xargs --no-run-if-empty stormforge delete clusters + + # Validate: when the cluster name has been registered, is not Inactive, and + # shows both products connected, then Optimize Live is working. + while :; do + echo "checking for stormforge-agent, stormforge-applier registration on $STORMFORGE_CLUSTER_NAME" + if stormforge get cluster "$STORMFORGE_CLUSTER_NAME" -o json \ + | jq -e 'all(.items[]; + (.status.phase == "Created") + and + all(.stormforge.products | map(.name); + any(index("stormforge-agent")) + and + any(index("stormforge-applier")) ))' + then + echo "successfully connected ${STORMFORGE_CLUSTER_NAME} to StormForge backend" + break + fi + sleep 5 + done + + # Success! (failure is handled by spec.activeDeadlineSeconds) + exit 0 diff --git a/eks-anywhere-common/Testers/StormForge/stormforge-test-job.yaml b/eks-anywhere-common/Testers/StormForge/stormforge-test-job.yaml deleted file mode 100644 index d809b42c..00000000 --- a/eks-anywhere-common/Testers/StormForge/stormforge-test-job.yaml +++ /dev/null @@ -1,64 +0,0 @@ ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: stormforge-test-job - namespace: stormforge -spec: - template: - spec: - activeDeadlineSeconds: 1800 - restartPolicy: Never - containers: - - name: stormforge-test-job - image: badouralix/curl-jq:alpine - env: - - name: CLI_VERSION - value: "5.1.9" - envFrom: - - secretRef: - name: stormforge-agent-auth - - secretRef: - name: stormforge-agent-env - command: - - '/bin/sh' - - '-c' - - | - # Setup: Fetch the StormForge CLI tool - while :; do - [ "$(uname -sm)" = "Linux aarch64" ] && arch=arm64 || arch=amd64 - curl -L "https://downloads.stormforge.io/stormforge-cli/v${CLI_VERSION}/stormforge_${CLI_VERSION}_linux_${arch}.tar.gz" | tar -xz - if [ $? = 0 ]; then - chmod a+x ./stormforge - mv ./stormforge /usr/local/bin - break - fi - sleep 5 - done - - # Tidy: delete any old and inactive eksa test clusters that may still be registered - stormforge get clusters --state Inactive -o json \ - | jq -r '.items[].name | select(. | test("^eksa-test-"))' \ - | xargs --no-run-if-empty stormforge delete clusters - - # Validate: when the cluster name has been registered, is not Inactive, and - # shows both products connected, then Optimize Live is working. - while :; do - echo "checking for stormforge-agent, stormforge-applier registration on $STORMFORGE_CLUSTER_NAME" - if stormforge get cluster "$STORMFORGE_CLUSTER_NAME" -o json \ - | jq -e 'all(.items[]; - (.status.phase == "Created") - and - all(.stormforge.products | map(.name); - any(index("stormforge-agent")) - and - any(index("stormforge-applier")) ))' - then - echo "successfully connected ${STORMFORGE_CLUSTER_NAME} to StormForge backend" - break - fi - sleep 5 - done - - # Success! (failure is handled by spec.activeDeadlineSeconds) - exit 0