Search in sources :

Example 26 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestNTProcs method testUAC.

public void testUAC() throws Exception {
    String pathToCatalog = Configuration.getPathToCatalogForTest("adhocddl.jar");
    String pathToDeployment = Configuration.getPathToCatalogForTest("adhocddl.xml");
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("--dont care");
    builder.setUseDDLSchema(true);
    boolean success = builder.compile(pathToCatalog, 2, 1, 0);
    assertTrue("Schema compilation failed", success);
    MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
    VoltDB.Configuration config = new VoltDB.Configuration();
    config.m_pathToCatalog = pathToCatalog;
    config.m_pathToDeployment = pathToDeployment;
    ServerThread localServer = new ServerThread(config);
    localServer.start();
    localServer.waitForInitialization();
    Client client = ClientFactory.createClient();
    client.createConnection("localhost");
    ClientResponseImpl response = (ClientResponseImpl) client.callProcedure("@AdHoc", "create table blah (pkey integer not null, strval varchar(200), PRIMARY KEY(pkey));");
    assertEquals(ClientResponse.SUCCESS, response.getStatus());
    // CHECK STATS
    VoltTable statsT = getStats(client, "PROCEDURE");
    System.out.println("STATS: " + statsT.toFormattedString());
    assertTrue(VoltTableUtil.tableContainsString(statsT, "UpdateCore", true));
    Map<String, Long> stats = aggregateProcRow(client, UpdateCore.class.getName());
    assertEquals(1, stats.get("INVOCATIONS").longValue());
    localServer.shutdown();
    localServer.join();
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) UpdateCore(org.voltdb.sysprocs.UpdateCore) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) AtomicLong(java.util.concurrent.atomic.AtomicLong) Client(org.voltdb.client.Client)

Example 27 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestJDBCConnectionFail method getBuilderForTest.

static VoltProjectBuilder getBuilderForTest() throws IOException {
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("CREATE TABLE T(" + "A1 INTEGER NOT NULL, " + "A2 DECIMAL, " + "A3 DECIMAL DEFAULT 0, " + "A4 DECIMAL DEFAULT 999, " + "A5 DECIMAL DEFAULT 9.99E2, " + "A6 DECIMAL DEFAULT 1.012345678901, " + "PRIMARY KEY(A1));");
    builder.addPartitionInfo("T", "A1");
    builder.addStmtProcedure("Insert", "INSERT INTO T(A1) VALUES(?);", "T.A1: 0");
    builder.addStmtProcedure("Select", "SELECT * FROM T WHERE A1 = ?;", "T.A1: 0");
    return builder;
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 28 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestJDBCConnectionFail method suite.

public static Test suite() throws IOException {
    // the suite made here will all be using the tests from this class
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestJDBCConnectionFail.class);
    // build up a project builder for the workload
    VoltProjectBuilder project = getBuilderForTest();
    boolean success;
    m_config = new LocalCluster("decimal-default.jar", 4, 5, kfactor, BackendTarget.NATIVE_EE_JNI);
    m_config.setHasLocalServer(true);
    success = m_config.compile(project);
    assertTrue(success);
    // add this config to the set of tests to run
    builder.addServerConfig(m_config);
    return builder;
}
Also used : LocalCluster(org.voltdb.regressionsuites.LocalCluster) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) MultiConfigSuiteBuilder(org.voltdb.regressionsuites.MultiConfigSuiteBuilder)

Example 29 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestFixedSQLSuite method suite.

