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 2019/09/24 10:18:02 UTC

[GitHub] [flink] TisonKun commented on a change in pull request #9719: [FLINK-14010][coordination] Shutdown cluster if ResourceManager terminated unexpectedly

TisonKun commented on a change in pull request #9719: [FLINK-14010][coordination] Shutdown cluster if ResourceManager terminated unexpectedly
URL: https://github.com/apache/flink/pull/9719#discussion_r327536119
 
 

 ##########
 File path: flink-runtime/src/test/java/org/apache/flink/runtime/entrypoint/component/DispatcherResourceManagerComponentTest.java
 ##########
 @@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.runtime.entrypoint.component;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.RestOptions;
+import org.apache.flink.runtime.minicluster.MiniCluster;
+import org.apache.flink.runtime.minicluster.MiniClusterConfiguration;
+import org.apache.flink.runtime.minicluster.RpcServiceSharing;
+import org.apache.flink.util.ExceptionUtils;
+import org.apache.flink.util.FlinkException;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit tests for {@link DispatcherResourceManagerComponent}.
+ */
+public class DispatcherResourceManagerComponentTest extends TestLogger {
+
+	@Test
+	public void testResourceManagerTerminateExceptionally() throws Exception {
+		final Configuration configuration = new Configuration();
+		configuration.setString(RestOptions.BIND_PORT, "0");
+
+		final MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder()
+			.setNumTaskManagers(1)
+			.setNumSlotsPerTaskManager(1)
+			.setRpcServiceSharing(RpcServiceSharing.SHARED)
+			.setConfiguration(configuration)
+			.build();
+
+		try (MiniCluster miniCluster = new MiniCluster(cfg)) {
+			miniCluster.start();
+
+			Collection<DispatcherResourceManagerComponent<?>> components = miniCluster.getDispatcherResourceManagerComponents();
+			assertThat(components.size(), is(1));
+
+			CompletableFuture<Throwable> future = new CompletableFuture<>();
+			DispatcherResourceManagerComponent<?> component = components.iterator().next();
+			component.getShutDownFuture().whenComplete(
+				(applicationStatus, throwable) -> {
+					if (throwable != null) {
+						future.complete(throwable);
+					}
+				}
+			);
+			component.getResourceManager().closeAsync();
+
+			String errorMessage = "ResourceManager was unexpectedly terminated while DispatcherResourceManagerComponent was running.";
+			Throwable t = future.get(2000L, TimeUnit.MILLISECONDS);
+			assertThat(ExceptionUtils.findThrowable(t, FlinkException.class).isPresent(), is(true));
+			assertThat(ExceptionUtils.findThrowableWithMessage(t, errorMessage).isPresent(), is(true));
+		}
 
 Review comment:
   Sounds reasonable. When I said "I'd like to introduce a test of it, but cannot find a good way." in pull request description actually I mean I cannot find a testing `DispatcherResourceManagerComponent` 😄 . However, now I think we can just use `DispatcherResourceManagerComponent` because it is well-design for testing also.
   
   If we eventually adopt the way changes in `DispatcherResourceManagerComponent`, I will do the update.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services