Search in sources :

Example 1 with SimulatedExitException

use of org.voltdb.VoltDB.SimulatedExitException in project voltdb by VoltDB.

the class TestCollector method testBasicFilesAndCrash.

/*
     * For each type of file that need to be collected, check whether it actually appears in the collection
     * currently sar data and /var/log/syslog* are ignored in testing
     * since in some cluster machines sar is not enabled and syslog* can only be read by root
     */
@Test
public void testBasicFilesAndCrash() throws Exception {
    //Terrible hack, wait for config logging thread to finish
    Thread.sleep(STARTUP_DELAY);
    try {
        client.callProcedure("CrashVoltDBProc");
    } catch (Exception e) {
    }
    client.close();
    cluster.shutDown();
    // generate heap dump
    File heapdumpGenerated = new File("/tmp", "java_pid" + m_pid + ".hprof");
    PrintWriter writer = new PrintWriter(heapdumpGenerated.getPath());
    heapdumpGenerated.deleteOnExit();
    writer.println("fake heapdump file");
    writer.close();
    File f = new File(m_voltDbRootPath, "systemcheck");
    f.createNewFile();
    FileOutputStream fStream = new FileOutputStream(f);
    fStream.write("fake text for test".getBytes());
    fStream.close();
    ZipFile collectionZip;
    m_outputFileName = new File(m_voltDbRootPath).getParent() + File.separator + m_pid + "_withCrash.zip";
    deleteOutputFileIfExists();
    collectionZip = collect(false, 50, false);
    verifyBasicTestCollect(collectionZip);
    collectionZip.close();
    deleteOutputFileIfExists();
    // negative test - prefix and output set at same time
    m_prefix = "foo_" + m_pid;
    boolean caughtExcp = false;
    try {
        collect(true, 3, false);
    } catch (SimulatedExitException excp) {
        System.out.println(excp.getMessage());
        caughtExcp = true;
    }
    assertTrue(caughtExcp);
    m_outputFileName = "";
    m_prefix = "prefix" + m_pid;
    collectionZip = collect(false, 3, true);
    verifyBasicTestCollect(collectionZip);
    collectionZip.close();
}
Also used : SimulatedExitException(org.voltdb.VoltDB.SimulatedExitException) ZipFile(java.util.zip.ZipFile) FileOutputStream(java.io.FileOutputStream) ZipFile(java.util.zip.ZipFile) File(java.io.File) SimulatedExitException(org.voltdb.VoltDB.SimulatedExitException) ParseException(java.text.ParseException) JSONException(org.json_voltpatches.JSONException) PrintWriter(java.io.PrintWriter) Test(org.junit.Test) JUnit4LocalClusterTest(org.voltdb.regressionsuites.JUnit4LocalClusterTest)

Example 2 with SimulatedExitException

use of org.voltdb.VoltDB.SimulatedExitException in project voltdb by VoltDB.

the class TestInitStartAction method testInitWithSchemaValidWithProcedures.

/** Test that a valid schema with procedures can be used to stage a matching catalog,
     * but running a second time without 'init --force' fails due to existing artifacts.
     * @throws Exception upon failure or error
     */
@Test
public void testInitWithSchemaValidWithProcedures() throws Exception {
    String schema = "create table books" + " (cash integer default 23 not null," + " title varchar(3) default 'foo'," + " PRIMARY KEY(cash));" + "PARTITION TABLE books ON COLUMN cash;" + "CREATE PROCEDURE FROM CLASS org.voltdb.compiler.procedures.AddBook;";
    File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
    {
        // valid use case
        Configuration c1 = new Configuration(new String[] { "initialize", "force", "voltdbroot", rootDH.getPath(), "schema", schemaFile.getPath() });
        ServerThread server = new ServerThread(c1);
        server.setUncaughtExceptionHandler(handleUncaught);
        server.start();
        server.join();
        expectSimulatedExit(0);
        validateStagedCatalog(schema, null);
        clearCrash();
    }
    try {
        // second attempt is not valid due to existing artifacts
        new Configuration(new String[] { "initialize", "voltdbroot", rootDH.getPath(), "schema", schemaFile.getPath() });
    } catch (SimulatedExitException e) {
        assertEquals(e.getStatus(), -1);
    }
    assertEquals(true, schemaFile.delete());
}
Also used : SimulatedExitException(org.voltdb.VoltDB.SimulatedExitException) Configuration(org.voltdb.VoltDB.Configuration) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)2 Test (org.junit.Test)2 SimulatedExitException (org.voltdb.VoltDB.SimulatedExitException)2 FileOutputStream (java.io.FileOutputStream)1 PrintWriter (java.io.PrintWriter)1 ParseException (java.text.ParseException)1 ZipFile (java.util.zip.ZipFile)1 JSONException (org.json_voltpatches.JSONException)1 Configuration (org.voltdb.VoltDB.Configuration)1 JUnit4LocalClusterTest (org.voltdb.regressionsuites.JUnit4LocalClusterTest)1 VoltFile (org.voltdb.utils.VoltFile)1