Search in sources :

Example 76 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class TestFunctionsForJSON method testProcWithValidJSON.

private void testProcWithValidJSON(long[] expectedResult, Client client, String procName, Object... parameters) throws Exception {
    ClientResponse cr = client.callProcedure(procName, parameters);
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    VoltTable result = cr.getResults()[0];
    validateRowOfLongs(result, expectedResult);
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable)

Example 77 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class TestFunctionsSuite method testMultiSignatureFunctionInStoredProcedure.

public void testMultiSignatureFunctionInStoredProcedure() throws Exception {
    // ENG-10939
    System.out.println("STARTING testMultiSignatureFunctionInStoredProcedure");
    Client client = getClient();
    ClientResponse cr = client.callProcedure("TEST_SUBSTRING_INPROC", 12, "string");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Client(org.voltdb.client.Client)

Example 78 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class TestFunctionsSuite method testPi.

public void testPi() throws Exception {
    System.out.println("STARTING testPi");
    Client client = getClient();
    /*
         *      "CREATE TABLE P1 ( " +
                "ID INTEGER DEFAULT 0 NOT NULL, " +
                "DESC VARCHAR(300), " +
                "NUM INTEGER, " +
                "RATIO FLOAT, " +
                "PAST TIMESTAMP DEFAULT NULL, " +
                "PRIMARY KEY (ID) ); " +
         */
    ClientResponse cr = null;
    VoltTable vt = null;
    double pi = 3.1415926535897932384;
    cr = client.callProcedure("@AdHoc", "INSERT INTO P1 (ID) VALUES(1)");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    vt = client.callProcedure("@AdHoc", "SELECT PI() * ID FROM P1 WHERE ID = 1;").getResults()[0];
    assertTrue(vt.advanceRow());
    assertTrue(Math.abs(vt.getDouble(0) - pi) <= 1.0e-16);
    cr = client.callProcedure("@AdHoc", "TRUNCATE TABLE P1");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Example 79 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class TestFunctionsSuite method displayFunctionRun.

private FunctionTestCase[] displayFunctionRun(Client client, String fname, int rowCount, String expectedFormat) throws Exception {
    ClientResponse cr;
    VoltTable result;
    FunctionTestCase[] resultSet = new FunctionTestCase[numTypeNames.length * rowCount];
    int ii = 0;
    String proc = "DISPLAY_" + fname;
    cr = client.callProcedure(proc);
    result = cr.getResults()[0];
    assertEquals(rowCount, result.getRowCount());
    while (result.advanceRow()) {
        int jj = 0;
        for (String numTypeName : numTypeNames) {
            double value = getColumnValue(expectedFormat, result, jj);
            resultSet[ii++] = new FunctionTestCase(proc + " " + numTypeName, value);
            ++jj;
        }
    }
    return resultSet;
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable)

Example 80 with ClientResponse

use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.

the class TestMaterializedViewNonemptyTablesSuite method testCreateView.

/**
     * Test to see if we can create a view.  The view name is
     * necessary because we drop the view after creation.
     *
     * @param client The Client object.
     * @param sql The sql string.  This should start "create view name ",
     *            where "name" is the view name.
     * @param expectedDiagnostic The expected diagnostic string.  This
     *                           should be null if the creation is
     *                           expected to succeed.
     * @throws IOException
     * @throws NoConnectionsException
     * @throws ProcCallException
     */
private void testCreateView(Client client, String sql, String expectedDiagnostic) throws IOException, NoConnectionsException, ProcCallException {
    ClientResponse cr = null;
    assertTrue("SQL string should start with \"create view \"", sql.startsWith("create view "));
    int pos = sql.indexOf(" ", 12);
    String viewName = sql.substring(12, pos);
    // Try to drop the view.  Even if it doesn't
    // exist, this should succeed.
    dropView(client, viewName);
    // Truncate all the tables.
    truncateTables(client, TABLE_NAMES);
    // This should always succeed.
    try {
        cr = client.callProcedure("@AdHoc", sql);
    } catch (Exception ex) {
        fail("Unexpected exception: \"" + ex.getMessage() + "\"");
    }
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    // Drop the view and populate the tables.
    dropView(client, viewName);
    populateTables(client);
    // Try the view creation again.  This may or may
    // not succeed.
    boolean expectedSuccess = (expectedDiagnostic == null);
    try {
        cr = client.callProcedure("@AdHoc", sql);
        if (!expectedSuccess) {
            fail("Unexpected SQL compilation success");
        }
    } catch (ProcCallException ex) {
        cr = ex.getClientResponse();
        if (expectedSuccess) {
            fail(String.format("Unexpected SQL compilation failure:\n%s", cr.getStatusString()));
        }
        assertTrue(String.format("Did not find \"%s\" in diagnostic message \"%s\"", expectedDiagnostic, cr.getStatusString()), cr.getStatusString().contains(expectedDiagnostic));
    }
    // Drop the view..
    dropView(client, viewName);
    truncateTables(client, TABLE_NAMES);
    // Try creating the view again.  Sometimes after a
    // population and then truncation things go awry.
    // Again, this should always succeed.
    cr = client.callProcedure("@AdHoc", sql);
    assertEquals("View creation on empty tables should always succeed.", ClientResponse.SUCCESS, cr.getStatus());
    dropView(client, viewName);
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException) ProcCallException(org.voltdb.client.ProcCallException)

Aggregations

ClientResponse (org.voltdb.client.ClientResponse)381 VoltTable (org.voltdb.VoltTable)193 Client (org.voltdb.client.Client)184 ProcCallException (org.voltdb.client.ProcCallException)105 IOException (java.io.IOException)52 NoConnectionsException (org.voltdb.client.NoConnectionsException)33 Test (org.junit.Test)32 ProcedureCallback (org.voltdb.client.ProcedureCallback)32 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)29 Configuration (org.voltdb.VoltDB.Configuration)28 File (java.io.File)18 Timestamp (java.sql.Timestamp)16 VoltDB (org.voltdb.VoltDB)16 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)16 VoltCompiler (org.voltdb.compiler.VoltCompiler)15 JSONException (org.json_voltpatches.JSONException)11 BigDecimal (java.math.BigDecimal)10 ExecutionException (java.util.concurrent.ExecutionException)10 ClientResponseImpl (org.voltdb.ClientResponseImpl)10 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)9