use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class QTestUtil method initFromScript.
private void initFromScript() throws IOException {
File scriptFile = new File(this.initScript);
if (!scriptFile.isFile()) {
LOG.info("No init script detected. Skipping");
return;
}
String initCommands = FileUtils.readFileToString(scriptFile);
LOG.info("Initial setup (" + initScript + "):\n" + initCommands);
try {
cliDriver.processLine(initCommands);
LOG.info("Result from cliDrriver.processLine in createSources=0");
} catch (CommandProcessorException e) {
Assert.fail("Failed during createSources processLine with code=" + e.getResponseCode());
}
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class QTestUtil method executeClientInternal.
private CommandProcessorResponse executeClientInternal(String commands) throws CommandProcessorException {
List<String> cmds = CliDriver.splitSemiColon(commands);
CommandProcessorResponse response = new CommandProcessorResponse();
StringBuilder command = new StringBuilder();
QTestSyntaxUtil qtsu = new QTestSyntaxUtil(this, conf, pd);
qtsu.checkQFileSyntax(cmds);
for (String oneCmd : cmds) {
if (StringUtils.endsWith(oneCmd, "\\")) {
command.append(StringUtils.chop(oneCmd) + "\\;");
continue;
} else {
if (isHiveCommand(oneCmd)) {
command.setLength(0);
}
command.append(oneCmd);
}
if (StringUtils.isBlank(command.toString())) {
continue;
}
String strCommand = command.toString();
try {
if (isCommandUsedForTesting(strCommand)) {
response = executeTestCommand(strCommand);
} else {
response = cliDriver.processLine(strCommand);
}
} catch (CommandProcessorException e) {
if (!ignoreErrors()) {
throw e;
}
}
command.setLength(0);
}
if (SessionState.get() != null) {
// reset
SessionState.get().setLastCommand(null);
}
return response;
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class QTestUtil method executeTestCommand.
private CommandProcessorResponse executeTestCommand(String command) throws CommandProcessorException {
String commandName = command.trim().split("\\s+")[0];
String commandArgs = command.trim().substring(commandName.length());
if (commandArgs.endsWith(";")) {
commandArgs = StringUtils.chop(commandArgs);
}
// replace ${hiveconf:hive.metastore.warehouse.dir} with actual dir if existed.
// we only want the absolute path, so remove the header, such as hdfs://localhost:57145
String wareHouseDir = SessionState.get().getConf().getVar(ConfVars.METASTOREWAREHOUSE).replaceAll("^[a-zA-Z]+://.*?:\\d+", "");
commandArgs = commandArgs.replaceAll("\\$\\{hiveconf:hive\\.metastore\\.warehouse\\.dir\\}", wareHouseDir);
if (SessionState.get() != null) {
SessionState.get().setLastCommand(commandName + " " + commandArgs.trim());
}
enableTestOnlyCmd(SessionState.get().getConf());
try {
CommandProcessor proc = getTestCommand(commandName);
if (proc != null) {
try {
CommandProcessorResponse response = proc.run(commandArgs.trim());
return response;
} catch (CommandProcessorException e) {
SessionState.getConsole().printError(e.toString(), e.getCause() != null ? Throwables.getStackTraceAsString(e.getCause()) : "");
throw e;
}
} else {
throw new RuntimeException("Could not get CommandProcessor for command: " + commandName);
}
} catch (Exception e) {
throw new RuntimeException("Could not execute test command", e);
}
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class CoreHBaseCliDriver method runTest.
@Override
public void runTest(String tname, String fname, String fpath) {
long startTime = System.currentTimeMillis();
try {
System.err.println("Begin query: " + fname);
qt.setInputFile(fpath);
qt.cliInit();
try {
qt.executeClient();
} catch (CommandProcessorException e) {
qt.failedQuery(e.getCause(), e.getResponseCode(), fname, null);
}
QTestProcessExecResult result = qt.checkCliDriverResults();
if (result.getReturnCode() != 0) {
qt.failedDiff(result.getReturnCode(), fname, result.getCapturedOutput());
}
} catch (Exception e) {
qt.failedWithException(e, fname, null);
}
long elapsedTime = System.currentTimeMillis() - startTime;
System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
assertTrue("Test passed", true);
}
use of org.apache.hadoop.hive.ql.processors.CommandProcessorException in project hive by apache.
the class CoreKuduCliDriver method runTest.
@Override
public void runTest(String tname, String fname, String fpath) {
long startTime = System.currentTimeMillis();
try {
System.err.println("Begin query: " + fname);
qt.setInputFile(fpath);
qt.cliInit();
try {
qt.executeClient();
} catch (CommandProcessorException e) {
qt.failedQuery(e.getCause(), e.getResponseCode(), fname, null);
}
QTestProcessExecResult result = qt.checkCliDriverResults();
if (result.getReturnCode() != 0) {
qt.failedDiff(result.getReturnCode(), fname, result.getCapturedOutput());
}
qt.clearPostTestEffects();
} catch (Exception e) {
qt.failedWithException(e, fname, null);
}
long elapsedTime = System.currentTimeMillis() - startTime;
System.err.println("Done query: " + fname + " elapsedTime=" + elapsedTime / 1000 + "s");
assertTrue("Test passed", true);
}
Aggregations