@@ -18,9 +18,9 @@ def gen_insert_values(size):
1818 )
1919
2020
21- def randomize_disk_name (table_name , random_suffix_length = 5 ):
21+ def randomize_name (table_name , random_suffix_length = 8 ):
2222 letters = string .ascii_letters
23- return f"{ table_name } { '' .join (random .choice (letters ) for _ in range (random_suffix_length ))} "
23+ return f"{ table_name } _ { '' .join (random .choice (letters ) for _ in range (random_suffix_length ))} "
2424
2525
2626@pytest .fixture (scope = "module" , autouse = True )
@@ -69,19 +69,23 @@ def create_insert(node, table_name, insert_values):
6969
7070 node .query ("INSERT INTO {} VALUES {}" .format (table_name , insert_values ))
7171
72- create_insert (node1 , "test1" , gen_insert_values (1000 ))
72+ table1 = randomize_name ("t1" )
73+ create_insert (node1 , table1 , gen_insert_values (1000 ))
7374
74- assert int (node1 .query ("SELECT count(*) FROM test1 " )) == 1000
75+ assert int (node1 .query (f "SELECT count(*) FROM { table1 } " )) == 1000
7576
76- uuid1 = node1 .query ("SELECT uuid FROM system.tables WHERE table='test1'" ).strip ()
77+ uuid1 = node1 .query (
78+ f"SELECT uuid FROM system.tables WHERE table='{ table1 } '"
79+ ).strip ()
7780
78- node1 .query ("DETACH TABLE test1 SYNC" )
81+ node1 .query (f "DETACH TABLE { table1 } PERMANENTLY SYNC" )
7982
80- disk_name = randomize_disk_name ( "disk_ " )
83+ disk_name = randomize_name ( "disk " )
8184 node2 = cluster .instances ["node2" ]
82- node2 .query ("DROP TABLE IF EXISTS test2 SYNC" )
85+ table2 = randomize_name ("table2" )
86+ node2 .query (f"DROP TABLE IF EXISTS { table2 } SYNC" )
8387 node2 .query (
84- f"""CREATE TABLE test2 (id Int64, data String)
88+ f"""CREATE TABLE { table2 } (id Int64, data String)
8589 ENGINE=MergeTree()
8690 ORDER BY id
8791 PARTITION BY id%10
@@ -94,10 +98,10 @@ def create_insert(node, table_name, insert_values):
9498 """
9599 )
96100
97- rotated_name = "test1_rotated "
98- node2 .query (f"""DROP TABLE IF EXISTS { rotated_name } SYNC""" )
101+ rotated_table = f" { table1 } _rotated "
102+ node2 .query (f"""DROP TABLE IF EXISTS { rotated_table } SYNC""" )
99103 node2 .query (
100- f"""ATTACH TABLE { rotated_name } UUID '{ uuid1 } ' (id Int64, data String)
104+ f"""ATTACH TABLE { rotated_table } UUID '{ uuid1 } ' (id Int64, data String)
101105 ENGINE=MergeTree()
102106 ORDER BY id
103107 PARTITION BY id%10
@@ -113,21 +117,18 @@ def create_insert(node, table_name, insert_values):
113117 assert (
114118 int (
115119 node2 .query (
116- f"SELECT count(*) FROM { rotated_name } WHERE _partition_id = '0'"
120+ f"SELECT count(*) FROM { rotated_table } WHERE _partition_id = '0'"
117121 )
118122 )
119123 == 100
120124 )
121125
122- assert int (node2 .query (f"SELECT count(*) FROM { rotated_name } " )) == 1000
126+ assert int (node2 .query (f"SELECT count(*) FROM { rotated_table } " )) == 1000
123127
124- node2 .query (f"""ALTER TABLE { rotated_name } MOVE PARTITION '0' TO TABLE test2 """ )
128+ node2 .query (f"""ALTER TABLE { rotated_table } MOVE PARTITION '0' TO TABLE { table2 } """ )
125129
126- assert int (node2 .query (f"SELECT count(*) FROM { rotated_name } " )) == 900
127- assert int (node2 .query ("SELECT count(*) FROM test2 " )) == 100
130+ assert int (node2 .query (f"SELECT count(*) FROM { rotated_table } " )) == 900
131+ assert int (node2 .query (f "SELECT count(*) FROM { table2 } " )) == 100
128132
129- node2 .query (f"DROP TABLE { rotated_name } SYNC" )
130- node2 .query ("DROP TABLE test2 SYNC" )
131-
132- node1 .query (f"ATTACH TABLE test1" )
133- node1 .query (f"DROP TABLE test1 SYNC" )
133+ node2 .query (f"DROP TABLE { rotated_table } SYNC" )
134+ node2 .query (f"DROP TABLE { table2 } SYNC" )
0 commit comments