Make 03172_system_detached_tables parallelizable

This commit is contained in:
Raúl Marín 2024-08-06 15:11:21 +02:00
parent 996699c78c
commit a9b22a454d
3 changed files with 75 additions and 60 deletions

View File

@ -1,11 +1,11 @@
database atomic tests
test03172_system_detached_tables test_table 0
test03172_system_detached_tables test_table_perm 1
test03172_system_detached_tables test_table 0
test03172_system_detached_tables test_table_perm 1
test03172_system_detached_tables test_table 0
default_atomic test_table 0
default_atomic test_table_perm 1
default_atomic test_table 0
default_atomic test_table_perm 1
default_atomic test_table 0
-----------------------
database lazy tests
before attach test03172_system_detached_tables_lazy test_table 0
before attach test03172_system_detached_tables_lazy test_table_perm 1
before attach default_lazy test_table 0
before attach default_lazy test_table_perm 1
DROP TABLE

View File

@ -0,0 +1,68 @@
#!/bin/bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
DATABASE_ATOMIC="${CLICKHOUSE_DATABASE}_atomic"
DATABASE_LAZY="${CLICKHOUSE_DATABASE}_lazy"
$CLICKHOUSE_CLIENT --multiquery "
SELECT 'database atomic tests';
DROP DATABASE IF EXISTS ${DATABASE_ATOMIC};
CREATE DATABASE IF NOT EXISTS ${DATABASE_ATOMIC} ENGINE=Atomic;
CREATE TABLE ${DATABASE_ATOMIC}.test_table (n Int64) ENGINE=MergeTree ORDER BY n;
SELECT * FROM system.detached_tables WHERE database='${DATABASE_ATOMIC}';
DETACH TABLE ${DATABASE_ATOMIC}.test_table;
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='${DATABASE_ATOMIC}';
ATTACH TABLE ${DATABASE_ATOMIC}.test_table;
CREATE TABLE ${DATABASE_ATOMIC}.test_table_perm (n Int64) ENGINE=MergeTree ORDER BY n;
SELECT * FROM system.detached_tables WHERE database='${DATABASE_ATOMIC}';
DETACH TABLE ${DATABASE_ATOMIC}.test_table_perm PERMANENTLY;
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='${DATABASE_ATOMIC}';
DETACH TABLE ${DATABASE_ATOMIC}.test_table SYNC;
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='${DATABASE_ATOMIC}';
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='${DATABASE_ATOMIC}' AND table='test_table';
DROP DATABASE ${DATABASE_ATOMIC} SYNC;
"
$CLICKHOUSE_CLIENT --multiquery "
SELECT '-----------------------';
SELECT 'database lazy tests';
DROP DATABASE IF EXISTS ${DATABASE_LAZY};
CREATE DATABASE ${DATABASE_LAZY} Engine=Lazy(10);
CREATE TABLE ${DATABASE_LAZY}.test_table (number UInt64) engine=Log;
INSERT INTO ${DATABASE_LAZY}.test_table SELECT * FROM numbers(100);
DETACH TABLE ${DATABASE_LAZY}.test_table;
CREATE TABLE ${DATABASE_LAZY}.test_table_perm (number UInt64) engine=Log;
INSERT INTO ${DATABASE_LAZY}.test_table_perm SELECT * FROM numbers(100);
DETACH table ${DATABASE_LAZY}.test_table_perm PERMANENTLY;
SELECT 'before attach', database, table, is_permanently FROM system.detached_tables WHERE database='${DATABASE_LAZY}';
ATTACH TABLE ${DATABASE_LAZY}.test_table;
ATTACH TABLE ${DATABASE_LAZY}.test_table_perm;
SELECT 'after attach', database, table, is_permanently FROM system.detached_tables WHERE database='${DATABASE_LAZY}';
SELECT 'DROP TABLE';
DROP TABLE ${DATABASE_LAZY}.test_table SYNC;
DROP TABLE ${DATABASE_LAZY}.test_table_perm SYNC;
DROP DATABASE ${DATABASE_LAZY} SYNC;
"

View File

@ -1,53 +0,0 @@
-- Tags: no-parallel
SELECT 'database atomic tests';
DROP DATABASE IF EXISTS test03172_system_detached_tables;
CREATE DATABASE IF NOT EXISTS test03172_system_detached_tables ENGINE=Atomic;
CREATE TABLE test03172_system_detached_tables.test_table (n Int64) ENGINE=MergeTree ORDER BY n;
SELECT * FROM system.detached_tables WHERE database='test03172_system_detached_tables';
DETACH TABLE test03172_system_detached_tables.test_table;
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables';
ATTACH TABLE test03172_system_detached_tables.test_table;
CREATE TABLE test03172_system_detached_tables.test_table_perm (n Int64) ENGINE=MergeTree ORDER BY n;
SELECT * FROM system.detached_tables WHERE database='test03172_system_detached_tables';
DETACH TABLE test03172_system_detached_tables.test_table_perm PERMANENTLY;
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables';
DETACH TABLE test03172_system_detached_tables.test_table SYNC;
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables';
SELECT database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables' AND table='test_table';
DROP DATABASE test03172_system_detached_tables SYNC;
SELECT '-----------------------';
SELECT 'database lazy tests';
DROP DATABASE IF EXISTS test03172_system_detached_tables_lazy;
CREATE DATABASE test03172_system_detached_tables_lazy Engine=Lazy(10);
CREATE TABLE test03172_system_detached_tables_lazy.test_table (number UInt64) engine=Log;
INSERT INTO test03172_system_detached_tables_lazy.test_table SELECT * FROM numbers(100);
DETACH TABLE test03172_system_detached_tables_lazy.test_table;
CREATE TABLE test03172_system_detached_tables_lazy.test_table_perm (number UInt64) engine=Log;
INSERT INTO test03172_system_detached_tables_lazy.test_table_perm SELECT * FROM numbers(100);
DETACH table test03172_system_detached_tables_lazy.test_table_perm PERMANENTLY;
SELECT 'before attach', database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables_lazy';
ATTACH TABLE test03172_system_detached_tables_lazy.test_table;
ATTACH TABLE test03172_system_detached_tables_lazy.test_table_perm;
SELECT 'after attach', database, table, is_permanently FROM system.detached_tables WHERE database='test03172_system_detached_tables_lazy';
SELECT 'DROP TABLE';
DROP TABLE test03172_system_detached_tables_lazy.test_table SYNC;
DROP TABLE test03172_system_detached_tables_lazy.test_table_perm SYNC;
DROP DATABASE test03172_system_detached_tables_lazy SYNC;