From 19db8f0f47ef74b7aab414581855631331a3f46b Mon Sep 17 00:00:00 2001 From: damien clochard Date: Sun, 14 Jan 2018 22:03:23 +0100 Subject: [PATCH] [ci] Add consistency tests --- t/consistency.t | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 t/consistency.t diff --git a/t/consistency.t b/t/consistency.t new file mode 100644 index 0000000..00efe18 --- /dev/null +++ b/t/consistency.t @@ -0,0 +1,38 @@ +#!/usr/bin/env bats +# -*- shell-script -*- + +setup() { +IN=t/fixtures/light.postgres.log.bz2 +BIN=$BATS_TMPDIR/out.bin +OUT=$BATS_TMPDIR/out.json +OUT_FROM_BIN=$BATS_TMPDIR/out_from_bin.json +./pgbadger $IN -o $OUT +./pgbadger $IN -o $BIN +./pgbadger $BIN --format=binary -o $OUT_FROM_BIN +} + +@test "Consistent count" { + # Assert out.html is not created in PWD. + N=$(jq .database_info.postgres.count < $OUT) + test $N -eq 629 + N=$(jq .database_info.postgres.count < $OUT_FROM_BIN) + test $N -eq 629 +} + + +@test "Consistent query_total" { + # Assert out.html is not created in PWD. + N=$(jq .overall_stat.histogram.query_total < $OUT) + test $N -eq 629 + N=$(jq .overall_stat.histogram.query_total < $OUT_FROM_BIN) + test $N -eq 629 +} + + +@test "Consistent peak.write" { + # Assert out.html is not created in PWD. + N=$(jq '.overall_stat.peak."2017-09-06 08:49:19".write' < $OUT) + test $N -eq 1 + N=$(jq '.overall_stat.peak."2017-09-06 08:49:19".write' < $OUT_FROM_BIN) + test $N -eq 1 +} \ No newline at end of file -- 2.40.0