Search in sources :

Example 91 with ProcCallException

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

the class TestFailuresSuite method testDivideByZero.

public void testDivideByZero() throws IOException {
    System.out.println("STARTING DivideByZero");
    Client client = getClient();
    VoltTable[] results = null;
    try {
        results = client.callProcedure("DivideByZero", 0L, 0L, (byte) 1).getResults();
        System.out.println("DivideByZero client response received");
        assertEquals(results.length, 0);
    } catch (ProcCallException e) {
        System.out.println(e.getMessage());
        if (e.getMessage().contains("SQL ERROR"))
            return;
        if (isHSQL())
            if (e.getMessage().contains("HSQL-BACKEND ERROR"))
                return;
    } catch (IOException e) {
        fail(e.toString());
        return;
    }
    fail("testDivideByZero should return while catching ProcCallException");
}
Also used : IOException(java.io.IOException) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 92 with ProcCallException

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

the class TestFailuresSuite method testBadFloatToVarcharCompare.

// Subcase of ENG-800
public void testBadFloatToVarcharCompare() throws IOException {
    System.out.println("STARTING testBadFloatToVarcharCompare");
    Client client = getClient();
    boolean threw = false;
    try {
        client.callProcedure("BadFloatToVarcharCompare", 1).getResults();
    } catch (ProcCallException e) {
        if (!isHSQL()) {
            if ((e.getMessage().contains("SQL ERROR")) && (e.getMessage().contains("VARCHAR cannot be cast for comparison to type FLOAT"))) {
                threw = true;
            } else {
                e.printStackTrace();
            }
        } else {
            threw = true;
        }
    }
    assertTrue(threw);
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 93 with ProcCallException

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

the class TestCatchExceptionsInProcedure method bigBatchChecker.

private void bigBatchChecker(Client client, int hasPreviousBatch, int duplicatedID, int hasFollowingBatch, int followingBatchHasException, double[] expected, int tableCount) throws NoConnectionsException, IOException, ProcCallException {
    VoltTable vt;
    String sql;
    try {
        // use the default value for partition column to route this procedure
        vt = client.callProcedure("SPBigBatchOnPartitionTable", 0, hasPreviousBatch, duplicatedID, hasFollowingBatch, followingBatchHasException).getResults()[0];
        if (isTrue(followingBatchHasException)) {
            assertTrue(isTrue(hasFollowingBatch));
            fail("Expected failure but succeeded.");
        }
        // validate returned value from the procedure calls
        validateRowOfLongs(vt, new long[] { duplicatedID > BIGBATCHTESTSIZE ? 0 : -1 });
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("CONSTRAINT VIOLATION"));
        // violated at row (3, 3.2)
        assertTrue(e.getMessage().contains("500.2"));
        assertTrue(isTrue(hasFollowingBatch) && isTrue(followingBatchHasException));
    }
    sql = "select distinct ratio from P1 order by 1; ";
    validateTableColumnOfScalarFloat(client, sql, expected);
    sql = "select count(*) from P1; ";
    validateTableOfScalarLongs(client, sql, new long[] { tableCount });
    client.callProcedure("@AdHoc", "truncate table P1");
}
Also used : VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException)

Example 94 with ProcCallException

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

the class TestCatchExceptionsInProcedure method testBigBatchAdvancedException.

