twalthr commented on a change in pull request #7265: [FLINK-10964] SQL-client 
throws exception when paging through finished batch query
URL: https://github.com/apache/flink/pull/7265#discussion_r245620954
 
 

 ##########
 File path: 
flink-libraries/flink-sql-client/src/test/java/org/apache/flink/table/client/gateway/local/LocalExecutorITCase.java
 ##########
 @@ -503,4 +596,70 @@ private void verifySinkResult(String path) throws 
IOException {
                }
                return actualResults;
        }
+
+       private List<String> retrieveChangelogResultAfterJobFinished(
+               Executor executor,
+               SessionContext session,
+               String resultID,
+               ResultDescriptor descriptor) throws InterruptedException {
+
+               final List<String> actualResults = new ArrayList<>();
+               while (true) {
+                       Thread.sleep(50); // slow the processing down
+                       final TypedResult<List<Tuple2<Boolean, Row>>> result =
+                               executor.retrieveResultChanges(session, 
resultID);
+                       if (result.getType() == TypedResult.ResultType.PAYLOAD) 
{
+                               for (Tuple2<Boolean, Row> change : 
result.getPayload()) {
+                                       actualResults.add(change.toString());
+                               }
+                       } else if (result.getType() == 
TypedResult.ResultType.EOS) {
+                               Thread cliChangelogResultViewRunner = null;
+                               try {
+                                       cliChangelogResultViewRunner = new 
Thread(new TestingCliResultView(executor, session, descriptor, false));
+                                       cliChangelogResultViewRunner.start();
+
+                                       //wait enough time to trigger 
CliTableResultView#refresh call stopRetrieval method
+                                       Thread.sleep(5000);
+
+                                       //make sure the result is still in the 
ResultStore
+                                       final TypedResult<List<Tuple2<Boolean, 
Row>>> lastResult = executor.retrieveResultChanges(session, resultID);
+                                       
assertEquals(TypedResult.ResultType.EOS, lastResult.getType());
+                               } catch (SqlExecutionException e) {
+                                       
fail("retrieveChangelogResultAfterJobFinished failed : " + e.getMessage());
+                               } finally {
+                                       if (cliChangelogResultViewRunner != 
null && !cliChangelogResultViewRunner.isInterrupted()) {
+                                               
cliChangelogResultViewRunner.interrupt();
+                                       }
+                               }
+
+                               break;
+                       }
+               }
+               return actualResults;
+
+       }
+
+       private static final class TestingCliResultView implements Runnable {
+
+               private final CliResultView resultView;
 
 Review comment:
   This test is meant for testing the `LocalExecutor`. Please don't use CLI 
classes here for separation of concerns. The tests should only perform calls to 
the executor interface.
   
   To verify you changes feel free to create a new `CliResultViewTest` or 
something like that. The test coverage is still little for the SQL Client and 
needs to be improved.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to