From 85cd4e1e6d77f82cd824a72dd7d60fab4ec6ef66 Mon Sep 17 00:00:00 2001 From: Catherine Fang Date: Tue, 2 Jan 2024 13:59:35 -0500 Subject: [PATCH] Add ci job for validating stable metrics Add ci job for validating stable metrics --- .github/workflows/ci.yml | 21 +++++++++++++++++++ Makefile | 3 +++ .../testdata/test-stable-metrics-list.yaml | 6 ++++++ tests/validate-stability.sh | 19 +++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 tests/stablemetrics/testdata/test-stable-metrics-list.yaml create mode 100644 tests/validate-stability.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 911ff7d0b1..9328a6f88f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -207,3 +207,24 @@ jobs: - name: End-to-end tests run: | make e2e + + ci-validate-stable-metrics-tests: + name: ci-validate-stable-metrics + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + + - name: Set up Go 1.x + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + id: go + + - name: Setup environment + run: | + make install-tools + + - name: End-to-end tests + run: | + make validate-stable-metrics diff --git a/Makefile b/Makefile index 016a024c24..68a005044f 100644 --- a/Makefile +++ b/Makefile @@ -129,6 +129,9 @@ clean: e2e: ./tests/e2e.sh +validate-stable-metrics: + ./tests/validate-stability.sh + generate: build-local @echo ">> generating docs" @./scripts/generate-help-text.sh diff --git a/tests/stablemetrics/testdata/test-stable-metrics-list.yaml b/tests/stablemetrics/testdata/test-stable-metrics-list.yaml new file mode 100644 index 0000000000..aa32b7bc1c --- /dev/null +++ b/tests/stablemetrics/testdata/test-stable-metrics-list.yaml @@ -0,0 +1,6 @@ +- name: kube_pod_init_container_status_restarts_total + help: The number of restarts for the init container. + type: Counter + stabilityLevel: STABLE + labels: + - container2 diff --git a/tests/validate-stability.sh b/tests/validate-stability.sh new file mode 100644 index 0000000000..028791c28b --- /dev/null +++ b/tests/validate-stability.sh @@ -0,0 +1,19 @@ +set -x +set -e + +temp_file=$(mktemp) +metric_file='internal/store/pod.go' + +go run \ + "tests/stablemetrics/main.go" \ + "tests/stablemetrics/decode_metric.go" \ + "tests/stablemetrics/find_stable_metric.go" \ + "tests/stablemetrics/error.go" \ + "tests/stablemetrics/metric.go" \ + -- \ + "${metric_file}" >"${temp_file}" + + +if diff -u "tests/stablemetrics/testdata/test-stable-metrics-list.yaml" "$temp_file"; then + echo -e "PASS metrics stability verification" +fi