forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-15504] Allow output to stdout/stderr during execution of Packa…
…gedProgram We suppress the output to stdout/stderr during plan extraction via PackagedProgram. This has unintended consequences for users who are looking into debugging their Flink programs during JobGraph creation. This change removes the suppression of output when we run the JARs. The plan preview still suppresses the output to avoid spaming the logs during plan preview.
- Loading branch information
Showing
16 changed files
with
329 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...k-clients/src/test/java/org/apache/flink/client/program/OptimizerPlanEnvironmentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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 | ||
* | ||
* https://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.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
/** | ||
* Tests for {@link OptimizerPlanEnvironment}. | ||
*/ | ||
public class OptimizerPlanEnvironmentTest { | ||
|
||
/** | ||
* Test the two modes for handling stdout/stderr of user program. | ||
* (1) Capturing the output and including it only in the exception | ||
* (2) Leaving the output untouched | ||
*/ | ||
@Test | ||
public void testStdOutStdErrHandling() throws Exception { | ||
runOutputTest(true, new String[] {"System.out: hello out!", "System.err: hello err!"}); | ||
runOutputTest(false, new String[] {"System.out: (none)", "System.err: (none)"}); | ||
} | ||
|
||
private void runOutputTest(boolean suppressOutput, String[] expectedCapturedOutput) throws ProgramInvocationException { | ||
PackagedProgram packagedProgram = PackagedProgram.newBuilder() | ||
.setEntryPointClassName(getClass().getName()) | ||
.build(); | ||
OptimizerPlanEnvironment env = new OptimizerPlanEnvironment(); | ||
try { | ||
// Flink will throw an error because no job graph will be generated by the main method. | ||
env.getPipeline(packagedProgram, suppressOutput); | ||
Assert.fail("This should have failed to create the Flink Plan."); | ||
} catch (ProgramInvocationException e) { | ||
// Test that that Flink captured the expected stdout/stderr | ||
for (String expected : expectedCapturedOutput) { | ||
assertThat(e.getMessage(), containsString(expected)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Main method for {@code testEnsureStdoutStdErrIsRestored()}. | ||
* This will not create a valid Flink program. We will just use this program to check whether stdout/stderr is | ||
* captured in a byte buffer or directly printed to the console. | ||
* */ | ||
public static void main(String[] args) { | ||
// Print something to stdout/stderr for output suppression test | ||
System.out.println("hello out!"); | ||
System.err.println("hello err!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.