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();
}
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());
}
Aggregations