@@ -114,6 +114,22 @@ def started_cluster():
114114 with_zookeeper = True ,
115115 stay_alive = True ,
116116 )
117+ cluster .add_instance (
118+ "c2.s0_0_0" ,
119+ main_configs = ["configs/cluster.xml" , "configs/named_collections.xml" ],
120+ user_configs = ["configs/users.xml" ],
121+ macros = {"replica" : "replica1" , "shard" : "shard1" },
122+ with_zookeeper = True ,
123+ stay_alive = True ,
124+ )
125+ cluster .add_instance (
126+ "c2.s0_0_1" ,
127+ main_configs = ["configs/cluster.xml" , "configs/named_collections.xml" ],
128+ user_configs = ["configs/users.xml" ],
129+ macros = {"replica" : "replica2" , "shard" : "shard1" },
130+ with_zookeeper = True ,
131+ stay_alive = True ,
132+ )
117133
118134 logging .info ("Starting cluster..." )
119135 cluster .start ()
@@ -1197,3 +1213,61 @@ def test_joins(started_cluster):
11971213 )
11981214 res = list (map (str .split , result8 .splitlines ()))
11991215 assert len (res ) == 25
1216+
1217+
1218+ def test_object_storage_remote_initiator (started_cluster ):
1219+ node = started_cluster .instances ["s0_0_0" ]
1220+
1221+ query_id = uuid .uuid4 ().hex
1222+ result = node .query (
1223+ f"""
1224+ SELECT * from s3Cluster(
1225+ 'cluster_remote',
1226+ 'http://minio1:9001/root/data/{{clickhouse,database}}/*', 'minio', '{ minio_secret_key } ', 'CSV',
1227+ 'name String, value UInt32, polygon Array(Array(Tuple(Float64, Float64)))') ORDER BY (name, value, polygon)
1228+ SETTINGS object_storage_remote_initiator=1
1229+ """ ,
1230+ query_id = query_id ,
1231+ )
1232+
1233+ assert result is not None
1234+
1235+ node .query ("SYSTEM FLUSH LOGS ON CLUSTER 'cluster_all'" )
1236+ queries = node .query (
1237+ f"""
1238+ SELECT count()
1239+ FROM clusterAllReplicas('cluster_all', system.query_log)
1240+ WHERE type='QueryFinish' AND initial_query_id='{ query_id } '
1241+ FORMAT TSV
1242+ """
1243+ ).splitlines ()
1244+
1245+ # initial node + describe table + remote initiator + 2 subqueries on replicas
1246+ assert queries == ["5" ]
1247+
1248+ query_id = uuid .uuid4 ().hex
1249+ result = node .query (
1250+ f"""
1251+ SELECT * from s3Cluster(
1252+ 'cluster_with_dots',
1253+ 'http://minio1:9001/root/data/{{clickhouse,database}}/*', 'minio', '{ minio_secret_key } ', 'CSV',
1254+ 'name String, value UInt32, polygon Array(Array(Tuple(Float64, Float64)))') ORDER BY (name, value, polygon)
1255+ SETTINGS object_storage_remote_initiator=1
1256+ """ ,
1257+ query_id = query_id ,
1258+ )
1259+
1260+ assert result is not None
1261+
1262+ node .query ("SYSTEM FLUSH LOGS ON CLUSTER 'cluster_all'" )
1263+ queries = node .query (
1264+ f"""
1265+ SELECT count()
1266+ FROM clusterAllReplicas('cluster_all', system.query_log)
1267+ WHERE type='QueryFinish' AND initial_query_id='{ query_id } '
1268+ FORMAT TSV
1269+ """
1270+ ).splitlines ()
1271+
1272+ # initial node + describe table + remote initiator + 2 subqueries on replicas
1273+ assert queries == ["5" ]
0 commit comments