use of org.voltdb.regressionsuites.LocalCluster in project voltdb by VoltDB.
the class CrashVoltDBTest method testSimple.
@Test
public void testSimple() throws Exception {
String simpleSchema = "create table blah (" + "ival bigint default 0 not null, " + "PRIMARY KEY(ival));";
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema(simpleSchema);
builder.addProcedures(CrashVoltDBProc.class);
/*boolean success = builder.compile(Configuration.getPathToCatalogForTest("crash.jar"), 1, 1, 0, "localhost");
assert(success);
MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("crash.xml"));*/
LocalCluster cluster = new LocalCluster("crash.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
cluster.setHasLocalServer(true);
boolean success = cluster.compile(builder);
assert (success);
cluster.startUp(true);
final String listener = cluster.getListenerAddresses().get(0);
final Client client = ClientFactory.createClient();
//client.createConnection(listener);
client.createConnection(listener);
try {
client.callProcedure("CrashVoltDBProc");
} catch (Exception e) {
}
Thread.sleep(10000);
client.close();
cluster.shutDown();
}
use of org.voltdb.regressionsuites.LocalCluster in project voltdb by VoltDB.
the class TestSSL method startLocalCluster.
private void startLocalCluster(String keyStorePath, String keyStorePasswd, String certStorePath, String certStorePasswd) throws Exception {
VoltProjectBuilder builder = getBuilderForTest();
if (keyStorePath != null) {
builder.setKeyStoreInfo(keyStorePath, keyStorePasswd);
}
if (certStorePath != null) {
builder.setCertStoreInfo(certStorePath, certStorePasswd);
}
System.setProperty("io.netty.leakDetection.level", "PARANOID");
Map<String, String> env = ImmutableMap.of("io.netty.leakDetection.level", "PARANOID");
m_cluster = new LocalCluster("ssl.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI, LocalCluster.FailureState.ALL_RUNNING, false, true, env);
boolean success = m_cluster.compile(builder);
assertTrue(success);
MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("ssl.xml"));
m_cluster.setHasLocalServer(false);
m_cluster.startUp();
}
use of org.voltdb.regressionsuites.LocalCluster in project voltdb by VoltDB.
the class TestAllPartitionProcedureCalls method setUp.
@Before
public void setUp() throws Exception {
VoltFile.recursivelyDelete(new File("/tmp/" + System.getProperty("user.name")));
File f = new File("/tmp/" + System.getProperty("user.name"));
f.mkdirs();
if (TheHashinator.getConfiguredHashinatorType() != TheHashinator.HashinatorType.ELASTIC)
return;
cluster = new LocalCluster("client-all-partitions.jar", 4, 2, 0, BackendTarget.NATIVE_EE_JNI);
cluster.overrideAnyRequestForValgrind();
cluster.setHasLocalServer(false);
VoltProjectBuilder project = new VoltProjectBuilder();
project.setUseDDLSchema(true);
project.addSchema(TestAllPartitionProcedureCalls.class.getResource("allpartitioncall.sql"));
boolean success = cluster.compile(project);
assertTrue(success);
cluster.startUp();
ClientConfig config = new ClientConfig();
config.setClientAffinity(false);
client = ClientFactory.createClient(config);
client.createConnection("", cluster.port(0));
load(client, "TABLE_INT_PARTITION");
load(client, "TABLE_STRING_PARTITION");
clientWithAffinity = ClientFactory.createClient();
clientWithAffinity.createConnection("", cluster.port(0));
}
use of org.voltdb.regressionsuites.LocalCluster in project voltdb by VoltDB.
the class TestAdhocCreateDropJavaProc method testBasic.
@Test
public void testBasic() throws Exception {
System.out.println("\n\n-----\n testBasic \n-----\n\n");
String pathToCatalog = Configuration.getPathToCatalogForTest("updateclasses.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("updateclasses.xml");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("-- Don't care");
builder.setUseDDLSchema(true);
boolean success = builder.compile(pathToCatalog, 2, 1, 0);
assertTrue("Schema compilation failed", success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
try {
LocalCluster cluster = new LocalCluster("updateclasses.jar", 2, 1, 0, BackendTarget.NATIVE_EE_JNI);
cluster.compile(builder);
cluster.setHasLocalServer(false);
cluster.startUp();
m_client = ClientFactory.createClient();
m_client.createConnection(cluster.getListenerAddress(0));
ClientResponse resp;
// Can't create a procedure without a class
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
System.out.println("CLASSES: " + resp.getResults()[0]);
try {
resp = m_client.callProcedure("@AdHoc", "create procedure from class org.voltdb_testprocs.updateclasses.testImportProc");
fail("Shouldn't be able to create a procedure backed by no class");
} catch (ProcCallException pce) {
}
assertFalse(findProcedureInSystemCatalog("testImportProc"));
InMemoryJarfile jarfile = new InMemoryJarfile();
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.testImportProc.class);
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
// call the procedure. Maybe this gets better in the future
try {
resp = m_client.callProcedure("@AdHoc", "create procedure from class org.voltdb_testprocs.updateclasses.testImportProc");
} catch (ProcCallException pce) {
fail("We allow procedures to be created with unsatisfied dependencies");
}
assertTrue(findProcedureInSystemCatalog("testImportProc"));
// Make sure we don't crash when we call it though
try {
resp = m_client.callProcedure("testImportProc");
fail("Should return an error and not crash calling procedure w/ bad dependencies");
} catch (ProcCallException pce) {
assertTrue(pce.getMessage().contains("ClassNotFoundException"));
}
// Okay, add the missing dependency
jarfile = new InMemoryJarfile();
comp = new VoltCompiler(false);
comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.NoMeaningClass.class);
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
// now we should be able to call it
try {
resp = m_client.callProcedure("testImportProc");
} catch (ProcCallException pce) {
fail("Should be able to call fully consistent procedure");
}
assertEquals(10L, resp.getResults()[0].asScalarLong());
// Now try to remove the procedure class
try {
resp = m_client.callProcedure("@UpdateClasses", null, "org.voltdb_testprocs.updateclasses.*");
fail("Shouldn't be able to rip a class out from under an active proc");
} catch (ProcCallException pce) {
assertTrue(pce.getMessage(), pce.getMessage().contains("Cannot load class for procedure: org.voltdb_testprocs.updateclasses.testImportProc"));
}
// Make sure we didn't purge anything (even the extra dependency)
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
assertEquals(2, resp.getResults()[0].getRowCount());
// Okay, drop the procedure first
try {
resp = m_client.callProcedure("@AdHoc", "drop procedure testImportProc");
} catch (ProcCallException pce) {
fail("Should be able to drop a stored procedure");
}
assertFalse(findProcedureInSystemCatalog("testImportProc"));
// Now try to remove the procedure class again
try {
resp = m_client.callProcedure("@UpdateClasses", null, "org.voltdb_testprocs.updateclasses.*");
} catch (ProcCallException pce) {
fail("Should be able to remove the classes for an inactive procedure");
}
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
// no classes in catalog
assertEquals(0, resp.getResults()[0].getRowCount());
m_client.close();
cluster.shutDown();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.voltdb.regressionsuites.LocalCluster in project voltdb by VoltDB.
the class TestAdhocCreateDropJavaProc method testCreateUsingExistingImport.
// This test should trigger the same failure seen in ENG-6611
@Test
public void testCreateUsingExistingImport() throws Exception {
System.out.println("\n\n-----\n testCreateUsingExistingImport \n-----\n\n");
String pathToCatalog = Configuration.getPathToCatalogForTest("updateclasses.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("updateclasses.xml");
VoltProjectBuilder builder = new VoltProjectBuilder();
// Start off with the dependency imported
builder.addLiteralSchema("import class org.voltdb_testprocs.updateclasses.NoMeaningClass;");
builder.setUseDDLSchema(true);
boolean success = builder.compile(pathToCatalog, 2, 1, 0);
assertTrue("Schema compilation failed", success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
try {
LocalCluster cluster = new LocalCluster("updateclasses.jar", 2, 1, 0, BackendTarget.NATIVE_EE_JNI);
cluster.compile(builder);
cluster.setHasLocalServer(false);
cluster.startUp();
m_client = ClientFactory.createClient();
m_client.createConnection(cluster.getListenerAddress(0));
ClientResponse resp;
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
System.out.println(resp.getResults()[0]);
// Now load the procedure requiring the already-resident dependency
InMemoryJarfile jarfile = new InMemoryJarfile();
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.testImportProc.class);
try {
resp = m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
} catch (ProcCallException pce) {
pce.printStackTrace();
fail("Triggered ENG-6611!");
}
resp = m_client.callProcedure("@SystemCatalog", "CLASSES");
assertEquals(2, resp.getResults()[0].getRowCount());
// create the proc and make sure it runs
try {
resp = m_client.callProcedure("@AdHoc", "create procedure from class org.voltdb_testprocs.updateclasses.testImportProc");
} catch (ProcCallException pce) {
fail("Should be able to create testImportProc procedure");
}
assertTrue(findProcedureInSystemCatalog("testImportProc"));
try {
resp = m_client.callProcedure("testImportProc");
} catch (ProcCallException pce) {
pce.printStackTrace();
fail("Should be able to call fully consistent procedure");
}
assertEquals(10L, resp.getResults()[0].asScalarLong());
m_client.close();
cluster.shutDown();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations