Search in sources :

Example 91 with VoltProjectBuilder

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

the class TestWindowFunctionSuiteMinMaxSum method suite.

public static junit.framework.Test suite() {
    VoltServerConfig config = null;
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestWindowFunctionSuiteMinMaxSum.class);
    boolean success = false;
    VoltProjectBuilder project;
    try {
        project = new VoltProjectBuilder();
        config = new LocalCluster("test-windowed-rank.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI);
        setupSchema(project);
        success = config.compile(project);
        assertTrue(success);
        builder.addServerConfig(config);
        project = new VoltProjectBuilder();
        config = new LocalCluster("test-windowed-rank.jar", 3, 1, 0, BackendTarget.NATIVE_EE_JNI);
        setupSchema(project);
        success = config.compile(project);
        assertTrue(success);
        builder.addServerConfig(config);
    } catch (IOException excp) {
        fail();
    }
    return builder;
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) IOException(java.io.IOException)

Example 92 with VoltProjectBuilder

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

the class TestSnapshotConverter method suite.

//
// Build a list of the tests to be run. Use the regression suite
// helpers to allow multiple backends.
// JUnit magic that uses the regression suite helper classes.
//
public static Test suite() throws IOException {
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestSnapshotConverter.class);
    VoltProjectBuilder project = new VoltProjectBuilder();
    project.addLiteralSchema("CREATE TABLE T_SP(A2 VARCHAR(128), A1 INTEGER NOT NULL, A3 VARCHAR(64), A4 VARCHAR(64));" + "CREATE TABLE T_MP(A2 VARCHAR(128), A1 INTEGER NOT NULL, A3 VARCHAR(64), A4 VARCHAR(64));");
    project.addPartitionInfo("T_SP", "A1");
    LocalCluster lcconfig = new LocalCluster("testsnapshotstatus.jar", 8, 1, 0, BackendTarget.NATIVE_EE_JNI);
    assertTrue(lcconfig.compile(project));
    builder.addServerConfig(lcconfig);
    return builder;
}
Also used : LocalCluster(org.voltdb.regressionsuites.LocalCluster) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) MultiConfigSuiteBuilder(org.voltdb.regressionsuites.MultiConfigSuiteBuilder)

Example 93 with VoltProjectBuilder

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

the class TestVoltBulkLoader method test_Interface.

public void test_Interface(String my_schema, Object[][] my_data, int my_batchSize, ArrayList<Integer> expectedFailList, int flushInterval, boolean upsert) throws Exception {
    try {
        pathToCatalog = Configuration.getPathToCatalogForTest("vbl.jar");
        pathToDeployment = Configuration.getPathToCatalogForTest("vbl.xml");
        builder = new VoltProjectBuilder();
        builder.addLiteralSchema(my_schema);
        builder.addPartitionInfo("BLAH", "clm_integer");
        boolean success = builder.compile(pathToCatalog, 2, 1, 0);
        assertTrue(success);
        MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
        config = new VoltDB.Configuration();
        config.m_pathToCatalog = pathToCatalog;
        config.m_pathToDeployment = pathToDeployment;
        localServer = new ServerThread(config);
        client1 = null;
        localServer.start();
        localServer.waitForInitialization();
        client1 = ClientFactory.createClient();
        client1.createConnection("localhost");
        prepare();
        TestFailureCallback testCallback = new TestFailureCallback();
        VoltBulkLoader bulkLoader = client1.getNewBulkLoader("BLAH", my_batchSize, upsert, testCallback);
        if (flushInterval > 0) {
            bulkLoader.setFlushInterval(0, flushInterval);
        }
        // do the test
        VoltTable modCount;
        modCount = client1.callProcedure("@AdHoc", "SELECT * FROM BLAH;").getResults()[0];
        System.out.println("data inserted to table BLAH:\n" + modCount);
        // Call validate partitioning to check if we are good.
        VoltTable valTable;
        valTable = client1.callProcedure("@ValidatePartitioning", null, null).getResults()[0];
        System.out.println("Validate for BLAH:\n" + valTable);
        while (valTable.advanceRow()) {
            long miscnt = valTable.getLong("MISPARTITIONED_ROWS");
            assertEquals(miscnt, 0);
        }
        int rowCnt = 1;
        try {
            for (Object[] nextRow : my_data) {
                Integer rowId = new Integer(rowCnt);
                bulkLoader.insertRow(rowId, nextRow);
                rowCnt++;
                if (flushInterval <= 0 && (rnd.nextInt() % 30 == 0)) {
                    //  Randomly inject a flush if no timer flush is involved.
                    bulkLoader.flush();
                }
            }
        } catch (Exception e) {
            System.err.print(e.getMessage());
        }
        System.out.println(String.format("Attempted inserting %d rows", --rowCnt));
        if (flushInterval <= 0 && rnd.nextBoolean()) {
            // One in 10 tests generate a sync and VoltBulkLoader internal state verification
            bulkLoader.drain();
            assertEquals(0, bulkLoader.getOutstandingRowCount());
            assertEquals(rowCnt, bulkLoader.getCompletedRowCount());
        }
        if (flushInterval > 0) {
            //Lets get timerFlush in
            Thread.sleep(flushInterval + 500);
            bulkLoader.drain();
            //We should have everything processed callbacked.
            assertEquals(0, bulkLoader.getOutstandingRowCount());
            assertEquals(rowCnt, bulkLoader.getCompletedRowCount());
        }
        bulkLoader.close();
        assertEquals(rowCnt, bulkLoader.getCompletedRowCount());
        assertTrue(testCallback.failureRowListMatches(expectedFailList));
    } finally {
        if (client1 != null)
            client1.close();
        client1 = null;
        if (localServer != null) {
            localServer.shutdown();
            localServer.join();
        }
        localServer = null;
        // no clue how helpful this is
        System.gc();
    }
}
Also used : VoltBulkLoader(org.voltdb.client.VoltBulkLoader.VoltBulkLoader) VoltTable(org.voltdb.VoltTable) VoltDB(org.voltdb.VoltDB) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread)

