-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #848 from akrejcir/metrics-unit-tests
feat: Metrics unit tests
- Loading branch information
Showing
9 changed files
with
469 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
readonly PROMTOOL="$(dirname "$0")/../bin/promtool" | ||
|
||
function cleanup() { | ||
local cleanup_dir="${1:?}" | ||
rm -rf "${cleanup_dir}" | ||
} | ||
|
||
function main() { | ||
local prom_spec_dumper="${1:?}" | ||
local tests_file="${2:?}" | ||
local temp_dir | ||
|
||
temp_dir="$(mktemp --tmpdir --directory metrics_test_dir.XXXXX)" | ||
trap "cleanup ${temp_dir}" RETURN EXIT INT | ||
|
||
local rules_file="${temp_dir}/rules.json" | ||
local tests_copy="${temp_dir}/rules-test.yaml" | ||
|
||
"${prom_spec_dumper}" > "${rules_file}" | ||
cp "${tests_file}" "${tests_copy}" | ||
|
||
echo "INFO: Rules file content:" | ||
cat "${rules_file}" | ||
echo | ||
|
||
${PROMTOOL} check rules "${rules_file}" | ||
${PROMTOOL} test rules "${tests_copy}" | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.