Exemplo n.º 1
0
 @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'"));
 }
Exemplo n.º 2
0
 @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"));
 }
Exemplo n.º 3
0
  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()
          });
    }
  }
Exemplo n.º 4
0
  @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());
  }
Exemplo n.º 5
0
  @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");
  }
Exemplo n.º 6
0
  @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();
    }
  }
Exemplo n.º 7
0
 private static void setVar(TajoCli cli, ConfigKey key, String val) throws Exception {
   cli.executeMetaCommand("\\set " + key.keyname() + " " + val);
 }
Exemplo n.º 8
0
 @Test
 public void testHelpSessionVars() throws Exception {
   tajoCli.executeMetaCommand("\\help set");
   assertOutputResult(new String(out.toByteArray()));
 }
Exemplo n.º 9
0
 @Test
 public void testStopWhenError() throws Exception {
   tajoCli.executeMetaCommand("\\set ON_ERROR_STOP true");
   verifyStopWhenError();
 }
Exemplo n.º 10
0
 @Test
 public void testStopWhenErrorDeprecated() throws Exception {
   tajoCli.executeMetaCommand("\\set tajo.cli.error.stop true");
   verifyStopWhenError();
 }