public void testBigBatchAdvancedException() throws IOException, ProcCallException {
    System.out.println("test testBigBatchAdvancedException...");
    Client client = getClient();
    String sql;
    // so many more permutations
    bigBatchAdvancedChecker(client, 0, 1, 1, 150, 1, 1, 1, 0, new double[] { 0.1, 500.1 }, 2);
    bigBatchAdvancedChecker(client, 0, 1, 1, 250, 1, 1, 1, 0, new double[] { 0.1, 500.1 }, 2);
    bigBatchAdvancedChecker(client, 0, 0, 1, 150, 0, 0, 0, 0, new double[] {}, 0);
    //
    // Test multiple procedure call suggested from code review
    //
    // big batch roll back
    client.callProcedure("SPBigBatchAdvancedOnPartitionTable", 0, 1, 1, 150, 0, 0, 0, 0);
    // how transaction roll back
    try {
        client.callProcedure("SPBigBatchAdvancedOnPartitionTable", 0, 0, 0, 0, 0, 0, 0, 1);
        fail();
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("CONSTRAINT VIOLATION"));
        // violated at row (700, 700.2)
        assertTrue(e.getMessage().contains("700.2"));
    }
    sql = "select distinct ratio from P1 order by 1;";
    validateTableColumnOfScalarFloat(client, sql, new double[] { 0.1 });
    // clear the data
    client.callProcedure("@AdHoc", "truncate table P1");
    // SP
    try {
        client.callProcedure("SPCatchRethrowOnPartitionTable", 0, 1);
        fail();
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("User's SP constraint error message"));
    }
    sql = "select distinct ratio from P1 order by 1;";
    validateTableColumnOfScalarFloat(client, sql, new double[] {});
    // two batches in the try catch block
    try {
        client.callProcedure("SPCatchRethrowOnPartitionTable", 0, 0);
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("User's SP constraint error message"));
    }
    sql = "select distinct ratio from P1 order by 1;";
    validateTableColumnOfScalarFloat(client, sql, new double[] {});
    // MP
    try {
        client.callProcedure("MPCatchRethrowOnPartitionTable", 1);
        fail();
    } catch (Exception e) {
        System.err.println(e.getMessage());
        assertTrue(e.getMessage().contains("User's MP constraint error message"));
    }
    sql = "select distinct ratio from P1 order by 1;";
    validateTableColumnOfScalarFloat(client, sql, new double[] {});
    // two batches in the try catch block
    try {
        client.callProcedure("MPCatchRethrowOnPartitionTable", 0);
    } catch (Exception e) {
        assertTrue(e.getMessage().contains("User's MP constraint error message"));
    }
    sql = "select distinct ratio from P1 order by 1;";
    validateTableColumnOfScalarFloat(client, sql, new double[] {});
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException)

Example 95 with ProcCallException

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

the class TestFixedSQLSuite method subTestVarcharByBytes.

private void subTestVarcharByBytes() throws IOException, ProcCallException {
    System.out.println("STARTING testing varchar by BYTES ......");
    Client client = getClient();
    VoltTable vt = null;
    String var;
    var = "VO";
    client.callProcedure("@AdHoc", "Insert into VarcharBYTES (id, var2) VALUES (0,'" + var + "')");
    vt = client.callProcedure("@AdHoc", "select var2 from VarcharBYTES where id = 0").getResults()[0];
    validateTableColumnOfScalarVarchar(vt, new String[] { var });
    if (isHSQL())
        return;
    var = "VOLT";
    try {
        client.callProcedure("@AdHoc", "Insert into VarcharBYTES (id, var2) VALUES (1,'" + var + "')");
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains(String.format("The size %d of the value '%s' exceeds the size of the VARCHAR(%d BYTES) column.", var.length(), var, 2)));
    }
    var = "贾鑫";
    try {
        // assert here that this two-character string decodes via UTF8 to a bytebuffer longer than 2 bytes.
        assertEquals(2, var.length());
        assertEquals(6, var.getBytes("UTF-8").length);
        client.callProcedure("@AdHoc", "Insert into VarcharBYTES (id, var2) VALUES (1,'" + var + "')");
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains(String.format("The size %d of the value '%s' exceeds the size of the VARCHAR(%d BYTES) column.", 6, var, 2)));
    }
    var = "Voltdb is great | Voltdb is great " + "| Voltdb is great | Voltdb is great| Voltdb is great | Voltdb is great" + "| Voltdb is great | Voltdb is great| Voltdb is great | Voltdb is great";
    try {
        client.callProcedure("VARCHARBYTES.insert", 2, null, var);
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains(String.format("The size %d of the value '%s...' exceeds the size of the VARCHAR(%d BYTES) column.", var.length(), var.substring(0, VARCHAR_VARBINARY_THRESHOLD), 80)));
    }
    var = var.substring(0, 70);
    client.callProcedure("VARCHARBYTES.insert", 2, null, var);
    vt = client.callProcedure("@AdHoc", "select var80 from VarcharBYTES where id = 2").getResults()[0];
    validateTableColumnOfScalarVarchar(vt, new String[] { var });
    truncateTable(client, "VarcharBYTES");
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) IOException(java.io.IOException) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException)

Aggregations

ProcCallException (org.voltdb.client.ProcCallException)240 Client (org.voltdb.client.Client)151 VoltTable (org.voltdb.VoltTable)120 ClientResponse (org.voltdb.client.ClientResponse)92 IOException (java.io.IOException)82 NoConnectionsException (org.voltdb.client.NoConnectionsException)55 Test (org.junit.Test)44 Configuration (org.voltdb.VoltDB.Configuration)41 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)36 File (java.io.File)21 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)19 VoltCompiler (org.voltdb.compiler.VoltCompiler)15 VoltDB (org.voltdb.VoltDB)10 VoltTableRow (org.voltdb.VoltTableRow)10 Timestamp (java.sql.Timestamp)5 TimestampType (org.voltdb.types.TimestampType)5 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 HashSet (java.util.HashSet)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)3