use of org.apache.hive.hcatalog.api.HCatDatabase in project hive by apache.
the class TestCommands method testDropDatabaseCommand.
@Test
public void testDropDatabaseCommand() throws HCatException, CommandNeedRetryException {
String dbName = "cmd_testdb";
int evid = 999;
Command testCmd = new DropDatabaseCommand(dbName, evid);
assertEquals(evid, testCmd.getEventId());
assertEquals(1, testCmd.get().size());
assertEquals(true, testCmd.isRetriable());
assertEquals(false, testCmd.isUndoable());
CommandTestUtils.testCommandSerialization(testCmd);
client.dropDatabase(dbName, true, HCatClient.DropDBMode.CASCADE);
client.createDatabase(HCatCreateDBDesc.create(dbName).ifNotExists(false).build());
HCatDatabase db = client.getDatabase(dbName);
assertNotNull(db);
LOG.info("About to run :" + testCmd.get().get(0));
driver.run(testCmd.get().get(0));
Exception onfe = null;
try {
HCatDatabase db_del = client.getDatabase(dbName);
} catch (Exception e) {
onfe = e;
}
assertNotNull(onfe);
assertTrue(onfe instanceof ObjectNotFoundException);
}
use of org.apache.hive.hcatalog.api.HCatDatabase in project hive by apache.
the class TestCommands method testNoopReplEximCommands.
@Test
public void testNoopReplEximCommands() throws CommandNeedRetryException, IOException {
// repl noop export on non-existant table, has repl.noop, does not error
// import repl noop dump, no error
int evid = 333;
String exportLocation = TEST_PATH + File.separator + "testNoopReplExim";
String dbName = "doesNotExist" + System.currentTimeMillis();
String tableName = "nope" + System.currentTimeMillis();
ExportCommand noopExportCmd = new ExportCommand(dbName, tableName, null, exportLocation, false, evid);
LOG.info("About to run :" + noopExportCmd.get().get(0));
CommandProcessorResponse ret = driver.run(noopExportCmd.get().get(0));
assertEquals(ret.getResponseCode() + ":" + ret.getErrorMessage(), null, ret.getException());
List<String> exportPaths = noopExportCmd.cleanupLocationsAfterEvent();
assertEquals(1, exportPaths.size());
String metadata = getMetadataContents(exportPaths.get(0));
LOG.info("Export returned the following _metadata contents:");
LOG.info(metadata);
assertTrue(metadata + "did not match \"repl.noop\"=\"true\"", metadata.matches(".*\"repl.noop\":\"true\".*"));
ImportCommand noopImportCmd = new ImportCommand(dbName, tableName, null, exportLocation, false, evid);
LOG.info("About to run :" + noopImportCmd.get().get(0));
CommandProcessorResponse ret2 = driver.run(noopImportCmd.get().get(0));
assertEquals(ret2.getResponseCode() + ":" + ret2.getErrorMessage(), null, ret2.getException());
Exception onfe = null;
try {
HCatDatabase d_doesNotExist = client.getDatabase(dbName);
} catch (Exception e) {
onfe = e;
}
assertNotNull(onfe);
assertTrue(onfe instanceof ObjectNotFoundException);
}
Aggregations