Skip to content

Commit

Permalink
Add ci job for validating stable metrics
Browse files Browse the repository at this point in the history
Add ci job for validating stable metrics
  • Loading branch information
CatherineF-dev committed Jan 2, 2024
1 parent 44ee7e2 commit 85cd4e1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/stablemetrics/testdata/test-stable-metrics-list.yaml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions tests/validate-stability.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 85cd4e1

Please sign in to comment.