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/12/11 09:25:11 UTC
[flink] branch master updated: [FLINK-10743] [runtime] Use 0
processExitCode for ApplicationStatus.CANCELED
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
The following commit(s) were added to refs/heads/master by this push:
new 2ab4d41 [FLINK-10743] [runtime] Use 0 processExitCode for ApplicationStatus.CANCELED
2ab4d41 is described below
commit 2ab4d417646d54938f10ebf8b216c7e4f203f691
Author: Ufuk Celebi <uc...@apache.org>
AuthorDate: Wed Oct 31 22:10:05 2018 +0100
[FLINK-10743] [runtime] Use 0 processExitCode for ApplicationStatus.CANCELED
This closes #7004.
---
.../clusterframework/ApplicationStatus.java | 2 +-
.../clusterframework/ApplicationStatusTest.java | 76 ++++++++++++++++++++++
2 files changed, 77 insertions(+), 1 deletion(-)
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/ApplicationStatus.java b/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/ApplicationStatus.java
index 963e9ab..0cc43c0 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/ApplicationStatus.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/ApplicationStatus.java
@@ -32,7 +32,7 @@ public enum ApplicationStatus {
FAILED(1443),
/** Application was canceled or killed on request */
- CANCELED(1444),
+ CANCELED(0),
/** Application status is not known */
UNKNOWN(1445);
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/ApplicationStatusTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/ApplicationStatusTest.java
new file mode 100644
index 0000000..8fb7cac
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/ApplicationStatusTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.clusterframework;
+
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Tests for the {@link ApplicationStatus}.
+ */
+public class ApplicationStatusTest extends TestLogger {
+
+ private static final int SUCCESS_EXIT_CODE = 0;
+
+ @Test
+ public void succeededStatusMapsToSuccessExitCode() {
+ int exitCode = ApplicationStatus.SUCCEEDED.processExitCode();
+ assertThat(exitCode, is(equalTo(SUCCESS_EXIT_CODE)));
+ }
+
+ @Test
+ public void cancelledStatusMapsToSuccessExitCode() {
+ int exitCode = ApplicationStatus.CANCELED.processExitCode();
+ assertThat(exitCode, is(equalTo(SUCCESS_EXIT_CODE)));
+ }
+
+ @Test
+ public void notSucceededNorCancelledStatusMapsToNonSuccessExitCode() {
+ Iterable<Integer> exitCodes = exitCodes(notSucceededNorCancelledStatus());
+ assertThat(exitCodes, not(contains(SUCCESS_EXIT_CODE)));
+ }
+
+ private static Iterable<Integer> exitCodes(Iterable<ApplicationStatus> statuses) {
+ return StreamSupport.stream(statuses.spliterator(), false)
+ .map(ApplicationStatus::processExitCode)
+ .collect(Collectors.toList());
+ }
+
+ private static Iterable<ApplicationStatus> notSucceededNorCancelledStatus() {
+ return Arrays.stream(ApplicationStatus.values())
+ .filter(ApplicationStatusTest::isNotSucceededNorCancelled)
+ .collect(Collectors.toList());
+ }
+
+ private static boolean isNotSucceededNorCancelled(ApplicationStatus status) {
+ return status != ApplicationStatus.SUCCEEDED && status != ApplicationStatus.CANCELED;
+ }
+
+}