End to end tests of metrics logging

This commit is contained in:
Zach Musgrave
2023-12-04 16:21:59 -08:00
parent f9e6922900
commit a7b31a3736
+27 -2
View File
@@ -17,9 +17,9 @@ teardown() {
cp -a $BATS_TEST_DIRNAME/helper/testEvents/* $BATS_TMPDIR/config-$$/.dolt/eventsData/
# kick off two child processes, one should lock the other out of the events dir
dolt send-metrics -output >file1.txt &
dolt send-metrics --output-format stdout >file1.txt &
pid1=$!
dolt send-metrics -output >file2.txt &
dolt send-metrics --output-format stdout >file2.txt &
pid2=$!
# wait for processes to finish
@@ -66,3 +66,28 @@ teardown() {
echo this block should not fire
return 1
}
@test "send-metrics: test event logging" {
DOLT_DISABLE_EVENT_FLUSH=true dolt sql -q "create table t1 (a int primary key, b int)"
DOLT_DISABLE_EVENT_FLUSH=true dolt sql -q "insert into t1 values (1, 2)"
DOLT_DISABLE_EVENT_FLUSH=true dolt ls
DOLT_DISABLE_EVENT_FLUSH=true dolt status
# output all the metrics data to stdout for examination
run dolt send-metrics --output-format stdout
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 4 ]
# output is random-ordered, so we have to search line in it
sql_count=$(echo "$output" | grep -o "type:SQL" | wc -l)
ls_count=$(echo "$output" | grep -o "type:LS" | wc -l)
status_count=$(echo "$output" | grep -o "type:STATUS" | wc -l)
[ "$sql_count" -eq 2 ]
[ "$ls_count" -eq 1 ]
[ "$status_count" -eq 1 ]
# send metrics should be empty after this, since it deletes all old metrics
run dolt send-metrics --output-format stdout
[ "$status" -eq 0 ]
[ "$output" == "" ]
}