You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/09/02 18:38:26 UTC

[GitHub] [flink] AHeise commented on a change in pull request #16951: [FLINK-23807][connector/testing-framework] Use numRestarts metric to detect TaskManager termination in MiniClusterTestEnvironment

AHeise commented on a change in pull request #16951:
URL: https://github.com/apache/flink/pull/16951#discussion_r701330242



##########
File path: flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkContainer.java
##########
@@ -77,6 +82,8 @@
     private final Path logBackupDir;
     private final int numTaskManagers;
 
+    private RestClusterClient<StandaloneClusterId> restClusterClient;

Review comment:
       `@Nullable`

##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/testutils/CommonTestUtils.java
##########
@@ -213,6 +216,19 @@ public static void waitForAllTaskRunning(
                 timeout);
     }
 
+    public static void waitForNoTaskRunning(
+            SupplierWithException<JobDetailsInfo, Exception> jobDetailsSupplier, Deadline timeout)
+            throws Exception {
+        waitUntilCondition(
+                () -> {
+                    final Map<ExecutionState, Integer> state =
+                            jobDetailsSupplier.get().getJobVerticesPerState();
+                    return state.get(ExecutionState.RUNNING).equals(0);

Review comment:
       Couldn't that potentially give an NPE? Maybe
   
   ```suggestion
                       return state.get(ExecutionState.RUNNING) == null || state.get(ExecutionState.RUNNING).equals(0);
   ```

##########
File path: flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkContainer.java
##########
@@ -126,6 +133,33 @@ public void afterTest(TestDescription description, Optional<Throwable> throwable
         temporaryFolder.delete();
     }
 
+    @Override
+    protected void doStart() {
+        super.doStart();
+        try {
+            final Configuration clientConfiguration = new Configuration();
+            clientConfiguration.set(RestOptions.ADDRESS, getHost());
+            clientConfiguration.set(RestOptions.PORT, getMappedPort(JOB_MANAGER_REST_PORT));
+            this.restClusterClient =
+                    new RestClusterClient<>(clientConfiguration, StandaloneClusterId.getInstance());
+        } catch (Exception e) {
+            throw new IllegalStateException(
+                    "Failed to create client for FlinkContainer cluster", e);
+        }

Review comment:
       How about lazy creation of the client in the getter? The field can serve as a cache.

##########
File path: flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkContainerTestEnvironment.java
##########
@@ -89,14 +87,16 @@ public void triggerTaskManagerFailover(JobClient jobClient, Runnable afterFailAc
         flinkContainer.restartTaskManager(
                 () -> {
                     try {
-                        CommonTestUtils.waitForJobStatus(
-                                jobClient,
-                                Arrays.asList(
-                                        JobStatus.FAILING, JobStatus.FAILED, JobStatus.RESTARTING),
-                                Deadline.fromNow(Duration.ofSeconds(30)));
+                        CommonTestUtils.waitForNoTaskRunning(
+                                () ->
+                                        flinkContainer
+                                                .getRestClusterClient()
+                                                .getJobDetails(jobClient.getJobID())
+                                                .get(),
+                                Deadline.fromNow(Duration.ofMinutes(1)));
                     } catch (Exception e) {
-                        throw new RuntimeException(
-                                "Error waiting for job entering failure status", e);
+                        throw new IllegalStateException(
+                                "Failed to wait for all task not running", e);
                     }

Review comment:
       I think this exception translation is not really necessary. Just change `public void restartTaskManager(Runnable afterFailAction)` to `RunnableWithException`
   If you want to keep it, then please change the message to be a bit more helpful.

##########
File path: flink-test-utils-parent/flink-connector-testing/src/main/java/org/apache/flink/connectors/test/common/environment/MiniClusterTestEnvironment.java
##########
@@ -84,10 +85,9 @@ public void triggerJobManagerFailover(JobClient jobClient, Runnable afterFailAct
     public void triggerTaskManagerFailover(JobClient jobClient, Runnable afterFailAction)
             throws Exception {
         terminateTaskManager();
-        CommonTestUtils.waitForJobStatus(
-                jobClient,
-                Arrays.asList(JobStatus.FAILING, JobStatus.FAILED, JobStatus.RESTARTING),
-                Deadline.fromNow(Duration.ofMinutes(5)));
+        CommonTestUtils.waitForNoTaskRunning(
+                () -> miniCluster.getRestClusterClient().getJobDetails(jobClient.getJobID()).get(),
+                Deadline.fromNow(Duration.ofMinutes(1)));

Review comment:
       I wouldn't lower the timeout here. There is nothing to be gained.

##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java
##########
@@ -138,7 +138,7 @@ public RestClient(Configuration configuration, Executor executor)
                 final OutboundChannelHandlerFactory factory = factories.next();
                 if (factory != null) {
                     outboundChannelHandlerFactories.add(factory);
-                    LOG.info("Loaded channel outbound factory: {}", factory);
+                    LOG.debug("Loaded channel outbound factory: {}", factory);

Review comment:
       Please add some description to the commit message to why this is a good change. I'm completely lost here.




-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org