Example 94 with VoltProjectBuilder

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

the class CrashVoltDBTest method testSimple.

@Test
public void testSimple() throws Exception {
    String simpleSchema = "create table blah (" + "ival bigint default 0 not null, " + "PRIMARY KEY(ival));";
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema(simpleSchema);
    builder.addProcedures(CrashVoltDBProc.class);
    /*boolean success = builder.compile(Configuration.getPathToCatalogForTest("crash.jar"), 1, 1, 0, "localhost");
        assert(success);
        MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("crash.xml"));*/
    LocalCluster cluster = new LocalCluster("crash.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
    cluster.setHasLocalServer(true);
    boolean success = cluster.compile(builder);
    assert (success);
    cluster.startUp(true);
    final String listener = cluster.getListenerAddresses().get(0);
    final Client client = ClientFactory.createClient();
    //client.createConnection(listener);
    client.createConnection(listener);
    try {
        client.callProcedure("CrashVoltDBProc");
    } catch (Exception e) {
    }
    Thread.sleep(10000);
    client.close();
    cluster.shutDown();
}
Also used : LocalCluster(org.voltdb.regressionsuites.LocalCluster) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Client(org.voltdb.client.Client) JUnit4LocalClusterTest(org.voltdb.regressionsuites.JUnit4LocalClusterTest) Test(org.junit.Test)

Example 95 with VoltProjectBuilder

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

the class TestAdhocAlterTable method testAlterLimitPartitionRows.

@Test
public void testAlterLimitPartitionRows() throws Exception {
    String pathToCatalog = Configuration.getPathToCatalogForTest("adhocddl.jar");
    String pathToDeployment = Configuration.getPathToCatalogForTest("adhocddl.xml");
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("create table FOO (" + "ID integer not null," + "VAL varchar(50), " + "constraint PK_TREE primary key (ID)" + ");\n");
    builder.addPartitionInfo("FOO", "ID");
    builder.setUseDDLSchema(true);
    boolean success = builder.compile(pathToCatalog, 1, 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;
    try {
        startSystem(config);
        VoltTable results = m_client.callProcedure("@Statistics", "TABLE", 0).getResults()[0];
        while (results.getRowCount() == 0) {
            results = m_client.callProcedure("@Statistics", "TABLE", 0).getResults()[0];
        }
        System.out.println(results);
        assertEquals(1, results.getRowCount());
        results.advanceRow();
        Long limit = results.getLong("TUPLE_LIMIT");
        assertTrue(results.wasNull());
        try {
            m_client.callProcedure("@AdHoc", "alter table foo add limit partition rows 10;");
        } catch (ProcCallException pce) {
            fail("Should be able to alter partition row limit: " + pce.toString());
        }
        do {
            results = m_client.callProcedure("@Statistics", "TABLE", 0).getResults()[0];
            results.advanceRow();
            limit = results.getLong("TUPLE_LIMIT");
        } while (results.wasNull());
        System.out.println(results);
        assertEquals(10L, (long) limit);
        try {
            m_client.callProcedure("@AdHoc", "alter table foo drop limit partition rows;");
        } catch (ProcCallException pce) {
            fail("Should be able to drop partition row limit: " + pce.toString());
        }
        do {
            results = m_client.callProcedure("@Statistics", "TABLE", 0).getResults()[0];
            results.advanceRow();
            limit = results.getLong("TUPLE_LIMIT");
        } while (!results.wasNull());
        System.out.println(results);
    } finally {
        teardownSystem();
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ProcCallException(org.voltdb.client.ProcCallException) Test(org.junit.Test)

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