From 9075f8ff59316f8f3a41a5fa4b448e9f98190039 Mon Sep 17 00:00:00 2001 From: Pete Wall Date: Mon, 28 Oct 2024 20:24:27 -0500 Subject: [PATCH] Introduce randomness to ensure that this particular run was successful Signed-off-by: Pete Wall --- .github/workflows/platform-test.yml | 7 +++++++ charts/k8s-monitoring/tests/platform/remote-config/.envrc | 1 + .../tests/platform/remote-config/test-manifest.yaml | 3 +++ .../tests/platform/remote-config/test-values.yaml | 4 +++- .../tests/platform/remote-config/test-variables.yaml | 8 ++++++++ .../tests/platform/remote-config/values.yaml | 2 ++ scripts/run-integration-test.sh | 2 +- 7 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 charts/k8s-monitoring/tests/platform/remote-config/test-variables.yaml diff --git a/.github/workflows/platform-test.yml b/.github/workflows/platform-test.yml index 0ae3f6e7d..980f56656 100644 --- a/.github/workflows/platform-test.yml +++ b/.github/workflows/platform-test.yml @@ -71,6 +71,12 @@ jobs: with: config: charts/k8s-monitoring/tests/integration/${{ matrix.test }}/cluster.yaml + - name: Random number + uses: yakubique/random-number@v1.1 + with: + min: 100000 + max: 999999 + - name: Run test env: CREATE_CLUSTER: "false" @@ -80,5 +86,6 @@ jobs: GRAFANA_CLOUD_METRICS_USERNAME: ${{ secrets.GRAFANA_CLOUD_METRICS_USERNAME }} GRAFANA_CLOUD_LOGS_USERNAME: ${{ secrets.GRAFANA_CLOUD_LOGS_USERNAME }} GRAFANA_CLOUD_RW_POLICY_TOKEN: ${{ secrets.GRAFANA_CLOUD_RW_POLICY_TOKEN }} + RANDOM_NUMBER: ${{ steps.random-number.outputs.number }} run: ./scripts/run-integration-test.sh "charts/k8s-monitoring/tests/platform/${{ matrix.test }}" diff --git a/charts/k8s-monitoring/tests/platform/remote-config/.envrc b/charts/k8s-monitoring/tests/platform/remote-config/.envrc index 1e08cc1de..f6d97b446 100644 --- a/charts/k8s-monitoring/tests/platform/remote-config/.envrc +++ b/charts/k8s-monitoring/tests/platform/remote-config/.envrc @@ -3,3 +3,4 @@ export GRAFANA_CLOUD_FLEET_MGMT_TOKEN=$(op --account grafana.1password.com read export GRAFANA_CLOUD_METRICS_USERNAME=$(op --account grafana.1password.com read "op://Kubernetes Monitoring/helmchart Prometheus/username") export GRAFANA_CLOUD_LOGS_USERNAME=$(op --account grafana.1password.com read "op://Kubernetes Monitoring/helmchart Loki/username") export GRAFANA_CLOUD_RW_POLICY_TOKEN=$(op --account grafana.1password.com read "op://Kubernetes Monitoring/helmchart Loki/password") +export RANDOM_NUMBER=$(shuf -i 100000-999999 -n 1) \ No newline at end of file diff --git a/charts/k8s-monitoring/tests/platform/remote-config/test-manifest.yaml b/charts/k8s-monitoring/tests/platform/remote-config/test-manifest.yaml index 2c2274f37..e0ea923c3 100644 --- a/charts/k8s-monitoring/tests/platform/remote-config/test-manifest.yaml +++ b/charts/k8s-monitoring/tests/platform/remote-config/test-manifest.yaml @@ -3,3 +3,6 @@ prerequisites: - type: manifest name: grafana-cloud-credentials file: charts/k8s-monitoring/tests/platform/remote-config/grafana-cloud-credentials.yaml + - type: manifest + name: test-variables + file: charts/k8s-monitoring/tests/platform/remote-config/test-variables.yaml diff --git a/charts/k8s-monitoring/tests/platform/remote-config/test-values.yaml b/charts/k8s-monitoring/tests/platform/remote-config/test-values.yaml index b6d9271ae..f2c47fd4e 100644 --- a/charts/k8s-monitoring/tests/platform/remote-config/test-values.yaml +++ b/charts/k8s-monitoring/tests/platform/remote-config/test-values.yaml @@ -3,6 +3,8 @@ tests: - envFrom: - secretRef: name: grafana-cloud-credentials + - configMapRef: + name: test-variables queries: - - query: alloy_build_info{cluster="remote-config-platform-test"} + - query: alloy_build_info{cluster="remote-config-platform-test", random="$RANDOM_NUMBER"} type: promql diff --git a/charts/k8s-monitoring/tests/platform/remote-config/test-variables.yaml b/charts/k8s-monitoring/tests/platform/remote-config/test-variables.yaml new file mode 100644 index 000000000..818f09630 --- /dev/null +++ b/charts/k8s-monitoring/tests/platform/remote-config/test-variables.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-variables +data: + CLUSTER: "remote-config-platform-test" + RANDOM_NUMBER: "$RANDOM_NUMBER" diff --git a/charts/k8s-monitoring/tests/platform/remote-config/values.yaml b/charts/k8s-monitoring/tests/platform/remote-config/values.yaml index 402a12335..763ee0938 100644 --- a/charts/k8s-monitoring/tests/platform/remote-config/values.yaml +++ b/charts/k8s-monitoring/tests/platform/remote-config/values.yaml @@ -16,3 +16,5 @@ alloy-metrics: envFrom: - secretRef: name: grafana-cloud-credentials + - configMapRef: + name: test-variables diff --git a/scripts/run-integration-test.sh b/scripts/run-integration-test.sh index 1df40b2de..ad08a89f0 100755 --- a/scripts/run-integration-test.sh +++ b/scripts/run-integration-test.sh @@ -119,6 +119,6 @@ helm upgrade --install k8smon "${PARENT_DIR}/charts/k8s-monitoring" -f "${values if [ -f "${testValuesFile}" ]; then echo "Deploying test chart..." - helm upgrade --install k8smon-test "${PARENT_DIR}/charts/k8s-monitoring-test" -f "${testValuesFile}" --wait + helm upgrade --install k8smon-test "${PARENT_DIR}/charts/k8s-monitoring-test" -f <(envsubst < "${testValuesFile}") --wait helm test k8smon-test --logs fi