XComp commented on code in PR #18893:
URL: https://github.com/apache/flink/pull/18893#discussion_r1102708809


##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/api/TableITCase.scala:
##########
@@ -108,28 +108,32 @@ class TableITCase(tableEnvName: String, isStreaming: 
Boolean) extends AbstractTe
 
   @Test
   def testCollectWithClose(): Unit = {
-    val query =
+    val sourceDdl =
       """
-        |select id, concat(concat(`first`, ' '), `last`) as `full name`
-        |from MyTable where mod(id, 2) = 0
-      """.stripMargin
+        |create table unbounded_source (
+        |  id int
+        |) with (
+        |  'connector' = 'datagen',
+        |  'number-of-rows' = '10000',
+        |  'rows-per-second' = '1' -- slow producing speed to make sure that
+        |                          -- source is not finished when job is 
cancelled
+        |)
+        |""".stripMargin
+    tEnv.executeSql(sourceDdl)
+    val query = "select id from unbounded_source where mod(id, 2) = 0"
     val table = tEnv.sqlQuery(query)
     val tableResult = table.execute()
     assertTrue(tableResult.getJobClient.isPresent)
     assertEquals(ResultKind.SUCCESS_WITH_CONTENT, tableResult.getResultKind)
     val it = tableResult.collect()
     it.close()
-    val jobStatus =
-      try {
-        Some(tableResult.getJobClient.get().getJobStatus.get())
-      } catch {
-        // ignore the exception,
-        // because the MiniCluster maybe already been shut down when getting 
job status
-        case _: Throwable => None
-      }
-    if (jobStatus.isDefined) {
-      assertNotEquals(JobStatus.RUNNING, jobStatus.get)
-    }
+
+    // wait for mini cluster to shut down
+    val jobClient = tableResult.getJobClient.get()
+    val jobId = jobClient.getJobID
+    
AbstractTestBase.MINI_CLUSTER_RESOURCE.getClusterClient.requestJobResult(jobId).get()

Review Comment:
   ```suggestion
       MINI_CLUSTER_RESOURCE.getClusterClient.requestJobResult(jobId).get()
   ```
   nit: could you do a static import here to shorten the line?



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

Reply via email to