Skip to content

Commit

Permalink
Introduce randomness to ensure that this particular run was successful
Browse files Browse the repository at this point in the history
Signed-off-by: Pete Wall <pete.wall@grafana.com>
  • Loading branch information
petewall committed Oct 29, 2024
1 parent c0c5186 commit 9075f8f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/platform-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 }}"
1 change: 1 addition & 0 deletions charts/k8s-monitoring/tests/platform/remote-config/.envrc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-variables
data:
CLUSTER: "remote-config-platform-test"
RANDOM_NUMBER: "$RANDOM_NUMBER"
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ alloy-metrics:
envFrom:
- secretRef:
name: grafana-cloud-credentials
- configMapRef:
name: test-variables
2 changes: 1 addition & 1 deletion scripts/run-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9075f8f

Please sign in to comment.