use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestMPMultiRoundTripSuite method suite.
public static junit.framework.Test suite() {
VoltServerConfig config = null;
final MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestMPMultiRoundTripSuite.class);
final VoltProjectBuilder project = new VoltProjectBuilder();
project.addStmtProcedure("CountP1", "select count(*) from p1;");
project.addStmtProcedure("GetP1", "select * from p1;");
// update non-unique, non-partitioning attribute
project.addStmtProcedure("UpdateP1", "update p1 set b2 = 2");
project.addStmtProcedure("SumP1", "select sum(b2) from p1;");
project.addStmtProcedure("UpdateR1", "update r1 set b2 = 2");
project.addStmtProcedure("SumR1", "select sum(b2) from r1;");
// update all pkeys to the same value.
project.addStmtProcedure("ConstraintViolationUpdate", "update p1 set b1 = 1");
project.addStmtProcedure("SumB1", "select sum(b1) from p1;");
project.addStmtProcedure("ConstraintViolationUpdate_R", "update r1 set b1 = 1");
project.addStmtProcedure("SumB1_R", "select sum(b1) from r1;");
// update all partitioning keys to the same value.
project.addStmtProcedure("PartitionViolationUpdate", "update p1 set key = 1");
project.addStmtProcedure("SumKey", "select sum(key) from p1;");
// Single-part update
project.addStmtProcedure("UpdateP1SP", "update p1 set b2 = 2 where key = ?", "p1.key:0");
project.addProcedures(PROCEDURES);
try {
project.addLiteralSchema("CREATE TABLE p1(key INTEGER NOT NULL, b1 INTEGER NOT NULL ASSUMEUNIQUE, " + "b2 INTEGER NOT NULL, a2 VARCHAR(10) NOT NULL, PRIMARY KEY (b1,key)); " + "PARTITION TABLE P1 ON COLUMN key;");
// a replicated table (should not generate procedures).
project.addLiteralSchema("CREATE TABLE r1(key INTEGER NOT NULL, b1 INTEGER NOT NULL, " + "b2 INTEGER NOT NULL, a2 VARCHAR(10) NOT NULL, PRIMARY KEY (b1));");
} catch (IOException error) {
fail(error.getMessage());
}
// JNI
config = new LocalCluster("sqltypes-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI);
boolean t1 = config.compile(project);
assertTrue(t1);
builder.addServerConfig(config);
config = new LocalCluster("sqltypes-onesite.jar", 3, 1, 0, BackendTarget.NATIVE_EE_JNI);
boolean t3 = config.compile(project);
assertTrue(t3);
builder.addServerConfig(config);
// CLUSTER
config = new LocalCluster("sqltypes-cluster.jar", 2, 2, 0, BackendTarget.NATIVE_EE_JNI);
boolean t2 = config.compile(project);
assertTrue(t2);
builder.addServerConfig(config);
return builder;
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestJoinsSuite method suite.
public static junit.framework.Test suite() {
MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestJoinsSuite.class);
VoltProjectBuilder project = new VoltProjectBuilder();
project.addSchema(TestJoinsSuite.class.getResource("testjoins-ddl.sql"));
// try {
// project.addLiteralSchema("CREATE PROCEDURE R4_INSERT AS INSERT INTO R4 VALUES(?, ?);");
// }
// catch (IOException e) {
// e.printStackTrace();
// fail();
// }
LocalCluster config;
config = new LocalCluster("testjoin-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI);
assertTrue(config.compile(project));
builder.addServerConfig(config);
// Cluster
config = new LocalCluster("testjoin-cluster.jar", 2, 3, 1, BackendTarget.NATIVE_EE_JNI);
assertTrue(config.compile(project));
builder.addServerConfig(config);
// HSQLDB
config = new LocalCluster("testjoin-hsql.jar", 1, 1, 0, BackendTarget.HSQLDB_BACKEND);
assertTrue(config.compile(project));
builder.addServerConfig(config);
return builder;
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestJSONInterface method testLongQuerySTring.
public void testLongQuerySTring() throws Exception {
try {
String simpleSchema = "CREATE TABLE foo (\n" + " bar BIGINT NOT NULL,\n" + " PRIMARY KEY (bar)\n" + ");";
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema(simpleSchema);
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();
//create a large query string
final StringBuilder s = new StringBuilder();
s.append("Procedure=@Statistics&Parameters=[TABLE]&jsonpxx=");
for (int i = 0; i < 450000; i++) {
s.append(i);
}
String query = s.toString();
//call multiple times.
for (int i = 0; i < 500; i++) {
String response = callProcOverJSONRaw(query, 200);
System.out.println(response);
Response r = responseFromJSON(response);
assertEquals(ClientResponse.UNEXPECTED_FAILURE, r.status);
//make sure good queries can still work.
ParameterSet pset = ParameterSet.fromArrayNoCopy("select * from foo");
String responseJSON = callProcOverJSON("@AdHoc", pset, null, null, false);
System.out.println(responseJSON);
r = responseFromJSON(responseJSON);
assertEquals(ClientResponse.SUCCESS, r.status);
}
//make sure good queries can still work after.
ParameterSet pset = ParameterSet.fromArrayNoCopy("select * from foo");
String responseJSON = callProcOverJSON("@AdHoc", pset, null, null, false);
System.out.println(responseJSON);
Response response = responseFromJSON(responseJSON);
System.out.println(response.statusString);
assertEquals(ClientResponse.SUCCESS, response.status);
} finally {
if (server != null) {
server.shutdown();
server.join();
}
server = null;
}
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestJSONInterface method testExportTypes.
public void testExportTypes() throws Exception {
try {
VoltProjectBuilder builder = new VoltProjectBuilder();
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 exportTypes
String json = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment/export/types", null, null, null, 200, "application/json");
JSONObject jobj = new JSONObject(json);
assertTrue(jobj.getString("types").contains("FILE"));
assertTrue(jobj.getString("types").contains("JDBC"));
assertTrue(jobj.getString("types").contains("KAFKA"));
assertTrue(jobj.getString("types").contains("HTTP"));
assertTrue(jobj.getString("types").contains("RABBITMQ"));
assertTrue(jobj.getString("types").contains("CUSTOM"));
} finally {
if (server != null) {
server.shutdown();
server.join();
}
server = null;
}
}
use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.
the class TestJSONInterface method testDeploymentSecurityAuthorizationHashed.
public void testDeploymentSecurityAuthorizationHashed() 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);
UserInfo[] users = new UserInfo[] { new UserInfo("user1", "admin", new String[] { "user" }), new UserInfo("user2", "admin", new String[] { "administrator" }) };
builder.addUsers(users);
// suite defines its own ADMINISTRATOR user
builder.setSecurityEnabled(true, false);
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 deployment bad user
String dep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", "user1", "admin", "hashed", 401, "application/json");
assertTrue(dep.contains("Permission denied"));
//good user
dep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", "user2", "admin", "hashed", 200, "application/json");
assertTrue(dep.contains("cluster"));
//Download deployment bad user
dep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment/download", "user1", "admin", "hashed", 401, "application/json");
assertTrue(dep.contains("Permission denied"));
//good user
dep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment/download", "user2", "admin", "hashed", 200, "text/xml");
assertTrue(dep.contains("<deployment>"));
assertTrue(dep.contains("</deployment>"));
dep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment/download", "user2", "admin", "hashed256", 200, "text/xml");
assertTrue(dep.contains("<deployment>"));
assertTrue(dep.contains("</deployment>"));
//Test back with sha1
dep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment/download", "user2", "admin", "hashed", 200, "text/xml");
assertTrue(dep.contains("<deployment>"));
assertTrue(dep.contains("</deployment>"));
} finally {
if (server != null) {
server.shutdown();
server.join();
}
server = null;
}
}
Aggregations