Copilot commented on code in PR #62747:
URL: https://github.com/apache/doris/pull/62747#discussion_r3129884776


##########
regression-test/suites/cloud_p0/multi_cluster/streaming_job/test_streaming_insert_job_compute_group_multi_cluster.groovy:
##########
@@ -0,0 +1,176 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.awaitility.Awaitility
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+suite("test_streaming_insert_job_compute_group_multi_cluster") {
+    def tableName = "test_sij_cg_mc_tbl"
+    def jobName   = "test_sij_cg_mc_job"
+
+    List<String> ipList = new ArrayList<>()
+    List<String> hbPortList = new ArrayList<>()
+    List<String> httpPortList = new ArrayList<>()
+    List<String> beUniqueIdList = new ArrayList<>()
+
+    String[] bes = context.config.multiClusterBes.split(',')
+    for (String values : bes) {
+        String[] beInfo = values.split(':')
+        ipList.add(beInfo[0])
+        hbPortList.add(beInfo[1])
+        httpPortList.add(beInfo[2])
+        beUniqueIdList.add(beInfo[3])
+    }
+    assert ipList.size() >= 2 : "need at least two BEs for multi-cluster test"
+
+    for (unique_id : beUniqueIdList) {
+        def resp = get_cluster.call(unique_id)
+        for (cluster : resp) {
+            if (cluster.type == "COMPUTE") {
+                drop_cluster.call(cluster.cluster_name, cluster.cluster_id)
+            }
+        }
+    }
+    sleep(20000)
+

Review Comment:
   The test uses a fixed `sleep(20000)` after dropping clusters. This can be 
flaky (too short under load) and slows the suite (too long when the cluster 
change is fast). Prefer the existing multi-cluster helper that waits until 
cluster membership changes (e.g. `wait_cluster_change()` used in other suites) 
so the test is both faster and more reliable.



##########
regression-test/suites/cloud_p0/multi_cluster/streaming_job/test_streaming_insert_job_compute_group_multi_cluster.groovy:
##########
@@ -0,0 +1,176 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.awaitility.Awaitility
+
+import static java.util.concurrent.TimeUnit.SECONDS
+
+suite("test_streaming_insert_job_compute_group_multi_cluster") {
+    def tableName = "test_sij_cg_mc_tbl"
+    def jobName   = "test_sij_cg_mc_job"
+
+    List<String> ipList = new ArrayList<>()
+    List<String> hbPortList = new ArrayList<>()
+    List<String> httpPortList = new ArrayList<>()
+    List<String> beUniqueIdList = new ArrayList<>()
+
+    String[] bes = context.config.multiClusterBes.split(',')
+    for (String values : bes) {
+        String[] beInfo = values.split(':')
+        ipList.add(beInfo[0])
+        hbPortList.add(beInfo[1])
+        httpPortList.add(beInfo[2])
+        beUniqueIdList.add(beInfo[3])
+    }
+    assert ipList.size() >= 2 : "need at least two BEs for multi-cluster test"
+
+    for (unique_id : beUniqueIdList) {
+        def resp = get_cluster.call(unique_id)
+        for (cluster : resp) {
+            if (cluster.type == "COMPUTE") {
+                drop_cluster.call(cluster.cluster_name, cluster.cluster_id)
+            }
+        }
+    }
+    sleep(20000)
+
+    def cgA = "sij_cg_a"
+    def cgB = "sij_cg_b"
+    add_cluster.call(beUniqueIdList[0], ipList[0], hbPortList[0], cgA, 
"sij_cg_a_id")
+    add_cluster.call(beUniqueIdList[1], ipList[1], hbPortList[1], cgB, 
"sij_cg_b_id")
+    sleep(20000)
+
+    def result = sql "show clusters"

Review Comment:
   Same as above: using a fixed `sleep(20000)` after `add_cluster` is prone to 
timing flakes. Switching to a condition-based wait (e.g. 
`wait_cluster_change()` or polling `show clusters` until the expected clusters 
appear) will make this test more robust and reduce unnecessary delay.
   ```suggestion
   
       def result = null
       Awaitility.await().atMost(30, SECONDS).pollInterval(1, SECONDS).until {
           result = sql "show clusters"
           return result.size() == 2
       }
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertTask.java:
##########
@@ -86,6 +91,11 @@ public void before() throws Exception {
         this.startTimeMs = System.currentTimeMillis();
         ctx = InsertTask.makeConnectContext(userIdentity, currentDb);
         
ctx.setSessionVariable(jobProperties.getSessionVariable(ctx.getSessionVariable()));
+        // apply after session merge so compute_group wins over 
session.cloud_cluster
+        if (Config.isCloudMode() && StringUtils.isNotEmpty(cloudCluster)) {
+            ctx.setCloudCluster(cloudCluster);
+            ctx.getSessionVariable().setCloudCluster(cloudCluster);

Review Comment:
   `ConnectContext.setCloudCluster()` already updates the session variable (it 
delegates to `getSessionVariable().setCloudCluster(...)`). Setting both 
`ctx.setCloudCluster(cloudCluster)` and 
`ctx.getSessionVariable().setCloudCluster(cloudCluster)` is redundant and can 
be simplified to a single call to avoid divergence if `setCloudCluster()` 
behavior changes later.
   ```suggestion
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to