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


##########
regression-test/suites/job_p0/streaming_job/cdc/test_streaming_mysql_job_ssl.groovy:
##########
@@ -0,0 +1,158 @@
+// 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_mysql_job_ssl", 
"p0,external,mysql,external_docker,external_docker_mysql,nondatalake") {
+    def jobName = "test_streaming_mysql_job_name_ssl"
+    def currentDb = (sql "select database()")[0][0]
+    def table1 = "user_info_mysql_normal1_ssl"
+    def mysqlDb = "test_cdc_db_ssl"
+
+    sql """DROP JOB IF EXISTS where jobname = '${jobName}'"""
+    sql """drop table if exists ${currentDb}.${table1} force"""
+
+
+    String enabled = context.config.otherConfigs.get("enableJdbcTest")
+    if (enabled != null && enabled.equalsIgnoreCase("true")) {
+        String mysql_port = context.config.otherConfigs.get("mysql_57_port");
+        String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+        String s3_endpoint = getS3Endpoint()
+        String bucket = getS3BucketName()
+        String driver_url = 
"https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.4.0.jar";
+
+        // create test
+        connect("root", "123456", 
"jdbc:mysql://${externalEnvIp}:${mysql_port}") {
+            sql """CREATE DATABASE IF NOT EXISTS ${mysqlDb}"""
+            sql """DROP TABLE IF EXISTS ${mysqlDb}.${table1}"""
+            sql """CREATE TABLE ${mysqlDb}.${table1} (
+                  `name` varchar(200) NOT NULL,
+                  `age` int DEFAULT NULL,
+                  PRIMARY KEY (`name`)
+                ) ENGINE=InnoDB"""
+            sql """INSERT INTO ${mysqlDb}.${table1} (name, age) VALUES ('A1', 
1);"""
+            sql """INSERT INTO ${mysqlDb}.${table1} (name, age) VALUES ('B1', 
2);"""
+        }
+
+        try {
+            sql """DROP FILE "mysql_ca.pem" FROM ${currentDb} PROPERTIES 
("catalog" = "streaming_job")"""
+        } catch (Exception ignored) {
+            // ignore
+        }
+
+        sql """CREATE FILE "mysql_ca.pem"
+            IN ${currentDb}
+            PROPERTIES
+            (
+                "url" = 
"https://qa-build.oss-cn-beijing.aliyuncs.com/jianxu/root.crt";,
+                "catalog" = "streaming_job"
+            )
+        """
+
+        sql """CREATE JOB ${jobName}
+                ON STREAMING
+                FROM MYSQL (
+                    "jdbc_url" = "jdbc:mysql://${externalEnvIp}:${mysql_port}",
+                    "driver_url" = "${driver_url}",
+                    "driver_class" = "com.mysql.cj.jdbc.Driver",
+                    "user" = "root",
+                    "password" = "123456",
+                    "database" = "${mysqlDb}",
+                    "include_tables" = "${table1}",
+                    "offset" = "initial",
+                    "ssl_mode" = "verify_ca",
+                    "ssl_rootcert" = "FILE:mysql_ca.pem"
+                )
+                TO DATABASE ${currentDb} (
+                  "table.create.properties.replication_num" = "1"
+                )
+            """
+        def showAllTables = sql """ show tables from ${currentDb}"""
+        log.info("showAllTables: " + showAllTables)
+        // check table created
+        def showTables = sql """ show tables from ${currentDb} like 
'${table1}'; """
+        assert showTables.size() == 1
+
+        // check job running
+        try {
+            Awaitility.await().atMost(300, SECONDS)
+                    .pollInterval(1, SECONDS).until(
+                    {
+                        def jobSuccendCount = sql """ select SucceedTaskCount 
from jobs("type"="insert") where Name = '${jobName}' and 
ExecuteType='STREAMING' """
+                        log.info("jobSuccendCount: " + jobSuccendCount)
+                        // check job status and succeed task count larger than 
2
+                        jobSuccendCount.size() == 1 && '2' <= 
jobSuccendCount.get(0).get(0)

Review Comment:
   The Awaitility condition compares succeed task count as Strings (`'2' <= 
jobSuccendCount.get(0).get(0)`), which is lexicographical in Groovy and can 
produce incorrect results (e.g., '10' is considered < '2'). Convert the value 
to a number and use a numeric comparison (e.g., `toLong() >= 2`) to avoid flaky 
waits/hangs.
   ```suggestion
                           if (jobSuccendCount.size() != 1) {
                               return false
                           }
                           long succeedTaskCount = 
jobSuccendCount.get(0).get(0).toString().toLong()
                           succeedTaskCount >= 2L
   ```



-- 
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