File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
tests/integration/test_backup_restore_on_cluster Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 11from pathlib import Path
2- from typing import Callable , List
2+ from typing import List
33
44from helpers .cluster import ClickHouseCluster , ClickHouseInstance
55
66
77def generate_cluster_def (file : str , num_nodes : int ) -> str :
8+ # For multiple workers, it has race and sometimes errors out,
9+ # so we generate it once and reuse
810 path = (
911 Path (__file__ ).parent / f"_gen/cluster_{ Path (file ).stem } _{ num_nodes } _nodes.xml"
1012 )
11- path .parent .mkdir (parents = True , exist_ok = True )
1213 replicas = "\n " .join (
1314 f""" <replica>
1415 <host>node{ i } </host>
1516 <port>9000</port>
1617 </replica>"""
1718 for i in range (num_nodes )
1819 )
19- path .write_text (
20- encoding = "utf-8" ,
21- data = f"""<clickhouse>
20+ config = f"""<clickhouse>
2221 <remote_servers>
2322 <cluster>
2423 <shard>
2524{ replicas }
2625 </shard>
2726 </cluster>
2827 </remote_servers>
29- </clickhouse>""" ,
28+ </clickhouse>"""
29+ if path .is_file ():
30+ existing = path .read_text (encoding = "utf-8" )
31+ if existing == config :
32+ return str (path .absolute ())
33+ path .parent .mkdir (parents = True , exist_ok = True )
34+ path .write_text (
35+ encoding = "utf-8" ,
36+ data = config ,
3037 )
3138 return str (path .absolute ())
3239
You can’t perform that action at this time.
0 commit comments