| 1 | #!/usr/bin/env bats |
| 2 | |
| 3 | validate_metrics() { |
| 4 | fname="${1}" |
| 5 | params="${2}" |
| 6 | |
| 7 | curl -sS "http://localhost:19999/api/v1/allmetrics?format=prometheus&prefix=nd×tamps=no${params}" | |
| 8 | grep -E 'nd_system_|nd_cpu_|nd_system_|nd_net_|nd_disk_|nd_ip_|nd_ipv4_|nd_ipv6_|nd_mem_|nd_netdata_|nd_apps_|nd_services_' | |
| 9 | sed -ne 's/{.*//p' | sort | uniq > tests/exportings/new-${fname} |
| 10 | diff tests/exportings/${fname} tests/exportings/new-${fname} |
| 11 | rm tests/exportings/new-${fname} |
| 12 | } |
| 13 | |
| 14 | |
| 15 | if [ ! -f .gitignore ]; then |
| 16 | echo "Need to run as ./tests/exportings/$(basename "$0") from top level directory of git repository" >&2 |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | |
| 21 | @test "prometheus raw" { |
| 22 | validate_metrics prometheus-raw.txt "&data=raw" |
| 23 | } |
| 24 | |
| 25 | @test "prometheus avg" { |
| 26 | validate_metrics prometheus-avg.txt "" |
| 27 | } |
| 28 | |
| 29 | @test "prometheus avg oldunits" { |
| 30 | validate_metrics prometheus-avg-oldunits.txt "&oldunits=yes" |
| 31 | } |