forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ClickHouse#58748 from ClickHouse/imp-01600_parts
Return and fix 01600_parts_states_metrics_long test
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
tests/queries/0_stateless/01600_parts_states_metrics_long.reference
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,4 @@ | ||
1 | ||
1 | ||
1 | ||
1 |
40 changes: 40 additions & 0 deletions
40
tests/queries/0_stateless/01600_parts_states_metrics_long.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,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
# shellcheck source=../shell_config.sh | ||
. "$CURDIR"/../shell_config.sh | ||
|
||
# NOTE: database = $CLICKHOUSE_DATABASE is unwanted | ||
verify_sql="SELECT | ||
(SELECT sumIf(value, metric = 'PartsActive'), sumIf(value, metric = 'PartsOutdated') FROM system.metrics) | ||
= (SELECT sum(active), sum(NOT active) FROM | ||
(SELECT active FROM system.parts UNION ALL SELECT active FROM system.projection_parts UNION ALL SELECT 1 FROM system.dropped_tables_parts))" | ||
|
||
# The query is not atomic - it can compare states between system.parts and system.metrics from different points in time. | ||
# So, there is inherent race condition. But it should get expected result eventually. | ||
# In case of test failure, this code will do infinite loop and timeout. | ||
verify() | ||
{ | ||
while true | ||
do | ||
result=$( $CLICKHOUSE_CLIENT -m --query="$verify_sql" ) | ||
[ "$result" = "1" ] && break | ||
sleep 0.1 | ||
done | ||
echo 1 | ||
} | ||
|
||
$CLICKHOUSE_CLIENT --database_atomic_wait_for_drop_and_detach_synchronously=1 --query="DROP TABLE IF EXISTS test_table" | ||
$CLICKHOUSE_CLIENT --query="CREATE TABLE test_table(data Date) ENGINE = MergeTree PARTITION BY toYear(data) ORDER BY data;" | ||
|
||
$CLICKHOUSE_CLIENT --query="INSERT INTO test_table VALUES ('1992-01-01')" | ||
verify | ||
|
||
$CLICKHOUSE_CLIENT --query="INSERT INTO test_table VALUES ('1992-01-02')" | ||
verify | ||
|
||
$CLICKHOUSE_CLIENT --query="OPTIMIZE TABLE test_table FINAL" | ||
verify | ||
|
||
$CLICKHOUSE_CLIENT --database_atomic_wait_for_drop_and_detach_synchronously=1 --query="DROP TABLE test_table" | ||
verify |