Search in sources :

Example 46 with VoltProjectBuilder

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;
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) File(java.io.File)

Example 47 with VoltProjectBuilder

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();
}
Also used : VoltDB(org.voltdb.VoltDB) VoltCompiler(org.voltdb.compiler.VoltCompiler) Configuration(org.voltdb.VoltDB.Configuration) SSLConfiguration(org.voltcore.utils.ssl.SSLConfiguration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration)

Example 48 with VoltProjectBuilder

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();
}
Also used : VoltDB(org.voltdb.VoltDB) Configuration(org.voltdb.VoltDB.Configuration) SSLConfiguration(org.voltcore.utils.ssl.SSLConfiguration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) PortGenerator(org.voltcore.utils.PortGenerator) Configuration(org.voltdb.VoltDB.Configuration)

Example 49 with VoltProjectBuilder

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);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 50 with VoltProjectBuilder

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);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Aggregations

VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)269 Configuration (org.voltdb.VoltDB.Configuration)89 IOException (java.io.IOException)49 Test (org.junit.Test)45 File (java.io.File)40 ProcCallException (org.voltdb.client.ProcCallException)38 ClientResponse (org.voltdb.client.ClientResponse)37 VoltDB (org.voltdb.VoltDB)22 LocalCluster (org.voltdb.regressionsuites.LocalCluster)18 Client (org.voltdb.client.Client)17 Before (org.junit.Before)14 HashMap (java.util.HashMap)13 VoltTable (org.voltdb.VoltTable)13 ServerThread (org.voltdb.ServerThread)12 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)12 VoltCompiler (org.voltdb.compiler.VoltCompiler)11 HttpResponse (org.apache.http.HttpResponse)10 BeforeClass (org.junit.BeforeClass)8 ClientConfig (org.voltdb.client.ClientConfig)7 UserInfo (org.voltdb.compiler.VoltProjectBuilder.UserInfo)7