use of org.voltdb_testprocs.updateclasses.jars.TestProcedure in project voltdb by VoltDB.
the class TestUpdateClasses method testUpdateClassesWithSQLStmtChanges.
// See ENG-12536: Test UpdateClasses with changed SQLStmts
@Test
public void testUpdateClassesWithSQLStmtChanges() throws Exception {
System.out.println("\n\n-----\n testUpdateClassesWithSQLStmtChanges \n-----\n\n");
String pathToCatalog = Configuration.getPathToCatalogForTest("updateclasses.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("updateclasses.xml");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema("create table tt (PID varchar(20 BYTES) NOT NULL, CITY varchar(6 BYTES), " + "CONSTRAINT IDX_TT_PKEY PRIMARY KEY (PID)); \n" + "PARTITION TABLE TT ON COLUMN PID;\n");
builder.setUseDDLSchema(true);
boolean success = builder.compile(pathToCatalog, 2, 1, 0);
assertTrue("Schema compilation failed", success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
try {
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
startSystem(config);
ClientResponse resp;
// Testing system can load jar file from class path, but not the internal class files
try {
resp = m_client.callProcedure("TestProcedure", "12345", "boston");
fail("TestProcedure is not loaded");
} catch (ProcCallException e) {
assertTrue(e.getMessage().contains("Procedure TestProcedure was not found"));
}
try {
Class.forName("voter.TestProcedure");
fail("Should not load the class file from the jar file on disk automatically");
} catch (ClassNotFoundException e) {
assertTrue(e.getMessage().contains("voter.TestProcedure"));
}
InMemoryJarfile boom = new InMemoryJarfile(TestProcedure.class.getResource("addSQLStmt.jar"));
resp = m_client.callProcedure("@UpdateClasses", boom.getFullJarBytes(), null);
assertEquals(ClientResponse.SUCCESS, resp.getStatus());
resp = m_client.callProcedure("@AdHoc", "create procedure partition ON TABLE tt COLUMN pid from class voter.TestProcedure;");
assertEquals(ClientResponse.SUCCESS, resp.getStatus());
resp = m_client.callProcedure("TestProcedure", "12345", "boston");
assertEquals(ClientResponse.SUCCESS, resp.getStatus());
// UpdateClass with the new changed StmtSQL jar
boom = new InMemoryJarfile(TestProcedure.class.getResource("addSQLStmtNew.jar"));
resp = m_client.callProcedure("@UpdateClasses", boom.getFullJarBytes(), null);
assertEquals(ClientResponse.SUCCESS, resp.getStatus());
// run with a new query without problems
resp = m_client.callProcedure("TestProcedure", "12345", "boston");
assertEquals(ClientResponse.SUCCESS, resp.getStatus());
// Invalid SQLStmt should fail during UpdateClasses
boom = new InMemoryJarfile(TestProcedure.class.getResource("addSQLStmtInvalid.jar"));
try {
resp = m_client.callProcedure("@UpdateClasses", boom.getFullJarBytes(), null);
fail("Invalid SQLStmt should fail during UpdateClasses");
} catch (ProcCallException e) {
assertTrue(e.getMessage().contains("Failed to plan for statement"));
assertTrue(e.getMessage().contains("user lacks privilege or object not found: TT_INVALID_QUERY"));
}
} finally {
teardownSystem();
}
}
Aggregations