use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartAction method testInitStartAction.
/** Tests starting an empty database with the NewCLI commands "init" and "start",
* plus a few error cases.
*/
@Test
public void testInitStartAction() throws Exception {
File deplFH = new VoltFile(new VoltFile(new VoltFile(rootDH, "voltdbroot"), "config"), "deployment.xml");
Configuration c1 = new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath(), "force", "deployment", legacyDeploymentFH.getPath() });
ServerThread server = new ServerThread(c1);
server.setUncaughtExceptionHandler(handleUncaught);
server.start();
server.join();
expectSimulatedExit(0);
assertTrue(deplFH.exists() && deplFH.isFile() && deplFH.canRead());
if (c1.m_isEnterprise) {
assertTrue(cmdlogDH.exists() && cmdlogDH.isDirectory() && cmdlogDH.canRead() && cmdlogDH.canWrite() && cmdlogDH.canExecute());
for (int i = 0; i < 10; ++i) {
new FileOutputStream(new File(cmdlogDH, String.format("dummy-%02d.log", i))).close();
}
assertEquals(10, cmdlogDH.list().length);
}
serverException.set(null);
// server thread sets m_forceVoltdbCreate to true by default
c1 = new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath(), "force", "deployment", legacyDeploymentFH.getPath() });
assertTrue(c1.m_forceVoltdbCreate);
server = new ServerThread(c1);
server.setUncaughtExceptionHandler(handleUncaught);
server.start();
server.join();
expectSimulatedExit(0);
assertTrue(deplFH.exists() && deplFH.isFile() && deplFH.canRead());
if (c1.m_isEnterprise) {
assertTrue(cmdlogDH.exists() && cmdlogDH.isDirectory() && cmdlogDH.canRead() && cmdlogDH.canWrite() && cmdlogDH.canExecute());
assertEquals(0, cmdlogDH.list().length);
}
try {
c1 = new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath() });
fail("did not detect prexisting initialization");
} catch (VoltDB.SimulatedExitException e) {
assertEquals(-1, e.getStatus());
}
VoltDB.wasCrashCalled = false;
VoltDB.crashMessage = null;
serverException.set(null);
c1 = new Configuration(new String[] { "create", "deployment", legacyDeploymentFH.getPath(), "host", "localhost" });
server = new ServerThread(c1);
server.setUncaughtExceptionHandler(handleUncaught);
server.start();
server.join();
assertNotNull(serverException.get());
assertTrue(serverException.get() instanceof AssertionError);
assertTrue(VoltDB.wasCrashCalled);
assertTrue(VoltDB.crashMessage.contains("Cannot use legacy start action"));
if (!c1.m_isEnterprise)
return;
clearCrash();
c1 = new Configuration(new String[] { "recover", "deployment", legacyDeploymentFH.getPath(), "host", "localhost" });
server = new ServerThread(c1);
server.setUncaughtExceptionHandler(handleUncaught);
server.start();
server.join();
assertNotNull(serverException.get());
assertTrue(serverException.get() instanceof AssertionError);
assertTrue(VoltDB.wasCrashCalled);
assertTrue(VoltDB.crashMessage.contains("Cannot use legacy start action"));
// this test which action should be considered legacy
EnumSet<StartAction> legacyOnes = EnumSet.complementOf(EnumSet.of(StartAction.INITIALIZE, StartAction.PROBE, StartAction.GET));
assertTrue(legacyOnes.stream().allMatch(StartAction::isLegacy));
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartAction method testInitWithSchemaInvalidJunkSchema.
/** Test that a valid schema with no procedures can be used to stage a matching catalog.
* @throws Exception upon failure or error
*/
@Test
public void testInitWithSchemaInvalidJunkSchema() throws Exception {
File schemaFile = Files.createTempDirectory("junk").toFile();
try {
new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath(), "force", "schema", schemaFile.getPath() });
fail("did not detect unusable schema file");
} catch (VoltDB.SimulatedExitException e) {
assertEquals(e.getStatus(), -1);
}
assertEquals(true, schemaFile.delete());
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartAction method testInitWithSchemaInvalidMissingClass.
/** Test that a valid schema with no procedures can be used to stage a matching catalog.
* @throws Exception upon failure or error
*/
@Test
public void testInitWithSchemaInvalidMissingClass() throws Exception {
String schema = "CREATE TABLE unicorns" + " (horn_size integer DEFAULT 12 NOT NULL," + " name varchar(32) DEFAULT 'Pixie' NOT NULL," + " PRIMARY KEY(name));" + "PARTITION TABLE unicorns ON COLUMN name;" + "CREATE PROCEDURE FROM CLASS org.voltdb.unicorns.ComputeSocialStanding;";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
Configuration c1 = new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath(), "force", "schema", schemaFile.getPath() });
ServerThread server = new ServerThread(c1);
server.setUncaughtExceptionHandler(handleUncaught);
server.start();
server.join();
assertNotNull(serverException.get());
assertTrue(serverException.get().getMessage().equals("Faux crash of VoltDB successful."));
assertTrue(VoltDB.wasCrashCalled);
assertTrue(VoltDB.crashMessage.contains("Could not compile specified schema"));
assertEquals(true, schemaFile.delete());
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartLocalClusterAllOutOfProcess method testGetDeployment.
// Test get deployment
public void testGetDeployment() throws Exception {
File deployment = File.createTempFile("get_deployment", ".xm");
if (deployment.exists())
deployment.delete();
Configuration config = new VoltDB.Configuration(new String[] { "get", "deployment", "getvoltdbroot", voltDBRootParentPath, "file", deployment.getAbsolutePath() + "l", "forceget" });
ServerThread server = new ServerThread(config);
try {
server.cli();
} catch (Throwable ex) {
//Good
}
DeploymentType dt = CatalogUtil.parseDeployment(deployment.getAbsolutePath() + "l");
assertNotNull(dt);
assertEquals(dt.getPaths().getVoltdbroot().getPath(), voltDbRootPath);
}
use of org.voltdb.VoltDB.Configuration in project voltdb by VoltDB.
the class TestInitStartLocalClusterInProcess method testGetDeployment.
// Test get deployment
public void testGetDeployment() throws Exception {
File deployment = File.createTempFile("get_deployment", ".xm");
Configuration config = new VoltDB.Configuration(new String[] { "get", "deployment", "getvoltdbroot", voltDBRootParentPath, "file", deployment.getAbsolutePath() + "l", "forceget" });
ServerThread server = new ServerThread(config);
try {
server.cli();
} catch (Throwable ex) {
//Good
}
DeploymentType dt = CatalogUtil.parseDeployment(deployment.getAbsolutePath() + "l");
assertNotNull(dt);
assertEquals(dt.getPaths().getVoltdbroot().getPath(), voltDbRootPath);
}
Aggregations