@Test(groups = CLI, timeOut = TIMEOUT) public void shouldRunQuery() throws IOException, InterruptedException { launchPrestoCliWithServerArgument(); presto.waitForPrompt(); presto.getProcessInput().println("select * from hive.default.nation;"); assertThat(trimLines(presto.readLinesUntilPrompt())).containsAll(nationTableInteractiveLines); }
@AfterTestWithContext public void stopPresto() throws InterruptedException { if (presto != null) { presto.getProcessInput().println(EXIT_COMMAND); presto.waitForWithTimeoutAndKill(); } }
@Test(groups = CLI, timeOut = TIMEOUT) public void shouldDisplayVersion() throws IOException, InterruptedException { launchPrestoCli("--version"); String version = firstNonNull(Presto.class.getPackage().getImplementationVersion(), "(version unknown)"); assertThat(presto.readRemainingOutputLines()).containsExactly("Presto CLI " + version); }
@Test(groups = CLI, timeOut = TIMEOUT) public void shouldRunQueryFromFile() throws IOException, InterruptedException { File temporayFile = File.createTempFile("test-sql", null); temporayFile.deleteOnExit(); Files.write("select * from hive.default.nation;\n", temporayFile, UTF_8); launchPrestoCliWithServerArgument("--file", temporayFile.getAbsolutePath()); assertThat(trimLines(presto.readRemainingOutputLines())).containsAll(nationTableBatchLines); }
@Test(groups = CLI, timeOut = TIMEOUT) public void shouldUseCatalogAndSchemaOptions() throws IOException, InterruptedException { launchPrestoCliWithServerArgument( "--catalog", "hive", "--schema", "default", "--execute", "select * from nation;"); assertThat(trimLines(presto.readRemainingOutputLines())).containsAll(nationTableBatchLines); }
@Test(groups = CLI, timeOut = TIMEOUT) public void shouldRunBatchQuery() throws IOException, InterruptedException { launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;"); assertThat(trimLines(presto.readRemainingOutputLines())).containsAll(nationTableBatchLines); }