Search in sources :

Example 1 with SelectBigString

use of org.voltdb_testprocs.regressionsuites.failureprocs.SelectBigString in project voltdb by VoltDB.

the class TestFailuresSuite method testMemoryOverload.

//
// Note: this test looks like it should be testing the 50MB buffer serialization
// limit between the EE and Java but watching it run, it really fails on max
// temp table serialization sizes. This needs more investigation.
//
public void testMemoryOverload() throws IOException, ProcCallException {
    if (isHSQL() || isValgrind())
        return;
    final int STRLEN = 30000;
    int totalBytes = 0;
    // less than the 50*1024*1024 limit.
    int expectedMaxSuccessBytes = 40000000;
    int expectedRows = 0;
    System.out.println("STARTING testMemoryOverload");
    Client client = getClient();
    String longStringPart = "volt!";
    StringBuilder sb = new StringBuilder();
    while (sb.length() < STRLEN) sb.append(longStringPart);
    String longString = sb.toString();
    assertEquals(STRLEN, longString.length());
    VoltTable[] results = null;
    while (totalBytes < expectedMaxSuccessBytes) {
        results = client.callProcedure("InsertBigString", expectedRows++, longString).getResults();
        assertEquals(1, results.length);
        assertEquals(1, results[0].asScalarLong());
        totalBytes += STRLEN;
    }
    results = client.callProcedure("WorkWithBigString", expectedRows++, longString).getResults();
    assertEquals(1, results.length);
    assertEquals(expectedRows, results[0].getRowCount());
    totalBytes += STRLEN;
    // 51MB exceeds the response buffer limit.
    while (totalBytes < (50 * 1024 * 1024)) {
        results = client.callProcedure("InsertBigString", expectedRows++, longString).getResults();
        assertEquals(1, results.length);
        assertEquals(1, results[0].asScalarLong());
        totalBytes += STRLEN;
    }
    // Some tests are run with a different effective partition count on community builds,
    // due to a k-factor downgrade, so allow for a possible per partition row count scale difference.
    int kFactorScaleDown;
    if (MiscUtils.isPro()) {
        kFactorScaleDown = 1;
    } else {
        kFactorScaleDown = 2;
    }
    for (int ii = 0; ii < 4; ii++) {
        results = client.callProcedure("SelectBigString", ii).getResults();
        System.out.println(results[0].getRowCount());
        long rowCount = results[0].getRowCount();
        //With elastic hashing the numbers are a little fuzzy
        if (!((rowCount > 800 && rowCount < 950) || (rowCount > 800 / kFactorScaleDown && rowCount < 950 / kFactorScaleDown))) {
            System.out.println("Unexpected row count: " + rowCount);
        }
        assertTrue((rowCount > 800 && rowCount < 950) || (rowCount > 800 / kFactorScaleDown && rowCount < 950 / kFactorScaleDown));
    }
    //System.out.flush();
    try {
        results = client.callProcedure("WorkWithBigString", expectedRows++, longString).getResults();
        fail();
    } catch (ProcCallException e) {
        // this should eventually happen
        assertTrue(totalBytes > expectedMaxSuccessBytes);
        return;
    } catch (IOException e) {
        fail(e.toString());
        return;
    }
    fail();
}
Also used : InsertBigString(org.voltdb_testprocs.regressionsuites.failureprocs.InsertBigString) SelectBigString(org.voltdb_testprocs.regressionsuites.failureprocs.SelectBigString) WorkWithBigString(org.voltdb_testprocs.regressionsuites.sqlfeatureprocs.WorkWithBigString) IOException(java.io.IOException) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Aggregations

IOException (java.io.IOException)1 VoltTable (org.voltdb.VoltTable)1 Client (org.voltdb.client.Client)1 ProcCallException (org.voltdb.client.ProcCallException)1 InsertBigString (org.voltdb_testprocs.regressionsuites.failureprocs.InsertBigString)1 SelectBigString (org.voltdb_testprocs.regressionsuites.failureprocs.SelectBigString)1 WorkWithBigString (org.voltdb_testprocs.regressionsuites.sqlfeatureprocs.WorkWithBigString)1