tillrohrmann commented on a change in pull request #11473: [FLINK-16705] Ensure MiniCluster shutdown does not interfere with JobResult retrieval URL: https://github.com/apache/flink/pull/11473#discussion_r400226586
########## File path: flink-clients/src/test/java/org/apache/flink/client/program/PerJobMiniClusterTest.java ########## @@ -0,0 +1,234 @@ +/* + * 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.client.program; + +import org.apache.flink.api.common.JobExecutionResult; +import org.apache.flink.api.common.JobStatus; +import org.apache.flink.api.common.JobSubmissionResult; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.core.execution.JobClient; +import org.apache.flink.runtime.execution.Environment; +import org.apache.flink.runtime.jobgraph.JobGraph; +import org.apache.flink.runtime.jobgraph.JobVertex; +import org.apache.flink.runtime.jobmaster.JobResult; +import org.apache.flink.runtime.minicluster.MiniCluster; +import org.apache.flink.runtime.testtasks.NoOpInvokable; +import org.apache.flink.runtime.testutils.CancelableInvokable; + +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.mockito.Mockito; + +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * Tests for {@link PerJobMiniCluster}. + */ +public class PerJobMiniClusterTest { + + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + + private MiniCluster miniCluster; + + @BeforeClass + public static void beforeClass() throws Exception { + temporaryFolder.create(); + } + + @Test + public void testJobExecution() throws Exception { + PerJobMiniCluster perJobMiniCluster = initializeMiniCluster(); + + JobClient jobClient = perJobMiniCluster.submitJob(getNoopJobGraph()).get(); + + JobExecutionResult jobExecutionResult = jobClient.getJobExecutionResult(getClass().getClassLoader()).get(); + assertThat(jobExecutionResult, is(notNullValue())); + + Map<String, Object> actual = jobClient.getAccumulators(getClass().getClassLoader()).get(); + assertThat(actual, is(notNullValue())); + + assertThatMiniClusterIsShutdown(); + } + + @Test + public void testJobClient() throws Exception { + PerJobMiniCluster perJobMiniCluster = initializeMiniCluster(); + + JobGraph cancellableJobGraph = getCancellableJobGraph(); + JobClient jobClient = perJobMiniCluster + .submitJob(cancellableJobGraph) + .get(); + + assertThat(jobClient.getJobID(), is(cancellableJobGraph.getJobID())); + assertThat(jobClient.getJobStatus().get(), is(JobStatus.RUNNING)); + + jobClient.cancel().get(); + + try { + jobClient.getJobExecutionResult(getClass().getClassLoader()).get(); Review comment: Are we expecting a certain exception here or that his method passes? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services