-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): rewrite explain analyze graphical test
- Loading branch information
Showing
3 changed files
with
41 additions
and
68 deletions.
There are no files selected for viewing
51 changes: 0 additions & 51 deletions
51
tests/suites/1_stateful/02_query/02_0009_explain_profile.py
This file was deleted.
Oops, something went wrong.
19 changes: 2 additions & 17 deletions
19
tests/suites/1_stateful/02_query/02_0009_explain_profile.result
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 |
---|---|---|
@@ -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
39
tests/suites/1_stateful/02_query/02_0009_explain_profile.sh
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,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 | ||
|