You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2018/10/05 16:14:30 UTC
[flink] branch master updated (f4aa31c -> f90f5e5)
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git.
from f4aa31c [hotfix] Remove unused cluster parameter from flink-contrib/docker-flink/docker-entrypoint.sh
new deef139 [FLINK-10427] [tests] Port JobSubmitTest to new code base
new f90f5e5 [FLINK-10427] [tests] Port JobSubmitTest#testFailureWhenJarBlobsMissing to new code base
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../flink/runtime/jobmanager/JobSubmitTest.java | 244 ---------------------
.../example/failing/JobSubmissionFailsITCase.java | 54 +++--
2 files changed, 33 insertions(+), 265 deletions(-)
delete mode 100644 flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/JobSubmitTest.java
[flink] 01/02: [FLINK-10427] [tests] Port JobSubmitTest to new code
base
Posted by tr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit deef139e02efc3b728654a202e2ad5247bc93a46
Author: tison <wa...@gmail.com>
AuthorDate: Thu Sep 27 01:48:46 2018 +0800
[FLINK-10427] [tests] Port JobSubmitTest to new code base
---
.../flink/runtime/jobmanager/JobSubmitTest.java | 244 ---------------------
1 file changed, 244 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/JobSubmitTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/JobSubmitTest.java
deleted file mode 100644
index ef493b9..0000000
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/JobSubmitTest.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * 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.jobmanager;
-
-import akka.actor.ActorSystem;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.JobManagerOptions;
-import org.apache.flink.runtime.akka.AkkaUtils;
-import org.apache.flink.runtime.akka.ListeningBehaviour;
-import org.apache.flink.runtime.blob.PermanentBlobKey;
-import org.apache.flink.runtime.checkpoint.CheckpointRetentionPolicy;
-import org.apache.flink.runtime.client.JobExecutionException;
-import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
-import org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedHaServices;
-import org.apache.flink.runtime.instance.ActorGateway;
-import org.apache.flink.runtime.jobgraph.JobGraph;
-import org.apache.flink.runtime.jobgraph.JobVertex;
-import org.apache.flink.runtime.jobgraph.JobVertexID;
-import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings;
-import org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration;
-import org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings;
-import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService;
-import org.apache.flink.runtime.messages.JobManagerMessages;
-import org.apache.flink.runtime.metrics.NoOpMetricRegistry;
-import org.apache.flink.runtime.testingUtils.TestingUtils;
-import org.apache.flink.runtime.testtasks.NoOpInvokable;
-import org.apache.flink.runtime.util.LeaderRetrievalUtils;
-import org.apache.flink.util.NetUtils;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import scala.Option;
-import scala.Tuple2;
-import scala.concurrent.Await;
-import scala.concurrent.Future;
-import scala.concurrent.duration.FiniteDuration;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Tests that the JobManager handles Jobs correctly that fail in
- * the initialization during the submit phase.
- */
-public class JobSubmitTest {
-
- private static final FiniteDuration timeout = new FiniteDuration(60000, TimeUnit.MILLISECONDS);
-
- private static ActorSystem jobManagerSystem;
- private static ActorGateway jmGateway;
- private static Configuration jmConfig;
- private static HighAvailabilityServices highAvailabilityServices;
-
- @BeforeClass
- public static void setupJobManager() {
- jmConfig = new Configuration();
-
- int port = NetUtils.getAvailablePort();
-
- jmConfig.setString(JobManagerOptions.ADDRESS, "localhost");
- jmConfig.setInteger(JobManagerOptions.PORT, port);
-
- scala.Option<Tuple2<String, Object>> listeningAddress = scala.Option.apply(new Tuple2<String, Object>("localhost", port));
- jobManagerSystem = AkkaUtils.createActorSystem(jmConfig, listeningAddress);
-
- highAvailabilityServices = new EmbeddedHaServices(TestingUtils.defaultExecutor());
-
- // only start JobManager (no ResourceManager)
- JobManager.startJobManagerActors(
- jmConfig,
- jobManagerSystem,
- TestingUtils.defaultExecutor(),
- TestingUtils.defaultExecutor(),
- highAvailabilityServices,
- NoOpMetricRegistry.INSTANCE,
- Option.empty(),
- JobManager.class,
- MemoryArchivist.class)._1();
-
- try {
- LeaderRetrievalService lrs = highAvailabilityServices.getJobManagerLeaderRetriever(HighAvailabilityServices.DEFAULT_JOB_ID);
-
- jmGateway = LeaderRetrievalUtils.retrieveLeaderGateway(
- lrs,
- jobManagerSystem,
- timeout
- );
- } catch (Exception e) {
- fail("Could not retrieve the JobManager gateway. " + e.getMessage());
- }
- }
-
- @AfterClass
- public static void teardownJobmanager() throws Exception {
- if (jobManagerSystem != null) {
- jobManagerSystem.terminate();
- }
-
- if (highAvailabilityServices != null) {
- highAvailabilityServices.closeAndCleanupAllData();
- highAvailabilityServices = null;
- }
- }
-
- @Test
- public void testFailureWhenJarBlobsMissing() {
- try {
- // create a simple job graph
- JobVertex jobVertex = new JobVertex("Test Vertex");
- jobVertex.setInvokableClass(NoOpInvokable.class);
- JobGraph jg = new JobGraph("test job", jobVertex);
-
- // add a reference to some non-existing BLOB to the job graph as a dependency
- jg.addUserJarBlobKey(new PermanentBlobKey());
-
- // submit the job
- Future<Object> submitFuture = jmGateway.ask(
- new JobManagerMessages.SubmitJob(
- jg,
- ListeningBehaviour.EXECUTION_RESULT),
- timeout);
- try {
- Await.result(submitFuture, timeout);
- }
- catch (JobExecutionException e) {
- // that is what we expect
- assertTrue(e.getCause() instanceof IOException);
- }
- catch (Exception e) {
- fail("Wrong exception type");
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- /**
- * Verifies a correct error message when vertices with master initialization
- * (input formats / output formats) fail.
- */
- @Test
- public void testFailureWhenInitializeOnMasterFails() {
- try {
- // create a simple job graph
-
- JobVertex jobVertex = new JobVertex("Vertex that fails in initializeOnMaster") {
-
- private static final long serialVersionUID = -3540303593784587652L;
-
- @Override
- public void initializeOnMaster(ClassLoader loader) throws Exception {
- throw new RuntimeException("test exception");
- }
- };
-
- jobVertex.setInvokableClass(NoOpInvokable.class);
- JobGraph jg = new JobGraph("test job", jobVertex);
-
- // submit the job
- Future<Object> submitFuture = jmGateway.ask(
- new JobManagerMessages.SubmitJob(
- jg,
- ListeningBehaviour.EXECUTION_RESULT),
- timeout);
- try {
- Await.result(submitFuture, timeout);
- }
- catch (JobExecutionException e) {
- // that is what we expect
- // test that the exception nesting is not too deep
- assertTrue(e.getCause() instanceof RuntimeException);
- }
- catch (Exception e) {
- fail("Wrong exception type");
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testAnswerFailureWhenSavepointReadFails() throws Exception {
- // create a simple job graph
- JobGraph jg = createSimpleJobGraph();
- jg.setSavepointRestoreSettings(SavepointRestoreSettings.forPath("pathThatReallyDoesNotExist..."));
-
- // submit the job
- Future<Object> submitFuture = jmGateway.ask(
- new JobManagerMessages.SubmitJob(jg, ListeningBehaviour.DETACHED), timeout);
- Object result = Await.result(submitFuture, timeout);
- assertEquals(JobManagerMessages.JobResultFailure.class, result.getClass());
- }
-
- private JobGraph createSimpleJobGraph() {
- JobVertex jobVertex = new JobVertex("Vertex");
-
- jobVertex.setInvokableClass(NoOpInvokable.class);
- List<JobVertexID> vertexIdList = Collections.singletonList(jobVertex.getID());
-
- JobGraph jg = new JobGraph("test job", jobVertex);
- jg.setSnapshotSettings(
- new JobCheckpointingSettings(
- vertexIdList,
- vertexIdList,
- vertexIdList,
- new CheckpointCoordinatorConfiguration(
- 5000,
- 5000,
- 0L,
- 10,
- CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION,
- true),
- null));
- return jg;
- }
-}
[flink] 02/02: [FLINK-10427] [tests] Port
JobSubmitTest#testFailureWhenJarBlobsMissing to new code base
Posted by tr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit f90f5e5832425f999c5ce564c25284b912ebab18
Author: Till Rohrmann <tr...@apache.org>
AuthorDate: Fri Oct 5 11:08:45 2018 +0200
[FLINK-10427] [tests] Port JobSubmitTest#testFailureWhenJarBlobsMissing to new code base
Port JobSubmitTest#testFailureWhenJarBlobsMissing to JobSubmissionFailureITCase#testMissingJarBlob.
This closes #6768.
---
.../example/failing/JobSubmissionFailsITCase.java | 54 +++++++++++++---------
1 file changed, 33 insertions(+), 21 deletions(-)
diff --git a/flink-tests/src/test/java/org/apache/flink/test/example/failing/JobSubmissionFailsITCase.java b/flink-tests/src/test/java/org/apache/flink/test/example/failing/JobSubmissionFailsITCase.java
index 66ffd5d..9a96297 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/example/failing/JobSubmissionFailsITCase.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/example/failing/JobSubmissionFailsITCase.java
@@ -22,6 +22,7 @@ package org.apache.flink.test.example.failing;
import org.apache.flink.client.program.ClusterClient;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.TaskManagerOptions;
+import org.apache.flink.runtime.blob.PermanentBlobKey;
import org.apache.flink.runtime.jobgraph.JobGraph;
import org.apache.flink.runtime.jobgraph.JobVertex;
import org.apache.flink.runtime.testtasks.NoOpInvokable;
@@ -35,9 +36,12 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import javax.annotation.Nonnull;
+
+import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Optional;
+import java.util.function.Predicate;
import static org.junit.Assert.fail;
@@ -92,29 +96,32 @@ public class JobSubmissionFailsITCase extends TestLogger {
failingJobVertex.setInvokableClass(NoOpInvokable.class);
final JobGraph failingJobGraph = new JobGraph("Failing testing job", failingJobVertex);
-
- ClusterClient<?> client = MINI_CLUSTER_RESOURCE.getClusterClient();
- client.setDetached(detached);
-
- try {
- client.submitJob(failingJobGraph, JobSubmissionFailsITCase.class.getClassLoader());
- fail("Job submission should have thrown an exception.");
- } catch (Exception e) {
- Optional<Throwable> expectedCause = ExceptionUtils.findThrowable(e,
- candidate -> "Test exception.".equals(candidate.getMessage()));
- if (!expectedCause.isPresent()) {
- throw e;
- }
- }
-
- client.setDetached(false);
- client.submitJob(getWorkingJobGraph(), JobSubmissionFailsITCase.class.getClassLoader());
+ runJobSubmissionTest(failingJobGraph, e ->
+ ExceptionUtils.findThrowable(
+ e,
+ candidate -> "Test exception.".equals(candidate.getMessage()))
+ .isPresent());
}
@Test
public void testSubmitEmptyJobGraph() throws Exception {
final JobGraph jobGraph = new JobGraph("Testing job");
+ runJobSubmissionTest(
+ jobGraph,
+ e ->
+ ExceptionUtils.findThrowable(
+ e,
+ throwable -> throwable.getMessage() != null && throwable.getMessage().contains("empty"))
+ .isPresent());
+ }
+ @Test
+ public void testMissingJarBlob() throws Exception {
+ final JobGraph jobGraph = getJobGraphWithMissingBlobKey();
+ runJobSubmissionTest(jobGraph, e -> ExceptionUtils.findThrowable(e, IOException.class).isPresent());
+ }
+
+ private void runJobSubmissionTest(JobGraph jobGraph, Predicate<Exception> failurePredicate) throws org.apache.flink.client.program.ProgramInvocationException {
ClusterClient<?> client = MINI_CLUSTER_RESOURCE.getClusterClient();
client.setDetached(detached);
@@ -122,9 +129,7 @@ public class JobSubmissionFailsITCase extends TestLogger {
client.submitJob(jobGraph, JobSubmissionFailsITCase.class.getClassLoader());
fail("Job submission should have thrown an exception.");
} catch (Exception e) {
- Optional<Throwable> expectedCause = ExceptionUtils.findThrowable(e,
- throwable -> throwable.getMessage() != null && throwable.getMessage().contains("empty"));
- if (!expectedCause.isPresent()) {
+ if (!failurePredicate.test(e)) {
throw e;
}
}
@@ -133,6 +138,13 @@ public class JobSubmissionFailsITCase extends TestLogger {
client.submitJob(getWorkingJobGraph(), JobSubmissionFailsITCase.class.getClassLoader());
}
+ @Nonnull
+ private static JobGraph getJobGraphWithMissingBlobKey() {
+ final JobGraph jobGraph = getWorkingJobGraph();
+ jobGraph.addUserJarBlobKey(new PermanentBlobKey());
+ return jobGraph;
+ }
+
// --------------------------------------------------------------------------------------------
private static class FailingJobVertex extends JobVertex {