use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class FlinkYarnSessionCliTest method testCorrectSettingOfMaxSlots.
@Test
public void testCorrectSettingOfMaxSlots() throws Exception {
File confFile = tmp.newFile("flink-conf.yaml");
File jarFile = tmp.newFile("test.jar");
new CliFrontend(tmp.getRoot().getAbsolutePath());
String[] params = new String[] { "-yn", "2", "-ys", "3", jarFile.getAbsolutePath() };
RunOptions runOptions = CliFrontendParser.parseRunCommand(params);
FlinkYarnSessionCli yarnCLI = new TestCLI("y", "yarn");
AbstractYarnClusterDescriptor descriptor = yarnCLI.createDescriptor("", runOptions.getCommandLine());
// each task manager has 3 slots but the parallelism is 7. Thus the slots should be increased.
Assert.assertEquals(3, descriptor.getTaskManagerSlots());
Assert.assertEquals(2, descriptor.getTaskManagerCount());
Configuration config = new Configuration();
CliFrontend.setJobManagerAddressInConfig(config, new InetSocketAddress("test", 9000));
ClusterClient client = new TestingYarnClusterClient(descriptor, config);
Assert.assertEquals(6, client.getMaxSlots());
}
use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class CliFrontendAddressConfigurationTest method testManualOptionsOverridesConfig.
@Test
public void testManualOptionsOverridesConfig() {
try {
CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
RunOptions options = CliFrontendParser.parseRunCommand(new String[] { "-m", "203.0.113.22:7788" });
ClusterClient client = frontend.retrieveClient(options);
Configuration config = client.getFlinkConfiguration();
InetSocketAddress expectedAddress = new InetSocketAddress("203.0.113.22", 7788);
checkJobManagerAddress(config, expectedAddress.getHostName(), expectedAddress.getPort());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class CliFrontendPackageProgramTest method testNonExistingFileWithoutArguments.
@Test
public void testNonExistingFileWithoutArguments() {
try {
String[] arguments = { "/some/none/existing/path" };
RunOptions options = CliFrontendParser.parseRunCommand(arguments);
assertEquals(arguments[0], options.getJarFilePath());
assertArrayEquals(new String[0], options.getProgramArgs());
CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
try {
frontend.buildProgram(options);
} catch (FileNotFoundException e) {
// that's what we want
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class CliFrontendPackageProgramTest method testNonExistingFileWithArguments.
@Test
public void testNonExistingFileWithArguments() {
try {
String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", "/some/none/existing/path", "--debug", "true", "arg1", "arg2" };
URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") };
String[] reducedArguments = { "--debug", "true", "arg1", "arg2" };
RunOptions options = CliFrontendParser.parseRunCommand(arguments);
assertEquals(arguments[4], options.getJarFilePath());
assertArrayEquals(classpath, options.getClasspaths().toArray());
assertArrayEquals(reducedArguments, options.getProgramArgs());
CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
try {
frontend.buildProgram(options);
fail("Should fail with an exception");
} catch (FileNotFoundException e) {
// that's what we want
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.client.cli.RunOptions in project flink by apache.
the class CliFrontendPackageProgramTest method testVariantWithExplicitJarAndNoArgumentsOption.
@Test
public void testVariantWithExplicitJarAndNoArgumentsOption() {
try {
String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", "-j", getTestJarPath(), "--debug", "true", "arg1", "arg2" };
URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") };
String[] reducedArguments = new String[] { "--debug", "true", "arg1", "arg2" };
RunOptions options = CliFrontendParser.parseRunCommand(arguments);
assertEquals(getTestJarPath(), options.getJarFilePath());
assertArrayEquals(classpath, options.getClasspaths().toArray());
assertArrayEquals(reducedArguments, options.getProgramArgs());
CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getConfigDir());
PackagedProgram prog = frontend.buildProgram(options);
Assert.assertArrayEquals(reducedArguments, prog.getArguments());
Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations