Skip to content

Commit

Permalink
feat(test): rewrite explain analyze graphical test
Browse files Browse the repository at this point in the history
  • Loading branch information
Maricaya committed Oct 17, 2024
1 parent f887e7d commit 05c9112
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 68 deletions.
51 changes: 0 additions & 51 deletions tests/suites/1_stateful/02_query/02_0009_explain_profile.py

This file was deleted.

19 changes: 2 additions & 17 deletions tests/suites/1_stateful/02_query/02_0009_explain_profile.result
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
2
0
True
0
2
0
True
2
4
0
True
0
5
0
True
0
1
0
True
true
0

39 changes: 39 additions & 0 deletions tests/suites/1_stateful/02_query/02_0009_explain_profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
response=$(curl -s -u root: -XPOST "http://localhost:8000/v1/query" -H 'Content-Type: application/json' -d '{"sql": "explain analyze graphical select 1"}')

data=$(echo $response | jq -r '.data')

json_string=$(echo "$data" | jq -r '.[][]')
profiles=$(echo "$json_string" | jq -r '.profiles')

profile_count=$(echo "$profiles" | jq length)
# Check the number of profiles
echo $profile_count

# Initialize memory_usage, error_count, cpu_time
memory_usage=0
error_count=0
cpu_time=0

# Loop through profiles and calculate statistics
for i in $(seq 0 $((profile_count - 1))); do
profile=$(echo "$profiles" | jq ".[$i]")
statistics=$(echo "$profile" | jq '.statistics')
errors=$(echo "$profile" | jq '.errors')

# Check if statistics has enough data (17 elements)
if [ "$(echo "$statistics" | jq length)" -ge 17 ]; then
memory_usage=$((memory_usage + $(echo "$statistics" | jq '.[16]')))
cpu_time=$((cpu_time + $(echo "$statistics" | jq '.[0]')))
fi


# Count errors
error_count=$((error_count + $(echo "$errors" | jq length)))
done


echo $memory_usage
echo "$( [ "$cpu_time" -gt 0 ] && echo true || echo false )"
echo $error_count

0 comments on commit 05c9112

Please sign in to comment.