This is an automated email from the ASF dual-hosted git repository.

leonard pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 83ee295ae04 [FLINK-32661][sql-gateway] Fix unstable 
OperationRelatedITCase.testOperationRelatedApis
83ee295ae04 is described below

commit 83ee295ae046bceebfa2dfb286afb20a814023e8
Author: Jiabao Sun <jiabao....@xtransfer.cn>
AuthorDate: Sun Oct 29 04:20:48 2023 -0500

    [FLINK-32661][sql-gateway] Fix unstable 
OperationRelatedITCase.testOperationRelatedApis
    
    This closes #23564.
---
 .../flink/table/gateway/rest/OperationRelatedITCase.java      | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git 
a/flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/rest/OperationRelatedITCase.java
 
b/flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/rest/OperationRelatedITCase.java
index a26799462da..b7e9e2fef4b 100644
--- 
a/flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/rest/OperationRelatedITCase.java
+++ 
b/flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/rest/OperationRelatedITCase.java
@@ -18,6 +18,7 @@
 
 package org.apache.flink.table.gateway.rest;
 
+import org.apache.flink.core.testutils.OneShotLatch;
 import org.apache.flink.runtime.rest.messages.EmptyMessageParameters;
 import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
 import org.apache.flink.table.gateway.api.operation.OperationHandle;
@@ -43,7 +44,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -119,6 +119,9 @@ class OperationRelatedITCase extends RestAPIITCaseBase {
         SessionHandle sessionHandle = new 
SessionHandle(UUID.fromString(sessionHandleId));
         
assertThat(SQL_GATEWAY_SERVICE_EXTENSION.getSessionManager().getSession(sessionHandle))
                 .isNotNull();
+
+        OneShotLatch startLatch = new OneShotLatch();
+        Thread main = Thread.currentThread();
         OperationHandle operationHandle =
                 SQL_GATEWAY_SERVICE_EXTENSION
                         .getService()
@@ -126,11 +129,15 @@ class OperationRelatedITCase extends RestAPIITCaseBase {
                                 sessionHandle,
                                 () -> {
                                     try {
-                                        TimeUnit.SECONDS.sleep(10);
+                                        startLatch.trigger();
+                                        // keep operation in RUNNING state in 
response to cancel
+                                        // or close operations.
+                                        main.join();
                                     } catch (InterruptedException ignored) {
                                     }
                                     return NotReadyResult.INSTANCE;
                                 });
+        startLatch.await();
         assertThat(operationHandle).isNotNull();
         return Arrays.asList(sessionHandleId, 
operationHandle.getIdentifier().toString());
     }

Reply via email to