public static junit.framework.Test suite() {
    VoltServerConfig config = null;
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestFixedSQLSuite.class);
    boolean success;
    VoltProjectBuilder project = new VoltProjectBuilder();
    project.addSchema(Insert.class.getResource("fixed-sql-ddl.sql"));
    project.addProcedures(PROCEDURES);
    // Now that this fails to compile with an overflow error, it should be migrated to a
    // Failures suite.
    //project.addStmtProcedure("Crap", "insert into COUNT_NULL values (" + Long.MIN_VALUE + ", 1, 200)");
    project.addStmtProcedure("Eng397Limit1", "Select P1.NUM from P1 order by P1.NUM limit ?;");
    //        project.addStmtProcedure("Eng490Select", "SELECT A.ASSET_ID, A.OBJECT_DETAIL_ID,  OD.OBJECT_DETAIL_ID FROM ASSET A, OBJECT_DETAIL OD WHERE A.OBJECT_DETAIL_ID = OD.OBJECT_DETAIL_ID;");
    project.addStmtProcedure("InsertNullString", "Insert into STRINGPART values (?, ?, ?);", "STRINGPART.NAME: 0");
    project.addStmtProcedure("Eng993Insert", "insert into P1 (ID,DESC,NUM,RATIO) VALUES(1+?,'NULL',NULL,1+?);");
    project.addStmtProcedure("Eng5926Insert", "insert into PWEE (ID,WEE,NUM,RATIO) VALUES(1+?,?||'WEE',NULL,1+?);");
    project.addStmtProcedure("Eng1316Insert_R", "insert into R1 values (?, ?, ?, ?);");
    project.addStmtProcedure("Eng1316Update_R", "update R1 set num = num + 1 where id < 104");
    project.addStmtProcedure("Eng1316Insert_P", "insert into P1 values (?, ?, ?, ?);");
    project.addStmtProcedure("Eng1316Update_P", "update P1 set num = num + 1 where id < 104");
    project.addStmtProcedure("Eng1316Insert_P1", "insert into P1 values (?, ?, ?, ?);", "P1.ID: 0");
    project.addStmtProcedure("Eng1316Update_P1", "update P1 set num = num + 1 where id = ?", "P1.ID: 0");
    //* CONFIG #1: JNI -- keep this enabled by default with / / vs. / *
    config = new LocalCluster("fixedsql-threesite.jar", 3, 1, 0, BackendTarget.NATIVE_EE_JNI);
    success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);
    /*/ // CONFIG #1b: IPC -- keep this normally disabled with / * vs. //
        config = new LocalCluster("fixedsql-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_IPC);
        success = config.compile(project);
        assertTrue(success);
        builder.addServerConfig(config);
        // end of normally disabled section */
    //* CONFIG #2: HSQL
    config = new LocalCluster("fixedsql-hsql.jar", 1, 1, 0, BackendTarget.HSQLDB_BACKEND);
    success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);
    // end of HSQDB config */
    return builder;
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Insert(org.voltdb_testprocs.regressionsuites.fixedsql.Insert)

Example 30 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestFunctionsForVoltDBSuite method suite.

