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 2020/08/18 11:19:40 UTC

[GitHub] [flink] xintongsong commented on a change in pull request #13186: [FLINK-18720][k8s] Migrate KubernetesResourceManager to the new KubernetesResourceManagerDriver

xintongsong commented on a change in pull request #13186:
URL: https://github.com/apache/flink/pull/13186#discussion_r472102547



##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/resourcemanager/active/ResourceManagerDriverTestBase.java
##########
@@ -0,0 +1,179 @@
+/*
+ * 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.resourcemanager.active;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.clusterframework.ApplicationStatus;
+import org.apache.flink.runtime.clusterframework.TaskExecutorProcessSpec;
+import org.apache.flink.runtime.clusterframework.TaskExecutorProcessUtils;
+import org.apache.flink.runtime.clusterframework.types.ResourceIDRetrievable;
+import org.apache.flink.runtime.concurrent.ScheduledExecutor;
+import org.apache.flink.runtime.concurrent.ScheduledExecutorServiceAdapter;
+import org.apache.flink.runtime.resourcemanager.WorkerResourceSpec;
+import org.apache.flink.util.TestLogger;
+import org.apache.flink.util.function.RunnableWithException;
+
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Common test cases for implementations of {@link ResourceManagerDriver}.
+ */
+public abstract class ResourceManagerDriverTestBase<WorkerType extends ResourceIDRetrievable> extends TestLogger {
+
+	protected static final long TIMEOUT_SEC = 5L;
+
+	protected static final TaskExecutorProcessSpec TASK_EXECUTOR_PROCESS_SPEC = TaskExecutorProcessUtils
+			.processSpecFromWorkerResourceSpec(new Configuration(), WorkerResourceSpec.ZERO);
+
+	private static final String MAIN_THREAD_NAME = "testing-rpc-main-thread";
+	private static final ScheduledExecutor MAIN_THREAD_EXECUTOR =
+			new ScheduledExecutorServiceAdapter(Executors.newSingleThreadScheduledExecutor(runnable -> new Thread(runnable, MAIN_THREAD_NAME)));
+
+	@Test
+	public void testInitialize() throws Exception {
+		final Context context = createContext();
+		context.runTest(context::validateInitialization);
+	}
+
+	@Test
+	public void testRecoverPreviousAttemptWorkers() throws Exception {
+		final CompletableFuture<Collection<WorkerType>> recoveredWorkersFuture = new CompletableFuture<>();
+		final Context context = createContext();
+		context.resourceEventHandlerBuilder.setOnPreviousAttemptWorkersRecoveredConsumer(recoveredWorkersFuture::complete);
+		context.preparePreviousAttemptWorkers();
+		context.runTest(() -> context.validateWorkersRecoveredFromPreviousAttempt(recoveredWorkersFuture.get(TIMEOUT_SEC, TimeUnit.SECONDS)));
+	}
+
+	@Test
+	public void testTerminate() throws Exception {
+		final Context context = createContext();
+		context.runTest(() -> {
+			context.getDriver().terminate();
+			context.validateTermination();
+		});
+	}
+
+	@Test
+	public void testDeregisterApplication() throws Exception {
+		final Context context = createContext();
+		context.runTest(() -> {
+			context.getDriver().deregisterApplication(ApplicationStatus.SUCCEEDED, null);

Review comment:
       True, it does no harm to be too careful.




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