xintongsong commented on a change in pull request #9801: [FLINK-13983][runtime] Launch task executor with new memory calculation logics URL: https://github.com/apache/flink/pull/9801#discussion_r334831988
########## File path: flink-dist/src/test/java/org/apache/flink/dist/JavaBashTestBase.java ########## @@ -0,0 +1,60 @@ +/* + * 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.dist; + +import org.apache.flink.util.OperatingSystem; +import org.apache.flink.util.TestLogger; + +import org.junit.Assume; +import org.junit.BeforeClass; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +/** + * Test class for executing bash scripts. + */ +public class JavaBashTestBase extends TestLogger { + @BeforeClass + public static void checkOperatingSystem() { + Assume.assumeTrue("This test checks shell scripts which are not available on Windows.", + !OperatingSystem.isWindows()); + } + + /** + * Executes the given shell script wrapper and returns its output. + * + * @param command command to run + * + * @return raw script output + */ + protected String executeScript(final String[] command) throws IOException { + ProcessBuilder pb = new ProcessBuilder(command); + pb.redirectErrorStream(true); + Process process = pb.start(); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + StringBuilder sb = new StringBuilder(); + String s; + while ((s = reader.readLine()) != null) { + sb.append(s).append("\n"); Review comment: Since we are separating the two commands (generating dynamic config / jvm parameters), we can simply remove this line breaker here. ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
