use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestJSONInterface method testProfile.
public void testProfile() throws Exception {
try {
String simpleSchema = "CREATE TABLE foo (\n" + " bar BIGINT NOT NULL,\n" + " PRIMARY KEY (bar)\n" + ");";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(simpleSchema);
String schemaPath = schemaFile.getPath();
schemaPath = URLEncoder.encode(schemaPath, "UTF-8");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addSchema(schemaPath);
builder.addPartitionInfo("foo", "bar");
builder.addProcedures(DelayProc.class);
builder.setHTTPDPort(8095);
boolean success = builder.compile(Configuration.getPathToCatalogForTest("json.jar"));
assertTrue(success);
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = config.setPathToCatalogForTest("json.jar");
config.m_pathToDeployment = builder.getPathToDeployment();
server = new ServerThread(config);
server.start();
server.waitForInitialization();
//Get profile
String dep = getUrlOverJSON(protocolPrefix + "localhost:8095/profile", null, null, null, 200, "application/json");
assertTrue(dep.contains("\"user\""));
assertTrue(dep.contains("\"permissions\""));
} finally {
if (server != null) {
server.shutdown();
server.join();
}
server = null;
}
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestCanonicalDDLThroughSQLcmd method secondCanonicalDDLFromAdhoc.
private void secondCanonicalDDLFromAdhoc() throws Exception {
String pathToCatalog = Configuration.getPathToCatalogForTest("emptyDDL.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("emptyDDL.xml");
VoltCompiler compiler = new VoltCompiler(false);
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.setUseDDLSchema(true);
boolean success = builder.compile(pathToCatalog);
assertTrue(success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
startSystem(config);
m_client.callProcedure("@AdHoc", firstCanonicalDDL);
// First line of canonical DDL differs thanks to creation time. Avoid
// it in the comparison
// Sanity check that we're not trimming the entire fullddl.sql file away
assertTrue(firstCanonicalDDL.indexOf('\n') < 100);
String secondDDL = compiler.getCanonicalDDL();
assertEquals(firstCanonicalDDL.substring(firstCanonicalDDL.indexOf('\n')), secondDDL.substring(secondDDL.indexOf('\n')));
teardownSystem();
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestCanonicalDDLThroughSQLcmd method secondCanonicalDDLFromSQLcmd.
private void secondCanonicalDDLFromSQLcmd(boolean fastModeDDL) throws Exception {
String pathToCatalog = Configuration.getPathToCatalogForTest("emptyDDL.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("emptyDDL.xml");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.setUseDDLSchema(true);
PortGenerator pg = new PortGenerator();
int httpdPort = pg.next();
builder.setHTTPDPort(httpdPort);
boolean success = builder.compile(pathToCatalog);
assertTrue(success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
startSystem(config);
String roundtripDDL;
assert (firstCanonicalDDL != null);
if (!triedSqlcmdDryRun) {
assertEquals("sqlcmd dry run failed -- maybe some sqlcmd component (the voltdb jar file?) needs to be rebuilt.", 0, callSQLcmd("\n", fastModeDDL));
triedSqlcmdDryRun = true;
}
assertEquals("sqlcmd failed on input:\n" + firstCanonicalDDL, 0, callSQLcmd(firstCanonicalDDL, fastModeDDL));
roundtripDDL = getDDLFromHTTP(httpdPort);
// IZZY: we force single statement SQL keywords to lower case, it seems
// Sanity check that we're not trimming the entire fullddl.sql file away
assertTrue(firstCanonicalDDL.indexOf('\n') < 100);
assertEquals(firstCanonicalDDL.substring(firstCanonicalDDL.indexOf('\n')).toLowerCase(), roundtripDDL.substring(roundtripDDL.indexOf('\n')).toLowerCase());
assertEquals("sqlcmd failed on last call", 0, callSQLcmd("CREATE TABLE NONSENSE (id INTEGER);\n", fastModeDDL));
roundtripDDL = getDDLFromHTTP(httpdPort);
assertTrue(firstCanonicalDDL.indexOf('\n') < 100);
assertFalse(firstCanonicalDDL.substring(firstCanonicalDDL.indexOf('\n')).toLowerCase().equals(roundtripDDL.substring(roundtripDDL.indexOf('\n')).toLowerCase()));
teardownSystem();
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestCatalogDiffs method testAddNonNullityRejected.
public void testAddNonNullityRejected() throws IOException {
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
// start with a table
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT , PRIMARY KEY(C1));");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testAddNonNullity1.jar"));
Catalog catOriginal = catalogForJar(testDir + File.separator + "testAddNonNullity1.jar");
// add a non-null constraint
builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL, PRIMARY KEY(C1));");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testAddNonNullity2.jar"));
Catalog catUpdated = catalogForJar(testDir + File.separator + "testAddNonNullity2.jar");
verifyDiffIfEmptyTable(catOriginal, catUpdated);
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestCatalogDiffs method testRemoveTableConstraint.
public void testRemoveTableConstraint() throws IOException {
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
// with the primary key
Catalog catOriginal = getCatalogForTable("A", "dropconstraint1");
// without the primary key
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT DEFAULT 0 NOT NULL);");
builder.addPartitionInfo("A", "C1");
builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "dropconstraint2.jar"));
Catalog catUpdated = catalogForJar(testDir + File.separator + "dropconstraint2.jar");
verifyDiff(catOriginal, catUpdated);
}
Aggregations