@Test public void testTimeZoneSessionVars1() throws Exception { tajoCli.executeMetaCommand("\\set TIMEZONE GMT+1"); tajoCli.executeMetaCommand("\\set"); String output = new String(out.toByteArray()); assertTrue(output.contains("'TIMEZONE'='GMT+1'")); }
@Test public void testTimeZoneTest2() throws Exception { String tableName = "test1"; tajoCli.executeMetaCommand("\\set TIMEZONE GMT+1"); tajoCli.executeScript("create table " + tableName + " (col1 TIMESTAMP)"); tajoCli.executeScript("insert into " + tableName + " select to_timestamp(0)"); tajoCli.executeScript("select * from " + tableName); String consoleResult = new String(out.toByteArray()); tajoCli.executeScript("DROP TABLE " + tableName + " PURGE"); assertTrue(consoleResult.contains("1970-01-01 01:00:00")); }
private void verifyDescTable(String sql, String tableName, String resultFileName) throws Exception { setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName()); tajoCli.executeScript(sql); tajoCli.executeMetaCommand("\\d " + tableName); tajoCli.executeMetaCommand("\\d \"" + tableName + "\""); String consoleResult = new String(out.toByteArray()); if (!cluster.isHiveCatalogStoreRunning()) { assertOutputResult( resultFileName, consoleResult, new String[] {"${table.path}"}, new String[] { TablespaceManager.getDefault().getTableUri("default", tableName).toString() }); } }
@Test public void testConnectDatabase() throws Exception { String databaseName; if (cluster.isHiveCatalogStoreRunning()) { databaseName = "TEST_CONNECTION_DATABASE".toLowerCase(); } else { databaseName = "TEST_CONNECTION_DATABASE"; } String sql = "create database \"" + databaseName + "\";"; tajoCli.executeScript(sql); tajoCli.executeMetaCommand("\\c " + databaseName); assertEquals(databaseName, tajoCli.getContext().getCurrentDatabase()); tajoCli.executeMetaCommand("\\c default"); assertEquals("default", tajoCli.getContext().getCurrentDatabase()); tajoCli.executeMetaCommand("\\c \"" + databaseName + "\""); assertEquals(databaseName, tajoCli.getContext().getCurrentDatabase()); }
@Test public void testShowMasters() throws Exception { TajoConf tajoConf = TpchTestBase.getInstance().getTestingCluster().getConfiguration(); setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName()); ByteArrayOutputStream out = new ByteArrayOutputStream(); TajoCli tajoCli = new TajoCli(tajoConf, new String[] {}, System.in, out); tajoCli.executeMetaCommand("\\admin -showmasters"); String consoleResult = new String(out.toByteArray()); String masterAddress = tajoCli.getContext().getConf().getVar(TajoConf.ConfVars.TAJO_MASTER_UMBILICAL_RPC_ADDRESS); String host = masterAddress.split(":")[0]; tajoCli.close(); assertEquals(consoleResult, host + "\n"); }
@Test public void testGetConf() throws Exception { TajoConf tajoConf = TpchTestBase.getInstance().getTestingCluster().getConfiguration(); setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName()); ByteArrayOutputStream out = new ByteArrayOutputStream(); TajoCli tajoCli = new TajoCli(tajoConf, new String[] {}, System.in, out); try { tajoCli.executeMetaCommand("\\getconf tajo.rootdir"); String consoleResult = new String(out.toByteArray()); assertEquals( consoleResult, tajoCli.getContext().getConf().getVar(TajoConf.ConfVars.ROOT_DIR) + "\n"); } finally { tajoCli.close(); } }
private static void setVar(TajoCli cli, ConfigKey key, String val) throws Exception { cli.executeMetaCommand("\\set " + key.keyname() + " " + val); }
@Test public void testHelpSessionVars() throws Exception { tajoCli.executeMetaCommand("\\help set"); assertOutputResult(new String(out.toByteArray())); }
@Test public void testStopWhenError() throws Exception { tajoCli.executeMetaCommand("\\set ON_ERROR_STOP true"); verifyStopWhenError(); }
@Test public void testStopWhenErrorDeprecated() throws Exception { tajoCli.executeMetaCommand("\\set tajo.cli.error.stop true"); verifyStopWhenError(); }
public void assertMetaCommandFailure(String cmd, String expectedMsg) throws Exception { tajoCli.executeMetaCommand(cmd); String consoleResult = new String(err.toByteArray()); assertEquals(expectedMsg, consoleResult); }