public static junit.framework.Test suite() {
    VoltServerConfig config = null;
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestFunctionsForVoltDBSuite.class);
    boolean success;
    VoltProjectBuilder project = new VoltProjectBuilder();
    final String literalSchema = "CREATE TABLE P1 ( " + "ID INTEGER DEFAULT '0' NOT NULL, " + "DESC VARCHAR(300), " + "NUM INTEGER, " + "RATIO FLOAT, " + "PRIMARY KEY (ID) ); " + "PARTITION TABLE P1 ON COLUMN ID;" + "CREATE TABLE P2 ( " + "ID INTEGER DEFAULT '0' NOT NULL, " + "TM TIMESTAMP DEFAULT NULL, " + "PRIMARY KEY (ID) ); " + "PARTITION TABLE P2 ON COLUMN ID;\n" + "CREATE TABLE P3_INLINE_DESC ( " + "ID INTEGER DEFAULT '0' NOT NULL, " + "DESC VARCHAR(15), " + "DESC2 VARCHAR(15), " + "NUM INTEGER, " + "RATIO FLOAT, " + "PRIMARY KEY (ID) ); " + "PARTITION TABLE P3_INLINE_DESC ON COLUMN ID;" + "CREATE TABLE R3 ( " + "ID INTEGER DEFAULT '0' NOT NULL, " + "TINY TINYINT, " + "SMALL SMALLINT, " + "NUM INTEGER, " + "BIG BIGINT, " + "RATIO FLOAT, " + "TM TIMESTAMP DEFAULT NULL, " + "VAR VARCHAR(300), " + "DEC DECIMAL, " + "PRIMARY KEY (ID) ); " + "CREATE INDEX R3_IDX_HEX ON R3 (hex(big));" + "CREATE INDEX R3_IDX_bit_shift_left ON R3 (bit_shift_left(big, 3));" + "CREATE INDEX R3_IDX_bit_shift_right ON R3 (bit_shift_right(big, 3));" + "CREATE TABLE JS1 (\n" + "  ID INTEGER NOT NULL, \n" + "  DOC VARCHAR(8192),\n" + "  PRIMARY KEY(ID))\n" + ";\n" + "CREATE TABLE D1 (\n" + "  ID INTEGER NOT NULL, \n" + "  DEC DECIMAL, \n" + "  PRIMARY KEY(ID))\n" + ";\n" + "CREATE PROCEDURE IdFieldProc AS\n" + "   SELECT ID FROM JS1 WHERE FIELD(DOC, ?) = ? ORDER BY ID\n" + ";\n" + "CREATE PROCEDURE InnerFieldProc AS\n" + "   SELECT ID FROM JS1 WHERE FIELD(FIELD(DOC, 'inner'), ?) = ? ORDER BY ID\n" + ";\n" + "CREATE PROCEDURE NullFieldProc AS\n" + "   SELECT ID FROM JS1 WHERE FIELD(DOC, ?) IS NULL ORDER BY ID\n" + ";\n" + "CREATE PROCEDURE IdArrayProc AS\n" + "   SELECT ID FROM JS1 WHERE ARRAY_ELEMENT(FIELD(DOC, ?), ?) = ? ORDER BY ID\n" + ";\n" + "CREATE PROCEDURE NullArrayProc AS\n" + "   SELECT ID FROM JS1 WHERE ARRAY_ELEMENT(FIELD(DOC, ?), ?) IS NULL ORDER BY ID\n" + ";\n" + "CREATE PROCEDURE IdArrayLengthProc AS\n" + "   SELECT ID FROM JS1 WHERE ARRAY_LENGTH(FIELD(DOC, ?)) = ? ORDER BY ID\n" + ";\n" + "CREATE PROCEDURE NullArrayLengthProc AS\n" + "   SELECT ID FROM JS1 WHERE ARRAY_LENGTH(FIELD(DOC, ?)) IS NULL ORDER BY ID\n" + ";\n" + "CREATE PROCEDURE SmallArrayLengthProc AS\n" + "   SELECT ID FROM JS1 WHERE ARRAY_LENGTH(FIELD(DOC, ?)) BETWEEN 0 AND ? ORDER BY ID\n" + ";\n" + "CREATE PROCEDURE LargeArrayLengthProc AS\n" + "   SELECT ID FROM JS1 WHERE ARRAY_LENGTH(FIELD(DOC, ?)) > ? ORDER BY ID\n" + ";\n" + "CREATE TABLE JSBAD (\n" + "  ID INTEGER NOT NULL,\n" + "  DOC VARCHAR(8192),\n" + "  PRIMARY KEY(ID))\n" + ";\n" + "CREATE PROCEDURE BadIdFieldProc AS\n" + "  SELECT ID FROM JSBAD WHERE ID = ? AND FIELD(DOC, ?) = ?\n" + ";\n" + "CREATE PROCEDURE BadIdArrayProc AS\n" + "  SELECT ID FROM JSBAD WHERE ID = ? AND ARRAY_ELEMENT(FIELD(DOC, ?), 1) = ?\n" + ";\n" + "CREATE PROCEDURE BadIdArrayLengthProc AS\n" + "  SELECT ID FROM JSBAD WHERE ID = ? AND ARRAY_LENGTH(FIELD(DOC, ?)) = ?\n" + ";\n" + "CREATE TABLE PAULTEST (ID INTEGER, NAME VARCHAR(12), LOCK_TIME TIMESTAMP, PRIMARY KEY(ID));" + "\n" + "CREATE PROCEDURE GOT_BAD_PARAM_COUNTS_INLINE AS \n" + "    SELECT TOP ? * FROM PAULTEST WHERE NAME IS NOT NULL AND " + "                                       (LOCK_TIME IS NULL OR " + "                                        SINCE_EPOCH(MILLIS,CURRENT_TIMESTAMP)-? < " + "                                        SINCE_EPOCH(MILLIS,LOCK_TIME))\n" + ";\n" + "CREATE INDEX ENG7792_UNUSED_INDEX_USES_CONCAT ON P3_INLINE_DESC (CONCAT(DESC, DESC2))" + ";\n" + "CREATE TABLE BINARYTEST (ID INTEGER, bdata varbinary(256), PRIMARY KEY(ID));" + // that the other equals the translation to the one.
    "CREATE TABLE INET4_TEST ( " + "    PRES         VARCHAR, " + "    BIN          BIGINT " + ");" + "CREATE TABLE INET4_TEST_PPRES ( " + "    PRES         VARCHAR NOT NULL, " + "    BIN          BIGINT " + ");" + "PARTITION TABLE INET4_TEST_PPRES ON COLUMN PRES;" + "CREATE TABLE INET6_TEST ( " + "    PRES         VARCHAR, " + "    BIN          VARBINARY " + ");" + "CREATE TABLE INET6_TEST_PPRES ( " + "    PRES         VARCHAR NOT NULL, " + "    BIN          VARBINARY " + ");" + "PARTITION TABLE INET6_TEST_PPRES ON COLUMN PRES;" + "";
    try {
        project.addLiteralSchema(literalSchema);
    } catch (IOException e) {
        assertFalse(true);
    }
    // load the procedures for the test
    loadProcedures(project);
    // CONFIG #1: Local Site/Partition running on JNI backend
    config = new LocalCluster("fixedsql-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI);
    success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);
    // CONFIG #2: Local Site/Partitions running on JNI backend
    config = new LocalCluster("fixedsql-threesite.jar", 3, 1, 0, BackendTarget.NATIVE_EE_JNI);
    success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);
    return builder;
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) IOException(java.io.IOException)

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