You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2016/03/21 07:24:19 UTC
tajo git commit: TAJO-2091: Error or progress update should use
stderr instead of stdout.
Repository: tajo
Updated Branches:
refs/heads/master dbaf9725a -> 9fcc9fd3a
TAJO-2091: Error or progress update should use stderr instead of stdout.
Closes #977
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/9fcc9fd3
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/9fcc9fd3
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/9fcc9fd3
Branch: refs/heads/master
Commit: 9fcc9fd3af4479c3042e4907938b18b6e264b500
Parents: dbaf972
Author: Hyunsik Choi <hy...@apache.org>
Authored: Mon Mar 21 15:22:29 2016 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Mon Mar 21 15:22:29 2016 +0900
----------------------------------------------------------------------
CHANGES | 3 ++
.../java/org/apache/tajo/cli/tsql/TajoCli.java | 27 +++++++----
.../tsql/commands/ConnectDatabaseCommand.java | 2 +-
.../cli/tsql/commands/DescTableCommand.java | 4 +-
.../tsql/commands/ExecExternalShellCommand.java | 3 +-
.../tajo/cli/tsql/commands/ExitCommand.java | 4 +-
.../tajo/cli/tsql/commands/HdfsCommand.java | 2 +-
.../tajo/cli/tsql/commands/HelpCommand.java | 2 +-
.../tajo/cli/tsql/commands/SetCommand.java | 2 +-
.../cli/tsql/commands/TajoAdminCommand.java | 2 +-
.../cli/tsql/commands/TajoGetConfCommand.java | 2 +-
.../cli/tsql/commands/TajoHAAdminCommand.java | 2 +-
.../cli/tsql/TestDefaultCliOutputFormatter.java | 2 +-
.../org/apache/tajo/cli/tsql/TestTajoCli.java | 48 ++++++++++++++------
.../tajo/cli/tsql/TestTajoCliNegatives.java | 16 ++++---
.../commands/TestExecExternalShellCommand.java | 3 +-
.../tajo/cli/tsql/commands/TestHdfsCommand.java | 7 +--
.../testAddPartitionNotimplementedException.err | 1 +
...stAddPartitionNotimplementedException.result | 3 +-
.../testSelectResultWithNullTrueDeprecated.err | 1 +
...estSelectResultWithNullTrueDeprecated.result | 1 -
.../results/TestTajoCli/testStopWhenError.err | 1 +
.../TestTajoCli/testStopWhenError.result | 3 +-
.../TestTajoCli/testStopWhenErrorDeprecated.err | 2 +
.../testStopWhenErrorDeprecated.result | 4 +-
25 files changed, 93 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3ec86be..3c6bcaf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -8,6 +8,9 @@ Release 0.12.0 - unreleased
IMPROVEMENT
+ TAJO-2091: Error or progress update should use stderr instead of stdout.
+ (hyunsik)
+
TAJO-2064: Supporting auto-completion in Tsql. (Jongyoung Park via jaehwa)
TAJO-2043: Implement new data type and schema. (hyunsik)
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java
index 70defb1..489cd3d 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java
@@ -71,6 +71,7 @@ public class TajoCli implements Closeable {
private final ConsoleReader reader;
private final InputStream sin;
private final PrintWriter sout;
+ private final PrintWriter serr;
private TajoFileHistory history;
private final boolean reconnect; // reconnect on invalid session
@@ -143,6 +144,10 @@ public class TajoCli implements Closeable {
return sout;
}
+ public PrintWriter getError() {
+ return serr;
+ }
+
public TajoConf getConf() {
return conf;
}
@@ -188,7 +193,7 @@ public class TajoCli implements Closeable {
}
}
- public TajoCli(TajoConf c, String [] args, @Nullable Properties clientParams, InputStream in, OutputStream out)
+ public TajoCli(TajoConf c, String [] args, @Nullable Properties clientParams, InputStream in, OutputStream out, OutputStream err)
throws Exception {
CommandLineParser parser = new PosixParser();
@@ -205,6 +210,7 @@ public class TajoCli implements Closeable {
this.reader.setExpandEvents(false);
this.sout = new PrintWriter(reader.getOutput());
+ this.serr = new PrintWriter(new OutputStreamWriter(err, "UTF-8"));
initFormatter();
if (cmd.hasOption("help")) {
@@ -278,6 +284,7 @@ public class TajoCli implements Closeable {
displayFormatter.setScriptMode();
int exitCode = executeScript(cmd.getOptionValue("c"));
sout.flush();
+ serr.flush();
System.exit(exitCode);
}
if (cmd.hasOption("f")) {
@@ -289,6 +296,7 @@ public class TajoCli implements Closeable {
script = replaceParam(script, cmd.getOptionValues("param"));
int exitCode = executeScript(script);
sout.flush();
+ serr.flush();
System.exit(exitCode);
} else {
System.err.println(ERROR_PREFIX + "No such a file \"" + cmd.getOptionValue("f") + "\"");
@@ -549,6 +557,7 @@ public class TajoCli implements Closeable {
onError(t);
return -1;
} finally {
+ context.getError().flush();
context.getOutput().flush();
}
@@ -670,11 +679,11 @@ public class TajoCli implements Closeable {
}
if (TajoClientUtil.isQueryRunning(status.getState())) {
- displayFormatter.printProgress(sout, status);
+ displayFormatter.printProgress(serr, status);
}
if (TajoClientUtil.isQueryComplete(status.getState()) && status.getState() != QueryState.QUERY_KILL_WAIT) {
- displayFormatter.printProgress(sout, status);
+ displayFormatter.printProgress(serr, status);
break;
} else {
Thread.sleep(Math.min(200 * progressRetries, 1000));
@@ -683,10 +692,10 @@ public class TajoCli implements Closeable {
}
if (status.getState() == QueryState.QUERY_ERROR || status.getState() == QueryState.QUERY_FAILED) {
- displayFormatter.printErrorMessage(sout, status);
+ displayFormatter.printErrorMessage(serr, status);
wasError = true;
} else if (status.getState() == QueryState.QUERY_KILLED) {
- displayFormatter.printKilledMessage(sout, queryId);
+ displayFormatter.printKilledMessage(serr, queryId);
wasError = true;
} else {
if (status.getState() == QueryState.QUERY_SUCCEEDED) {
@@ -727,18 +736,18 @@ public class TajoCli implements Closeable {
private void printUsage() {
HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("tsql [options] [database]", options);
+ formatter.printUsage(this.serr, 80, "tsql [options] [database]", options);
}
private void printInvalidCommand(String command) {
- sout.println("Invalid command " + command + ". Try \\? for help.");
+ serr.println("Invalid command " + command + ". Try \\? for help.");
}
private void onError(Throwable t) {
Preconditions.checkNotNull(t);
wasError = true;
- displayFormatter.printErrorMessage(sout, t.getMessage());
+ displayFormatter.printErrorMessage(serr, t.getMessage());
if (reconnect && (t instanceof InvalidClientSessionException)) {
try {
@@ -763,7 +772,7 @@ public class TajoCli implements Closeable {
public static void main(String [] args) throws Exception {
TajoConf conf = new TajoConf();
- TajoCli shell = new TajoCli(conf, args, new Properties(), System.in, System.out);
+ TajoCli shell = new TajoCli(conf, args, new Properties(), System.in, System.out, System.err);
System.out.println();
System.exit(shell.runShell());
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java
index 93cb62b..df548b3 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java
@@ -68,7 +68,7 @@ public class ConnectDatabaseCommand extends TajoShellCommand {
);
} catch (TajoException se) {
- context.getOutput().write(String.format("ERROR: %s%n", se.getMessage()));
+ context.getError().write(String.format("ERROR: %s%n", se.getMessage()));
}
}
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
index 8760a37..6f01911 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
@@ -61,7 +61,7 @@ public class DescTableCommand extends TajoShellCommand {
String tableName = tableNameMaker.toString().replace("\"", "");
TableDesc desc = client.getTableDesc(tableName);
if (desc == null) {
- context.getOutput().println("Did not find any relation named \"" + tableName + "\"");
+ context.getError().println("Did not find any relation named \"" + tableName + "\"");
} else {
context.getOutput().println(toFormattedString(desc));
// If there exists any indexes for the table, print index information
@@ -84,7 +84,7 @@ public class DescTableCommand extends TajoShellCommand {
} else if (cmd.length == 1) {
List<String> tableList = client.getTableList(null);
if (tableList.size() == 0) {
- context.getOutput().println("No Relation Found");
+ context.getError().println("No Relation Found");
}
for (String table : tableList) {
context.getOutput().println(table);
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExecExternalShellCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExecExternalShellCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExecExternalShellCommand.java
index ac97959..90fad70 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExecExternalShellCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExecExternalShellCommand.java
@@ -53,12 +53,13 @@ public class ExecExternalShellCommand extends TajoShellCommand {
execCommand[2] = builtCommand;
PrintWriter sout = context.getOutput();
+ PrintWriter serr = context.getError();
CountDownLatch latch = new CountDownLatch(2);
Process process = Runtime.getRuntime().exec(execCommand);
try {
InputStreamConsoleWriter inWriter = new InputStreamConsoleWriter(process.getInputStream(), sout, "", latch);
- InputStreamConsoleWriter errWriter = new InputStreamConsoleWriter(process.getErrorStream(), sout, "ERROR: ", latch);
+ InputStreamConsoleWriter errWriter = new InputStreamConsoleWriter(process.getErrorStream(), serr, "ERROR: ", latch);
inWriter.start();
errWriter.start();
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExitCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExitCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExitCommand.java
index a9f0846..15b664d 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExitCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ExitCommand.java
@@ -36,8 +36,8 @@ public class ExitCommand extends TajoShellCommand {
@Override
public void invoke(String[] cmd) throws Exception {
- context.getOutput().println("bye!");
- context.getOutput().close();
+ context.getError().println("bye!");
+ context.getError().flush();
System.exit(0);
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HdfsCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HdfsCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HdfsCommand.java
index 8f57b74..ad35398 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HdfsCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HdfsCommand.java
@@ -42,7 +42,7 @@ public class HdfsCommand extends TajoShellCommand {
fsShell.run(dfsCommands);
} catch (Exception e) {
- context.getOutput().println("ERROR: " + e.getMessage());
+ context.getError().println("ERROR: " + e.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HelpCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HelpCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HelpCommand.java
index e484d72..389375a 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HelpCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/HelpCommand.java
@@ -102,7 +102,7 @@ public class HelpCommand extends TajoShellCommand {
if (context.getCommands().containsKey(slashCommand)) {
context.getCommands().get(slashCommand).printHelp();
} else {
- context.getOutput().println("Command not found: " + cmd[1]);
+ context.getError().println("Command not found: " + cmd[1]);
}
}
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/SetCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/SetCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/SetCommand.java
index bd887d5..bd51458 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/SetCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/SetCommand.java
@@ -74,7 +74,7 @@ public class SetCommand extends TajoShellCommand {
}
if (SessionVars.isDeprecated(key)) {
- context.getOutput().println("Warning: deprecated to directly use config key in TajoConf.ConfVars. " +
+ context.getError().println("Warning: deprecated to directly use config key in TajoConf.ConfVars. " +
"Please execute '\\help set'.");
}
} else {
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoAdminCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoAdminCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoAdminCommand.java
index 53f66b0..9c31758 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoAdminCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoAdminCommand.java
@@ -42,7 +42,7 @@ public class TajoAdminCommand extends TajoShellCommand {
admin.runCommand(dfsCommands);
} catch (Exception e) {
- context.getOutput().println("ERROR: " + e.getMessage());
+ context.getError().println("ERROR: " + e.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoGetConfCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoGetConfCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoGetConfCommand.java
index a499766..8c8568f 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoGetConfCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoGetConfCommand.java
@@ -49,7 +49,7 @@ public class TajoGetConfCommand extends TajoShellCommand {
getconf.runCommand(getConfCommands);
} catch (Exception e) {
- context.getOutput().println("ERROR: " + e.getMessage());
+ context.getError().println("ERROR: " + e.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoHAAdminCommand.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoHAAdminCommand.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoHAAdminCommand.java
index 49dee28..2ea9b85 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoHAAdminCommand.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/TajoHAAdminCommand.java
@@ -42,7 +42,7 @@ public class TajoHAAdminCommand extends TajoShellCommand {
haAdmin.runCommand(haAdminCommands);
} catch (Exception e) {
- context.getOutput().println("ERROR: " + e.getMessage());
+ context.getError().println("ERROR: " + e.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestDefaultCliOutputFormatter.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestDefaultCliOutputFormatter.java b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestDefaultCliOutputFormatter.java
index c497d74..fefdbb1 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestDefaultCliOutputFormatter.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestDefaultCliOutputFormatter.java
@@ -66,7 +66,7 @@ public class TestDefaultCliOutputFormatter {
public void setUp() throws Exception {
conf = cluster.getConfiguration();
ByteArrayOutputStream out = new ByteArrayOutputStream();
- tajoCli = new TajoCli(conf, new String[]{}, null, System.in, out);
+ tajoCli = new TajoCli(conf, new String[]{}, null, System.in, out, out);
cliContext = tajoCli.getContext();
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
index 6bd694f..c210a24 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
@@ -69,6 +69,7 @@ public class TestTajoCli {
private TajoCli tajoCli;
private Path currentResultPath;
private ByteArrayOutputStream out;
+ private ByteArrayOutputStream err;
@Rule
public TestName name = new TestName();
@@ -81,14 +82,16 @@ public class TestTajoCli {
@Before
public void setUp() throws Exception {
out = new ByteArrayOutputStream();
+ err = new ByteArrayOutputStream();
Properties connParams = new Properties();
connParams.setProperty(RpcConstants.CLIENT_RETRY_NUM, "3");
- tajoCli = new TajoCli(cluster.getConfiguration(), new String[]{}, connParams, System.in, out);
+ tajoCli = new TajoCli(cluster.getConfiguration(), new String[]{}, connParams, System.in, out, err);
}
@After
public void tearDown() throws IOException {
out.close();
+ err.close();
if (tajoCli != null) {
tajoCli.close();
}
@@ -106,17 +109,33 @@ public class TestTajoCli {
assertOutputResult(name.getMethodName() + ".result", actual);
}
+ private void assertErrorResult(String actual, boolean required) throws Exception {
+ String fileName = name.getMethodName() + ".err";
+ if (required) {
+ assertOutputResult(fileName, actual);
+ }
+ }
+
private void assertOutputResult(String expectedResultFile, String actual) throws Exception {
assertOutputResult(expectedResultFile, actual, null, null);
}
+ private boolean existsFile(String fileName) throws IOException {
+ FileSystem fs = currentResultPath.getFileSystem(testBase.getTestingCluster().getConfiguration());
+ Path filePath = StorageUtil.concatPath(currentResultPath, fileName);
+ return fs.exists(filePath);
+ }
+
+ private Path getAbsolutePath(String fileName) {
+ return StorageUtil.concatPath(currentResultPath, fileName);
+ }
+
private void assertOutputResult(String expectedResultFile, String actual, String[] paramKeys, String[] paramValues)
throws Exception {
- FileSystem fs = currentResultPath.getFileSystem(testBase.getTestingCluster().getConfiguration());
- Path resultFile = StorageUtil.concatPath(currentResultPath, expectedResultFile);
- assertTrue(resultFile.toString() + " existence check", fs.exists(resultFile));
+ Path path = getAbsolutePath(expectedResultFile);
+ assertTrue(path.toString() + " existence check", existsFile(expectedResultFile));
- String expectedResult = FileUtil.readTextFile(new File(resultFile.toUri()));
+ String expectedResult = FileUtil.readTextFile(new File(path.toUri()));
if (paramKeys != null) {
for (int i = 0; i < paramKeys.length; i++) {
@@ -164,7 +183,7 @@ public class TestTajoCli {
assertEquals("tajo.executor.join.inner.in-memory-table-num=256", confValues[1]);
TajoConf tajoConf = TpchTestBase.getInstance().getTestingCluster().getConfiguration();
- try (TajoCli testCli = new TajoCli(tajoConf, args, null, System.in, System.out)) {
+ try (TajoCli testCli = new TajoCli(tajoConf, args, null, System.in, System.out, err)) {
assertEquals("false", testCli.getContext().get(SessionVars.CLI_PAGING_ENABLED));
assertEquals("256", testCli.getContext().getConf().get("tajo.executor.join.inner.in-memory-table-num"));
}
@@ -310,8 +329,10 @@ public class TestTajoCli {
tajoCli.executeScript(sql);
- String consoleResult = new String(out.toByteArray());
- assertOutputResult(consoleResult);
+ String stdoutResult = new String(out.toByteArray());
+ assertOutputResult(stdoutResult);
+ String stdErrResult = new String(err.toByteArray());
+ assertErrorResult(stdErrResult, false);
}
@Test
@@ -345,7 +366,8 @@ public class TestTajoCli {
setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
try (ByteArrayOutputStream out = new ByteArrayOutputStream();
- TajoCli tajoCli = new TajoCli(tajoConf, new String[]{}, null, System.in, out)) {
+ ByteArrayOutputStream err = new ByteArrayOutputStream();
+ TajoCli tajoCli = new TajoCli(tajoConf, new String[]{}, null, System.in, out, err)) {
tajoCli.executeMetaCommand("\\getconf tajo.rootdir");
String consoleResult = new String(out.toByteArray());
@@ -359,7 +381,7 @@ public class TestTajoCli {
setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
ByteArrayOutputStream out = new ByteArrayOutputStream();
- TajoCli tajoCli = new TajoCli(tajoConf, new String[]{}, null, System.in, out);
+ TajoCli tajoCli = new TajoCli(tajoConf, new String[]{}, null, System.in, out, err);
tajoCli.executeMetaCommand("\\admin -showmasters");
String consoleResult = new String(out.toByteArray());
@@ -395,7 +417,7 @@ public class TestTajoCli {
setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
Properties connParams = new Properties();
connParams.setProperty(ClientParameters.RETRY, "3");
- TajoCli tc = new TajoCli(tajoConf, new String[]{}, connParams, is, out);
+ TajoCli tc = new TajoCli(tajoConf, new String[]{}, connParams, is, out, err);
tc.executeMetaCommand("\\set ON_ERROR_STOP false");
assertSessionVar(tc, SessionVars.ON_ERROR_STOP.keyname(), "false");
@@ -489,7 +511,7 @@ public class TestTajoCli {
assertEquals(0L, tableDesc.getStats().getNumRows().longValue());
try (InputStream testInput = new ByteArrayInputStream(new byte[]{(byte) DefaultTajoCliOutputFormatter.QUIT_COMMAND});
- TajoCli cli = new TajoCli(cluster.getConfiguration(), new String[]{}, null, testInput, out)) {
+ TajoCli cli = new TajoCli(cluster.getConfiguration(), new String[]{}, null, testInput, out, err)) {
setVar(cli, SessionVars.CLI_PAGE_ROWS, "2");
setVar(cli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
@@ -504,7 +526,7 @@ public class TestTajoCli {
@Test
public void testResultRowNumWhenSelectingOnPartitionedTable() throws Exception {
try (TajoCli cli2 = new TajoCli(cluster.getConfiguration(), new String[]{}, null, System.in,
- new NullOutputStream())) {
+ new NullOutputStream(), new NullOutputStream())) {
cli2.executeScript("create table region_part (r_regionkey int8, r_name text) " +
"partition by column (r_comment text) as select * from region");
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCliNegatives.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCliNegatives.java b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCliNegatives.java
index fcf4546..aea82ab 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCliNegatives.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCliNegatives.java
@@ -36,16 +36,19 @@ import static org.junit.Assert.assertEquals;
public class TestTajoCliNegatives extends QueryTestCaseBase {
private static TajoCli tajoCli;
private static ByteArrayOutputStream out;
+ private static ByteArrayOutputStream err;
@BeforeClass
public static void setUp() throws Exception {
out = new ByteArrayOutputStream();
- tajoCli = new TajoCli(testingCluster.getConfiguration(), new String[]{}, null, System.in, out);
+ err = new ByteArrayOutputStream();
+ tajoCli = new TajoCli(testingCluster.getConfiguration(), new String[]{}, null, System.in, out, err);
}
@AfterClass
public static void tearDown() throws IOException {
out.close();
+ err.close();
if (tajoCli != null) {
tajoCli.close();
}
@@ -54,11 +57,12 @@ public class TestTajoCliNegatives extends QueryTestCaseBase {
@Before
public void resetConsole() throws IOException {
out.reset();
+ err.reset();
}
public void assertMetaCommandFailure(String cmd, String expectedMsg) throws Exception {
tajoCli.executeMetaCommand(cmd);
- String consoleResult = new String(out.toByteArray());
+ String consoleResult = new String(err.toByteArray());
assertEquals(expectedMsg, consoleResult);
}
@@ -67,13 +71,13 @@ public class TestTajoCliNegatives extends QueryTestCaseBase {
String expected = FileUtil.readTextFile(new File(resultFile.toUri()));
tajoCli.executeScript(cmd);
- String consoleResult = new String(out.toByteArray());
+ String consoleResult = new String(err.toByteArray());
assertEquals(expected, consoleResult);
}
public void assertScriptFailure(String cmd, String expectedMsg) throws Exception {
tajoCli.executeScript(cmd);
- String consoleResult = new String(out.toByteArray());
+ String consoleResult = new String(err.toByteArray());
assertEquals(expectedMsg, consoleResult);
}
@@ -132,9 +136,7 @@ public class TestTajoCliNegatives extends QueryTestCaseBase {
public void testQueryFailureOfSimpleQuery() throws Exception {
setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
assertScriptFailure("select fail(3, l_orderkey, 'testQueryFailureOfSimpleQuery') from default.lineitem" ,
- "?fail\n" +
- "-------------------------------\n" +
- "ERROR: internal error: internal error: internal error: testQueryFailureOfSimpleQuery\n");
+ "ERROR: internal error: internal error: internal error: testQueryFailureOfSimpleQuery\n");
}
@Test
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestExecExternalShellCommand.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestExecExternalShellCommand.java b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestExecExternalShellCommand.java
index 95c3a8b..cd2d1b7 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestExecExternalShellCommand.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestExecExternalShellCommand.java
@@ -33,8 +33,9 @@ public class TestExecExternalShellCommand {
TajoConf tajoConf = TpchTestBase.getInstance().getTestingCluster().getConfiguration();
ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ByteArrayOutputStream err = new ByteArrayOutputStream();
- TajoCli cli = new TajoCli(tajoConf, new String[]{}, null, null, out);
+ TajoCli cli = new TajoCli(tajoConf, new String[]{}, null, null, out, err);
cli.executeMetaCommand("\\! echo \"this is test\"");
String consoleResult = new String(out.toByteArray());
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestHdfsCommand.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestHdfsCommand.java b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestHdfsCommand.java
index d239c0a..c4c76cd 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestHdfsCommand.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/commands/TestHdfsCommand.java
@@ -34,13 +34,14 @@ public class TestHdfsCommand {
TajoConf tajoConf = TpchTestBase.getInstance().getTestingCluster().getConfiguration();
ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ByteArrayOutputStream err = new ByteArrayOutputStream();
System.setOut(new PrintStream(out));
- System.setErr(new PrintStream(out));
- TajoCli cli = new TajoCli(tajoConf, new String[]{}, null, null, out);
+ System.setErr(new PrintStream(err));
+ TajoCli cli = new TajoCli(tajoConf, new String[]{}, null, null, out, err);
cli.executeMetaCommand("\\dfs -test");
- String consoleResult = new String(out.toByteArray());
+ String consoleResult = new String(err.toByteArray());
assertEquals("-test: Not enough arguments: expected 1 but got 0\n" +
"Usage: hadoop fs [generic options] -test -[defsz] <path>\n", consoleResult);
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/resources/results/TestTajoCli/testAddPartitionNotimplementedException.err
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testAddPartitionNotimplementedException.err b/tajo-core-tests/src/test/resources/results/TestTajoCli/testAddPartitionNotimplementedException.err
new file mode 100644
index 0000000..0f93146
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testAddPartitionNotimplementedException.err
@@ -0,0 +1 @@
+ERROR: not implemented feature: ADD PARTITION
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/resources/results/TestTajoCli/testAddPartitionNotimplementedException.result
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testAddPartitionNotimplementedException.result b/tajo-core-tests/src/test/resources/results/TestTajoCli/testAddPartitionNotimplementedException.result
index 4aab8c8..a0aba93 100644
--- a/tajo-core-tests/src/test/resources/results/TestTajoCli/testAddPartitionNotimplementedException.result
+++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testAddPartitionNotimplementedException.result
@@ -1,2 +1 @@
-OK
-ERROR: not implemented feature: ADD PARTITION
\ No newline at end of file
+OK
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/resources/results/TestTajoCli/testSelectResultWithNullTrueDeprecated.err
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testSelectResultWithNullTrueDeprecated.err b/tajo-core-tests/src/test/resources/results/TestTajoCli/testSelectResultWithNullTrueDeprecated.err
new file mode 100644
index 0000000..634795a
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testSelectResultWithNullTrueDeprecated.err
@@ -0,0 +1 @@
+Warning: deprecated to directly use config key in TajoConf.ConfVars. Please execute '\help set'.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/resources/results/TestTajoCli/testSelectResultWithNullTrueDeprecated.result
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testSelectResultWithNullTrueDeprecated.result b/tajo-core-tests/src/test/resources/results/TestTajoCli/testSelectResultWithNullTrueDeprecated.result
index 1212ade..302d80c 100644
--- a/tajo-core-tests/src/test/resources/results/TestTajoCli/testSelectResultWithNullTrueDeprecated.result
+++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testSelectResultWithNullTrueDeprecated.result
@@ -1,4 +1,3 @@
-Warning: deprecated to directly use config key in TajoConf.ConfVars. Please execute '\help set'.
c_custkey, o_orderkey, o_orderstatus
-------------------------------
1, 1, O
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenError.err
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenError.err b/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenError.err
new file mode 100644
index 0000000..bff3cfe
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenError.err
@@ -0,0 +1 @@
+ERROR: relation 'default.lineitem2' does not exist
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenError.result
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenError.result b/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenError.result
index a0044c2..d480b2b 100644
--- a/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenError.result
+++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenError.result
@@ -1,5 +1,4 @@
?count
-------------------------------
5
-(1 rows, , 16 B selected)
-ERROR: relation 'default.lineitem2' does not exist
\ No newline at end of file
+(1 rows, , 16 B selected)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenErrorDeprecated.err
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenErrorDeprecated.err b/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenErrorDeprecated.err
new file mode 100644
index 0000000..6affb7f
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenErrorDeprecated.err
@@ -0,0 +1,2 @@
+Warning: deprecated to directly use config key in TajoConf.ConfVars. Please execute '\help set'.
+ERROR: relation 'default.lineitem2' does not exist
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/9fcc9fd3/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenErrorDeprecated.result
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenErrorDeprecated.result b/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenErrorDeprecated.result
index e3f1e6b..d480b2b 100644
--- a/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenErrorDeprecated.result
+++ b/tajo-core-tests/src/test/resources/results/TestTajoCli/testStopWhenErrorDeprecated.result
@@ -1,6 +1,4 @@
-Warning: deprecated to directly use config key in TajoConf.ConfVars. Please execute '\help set'.
?count
-------------------------------
5
-(1 rows, , 16 B selected)
-ERROR: relation 'default.lineitem2' does not exist
\ No newline at end of file
+(1 rows, , 16 B selected)
\ No newline at end of file