Search in sources :

Example 1 with Configuration

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));
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltFile(org.voltdb.utils.VoltFile) FileOutputStream(java.io.FileOutputStream) SimulatedExitException(org.voltdb.VoltDB.SimulatedExitException) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File) Test(org.junit.Test)

Example 2 with Configuration

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());
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) SimulatedExitException(org.voltdb.VoltDB.SimulatedExitException) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File) Test(org.junit.Test)

Example 3 with Configuration

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());
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File) Test(org.junit.Test)

Example 4 with Configuration

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);
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File)

Example 5 with Configuration

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);
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) File(java.io.File)

Aggregations

Configuration (org.voltdb.VoltDB.Configuration)15 File (java.io.File)13 ServerThread (org.voltdb.ServerThread)9 Test (org.junit.Test)6 VoltFile (org.voltdb.utils.VoltFile)6 SimulatedExitException (org.voltdb.VoltDB.SimulatedExitException)3 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)3 BeforeClass (org.junit.BeforeClass)2 ClientConfig (org.voltdb.client.ClientConfig)2 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)2 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)2 ClassPath (com.google_voltpatches.common.reflect.ClassPath)1 ClassInfo (com.google_voltpatches.common.reflect.ClassPath.ClassInfo)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 VoltCompiler (org.voltdb.compiler.VoltCompiler)1