/* This file is part of VoltDB.
* Copyright (C) 2008-2010 VoltDB L.L.C.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
package org.voltdb.regressionsuites;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import junit.framework.Test;
import org.voltdb.BackendTarget;
import org.voltdb.VoltProcedure;
import org.voltdb.client.Client;
import org.voltdb.client.ClientResponse;
import org.voltdb.VoltTable;
import org.voltdb.client.ProcCallException;
import org.voltdb.benchmark.tpcc.TPCCProjectBuilder;
import org.voltdb.benchmark.tpcc.procedures.*;
import org.voltdb.regressionsuites.rollbackprocs.*;
import org.voltdb.types.TimestampType;
public class TestRollbackSuite extends RegressionSuite {
// procedures used by these tests
@SuppressWarnings("unchecked")
static final Class<? extends VoltProcedure> PROCEDURES[] = (Class<? extends VoltProcedure>[])new Class<?>[] {
SinglePartitionJavaError.class,
SinglePartitionJavaAbort.class,
SinglePartitionConstraintError.class,
MultiPartitionJavaError.class,
MultiPartitionJavaAbort.class,
MultiPartitionConstraintError.class,
SinglePartitionUpdateConstraintError.class,
SinglePartitionConstraintFailureAndContinue.class,
SelectAll.class,
ReadMatView.class,
FetchNORowUsingIndex.class,
InsertAllTypes.class,
AllTypesJavaError.class,
AllTypesJavaAbort.class,
AllTypesUpdateJavaError.class,
AllTypesUpdateJavaAbort.class,
AllTypesMultiOpsJavaError.class
};
/**
* Constructor needed for JUnit. Should just pass on parameters to superclass.
* @param name The name of the method to test. This is just passed to the superclass.
*/
public TestRollbackSuite(String name) {
super(name);
}
// ENG-487
public void allTypesTestHelper(String procName, int[] order, int id)
throws IOException {
Client client = getClient();
final double EPSILON = 0.00001;
final BigDecimal moneyOne = new BigDecimal(BigInteger.valueOf(7700000000000L), 12);
final BigDecimal moneyTwo = new BigDecimal(BigInteger.valueOf(1100000000000L), 12);
try {
client.callProcedure("InsertAllTypes", 1, 2, 3, 4, new TimestampType(5),
0.6, moneyOne, "inlined", "uninlined");
client.callProcedure("InsertAllTypes", 7, 6, 5, 4, new TimestampType(3),
0.2, moneyTwo, "INLINED", "UNINLINED");
} catch (ProcCallException e1) {
System.err.printf(">>> %s UNEXPECTED[0] %s\n", procName, e1);
e1.printStackTrace();
fail();
}
try {
if (procName.contains("MultiOps"))
client.callProcedure("AllTypesMultiOpsJavaError", order, id);
else if (procName.contains("Update"))
client.callProcedure(procName, 7);
else
client.callProcedure(procName);
System.err.printf(">>> %s DID NOT FAIL!\n", procName);
fail();
}
catch (ProcCallException e) {}
catch (IOException e) {
System.err.printf(">>> %s UNEXPECTED[1] %s\n", procName, e);
e.printStackTrace();
fail();
}
try {
VoltTable[] results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES ORDER BY ID ASC;").getResults();
// get the table
VoltTable table = results[0];
assertTrue(table.getRowCount() == 2);
table.advanceRow();
assertEquals(1, table.getLong(0));
assertEquals(2, table.getLong(1));
assertEquals(3, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(5), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.6 - table.getDouble(5)) < EPSILON);
assertEquals(moneyOne, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("inlined"));
assertTrue(table.getString(8).equals("uninlined"));
table.advanceRow();
assertEquals(7, table.getLong(0));
assertEquals(6, table.getLong(1));
assertEquals(5, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("INLINED"));
assertTrue(table.getString(8).equals("UNINLINED"));
// Check by using the indexes
results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES WHERE ID > 3;").getResults();
// get the table
table = results[0];
assertTrue(table.getRowCount() == 1);
table.advanceRow();
assertEquals(7, table.getLong(0));
assertEquals(6, table.getLong(1));
assertEquals(5, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("INLINED"));
assertTrue(table.getString(8).equals("UNINLINED"));
// unique hash index
results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES WHERE ID = 1;").getResults();
// get the table
table = results[0];
assertTrue(table.getRowCount() == 1);
table.advanceRow();
assertEquals(1, table.getLong(0));
assertEquals(2, table.getLong(1));
assertEquals(3, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(5), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.6 - table.getDouble(5)) < EPSILON);
assertEquals(moneyOne, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("inlined"));
assertTrue(table.getString(8).equals("uninlined"));
// multimap tree index
results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES ORDER BY TINY, SMALL, BIG, T, RATIO, MONEY, INLINED DESC;").getResults();
// get the table
table = results[0];
assertTrue(table.getRowCount() == 2);
table.advanceRow();
assertEquals(1, table.getLong(0));
assertEquals(2, table.getLong(1));
assertEquals(3, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(5), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.6 - table.getDouble(5)) < EPSILON);
assertEquals(moneyOne, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("inlined"));
assertTrue(table.getString(8).equals("uninlined"));
table.advanceRow();
assertEquals(7, table.getLong(0));
assertEquals(6, table.getLong(1));
assertEquals(5, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("INLINED"));
assertTrue(table.getString(8).equals("UNINLINED"));
// multimap hash index
results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES WHERE TINY = 6 AND SMALL = 5 AND BIG = 4;").getResults();
// get the table
table = results[0];
assertTrue(table.getRowCount() == 1);
table.advanceRow();
assertEquals(7, table.getLong(0));
assertEquals(6, table.getLong(1));
assertEquals(5, table.getLong(2));
assertEquals(4, table.getLong(3));
assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
assertTrue(table.getString(7).equals("INLINED"));
assertTrue(table.getString(8).equals("UNINLINED"));
// clean up
client.callProcedure("@AdHoc", "DELETE FROM ALL_TYPES");
}
catch (ProcCallException e) {
System.err.printf(">>> %s UNEXPECTED[2] %s\n", procName, e);
e.printStackTrace();
fail();
}
catch (IOException e) {
System.err.printf(">>> %s UNEXPECTED[3] %s\n", procName, e);
e.printStackTrace();
fail();
}
}
public void testSinglePartitionJavaFailure() throws IOException {
Client client = getClient();
try {
client.callProcedure("SinglePartitionJavaError", 2);
fail();
}
catch (ProcCallException e) {}
catch (IOException e) {
e.printStackTrace();
fail();
}
try {
VoltTable[] results = client.callProcedure("SelectAll").getResults();
assertEquals(results.length, 9);
// get the new order table
VoltTable table = results[7];
assertTrue(table.getRowCount() == 0);
// check the mat view
results = client.callProcedure("ReadMatView", 2).getResults();
assertEquals(results.length, 1);
assertTrue(results[0].getRowCount() == 0);
}
catch (ProcCallException e) {
e.printStackTrace();
fail();
}
catch (IOException e) {
e.printStackTrace();
fail();
}
}
public void testSinglePartitionJavaAbort() throws IOException {
Client client = getClient();
try {
client.callProcedure("SinglePartitionJavaAbort", 2);
fail();
}
catch (ProcCallException e) {}
catch (IOException e) {
e.printStackTrace();
fail();
}
try {
VoltTable[] results = client.callProcedure("SelectAll").getResults();
assertEquals(results.length, 9);
// get the new order table
VoltTable table = results[7];
assertTrue(table.getRowCount() == 0);
// check the mat view
results = client.callProcedure("ReadMatView", 2).getResults();
assertEquals(results.length, 1);
assertTrue(results[0].getRowCount() == 0);
}
catch (ProcCallException e) {
e.printStackTrace();
fail();
}
catch (IOException e) {
e.printStackTrace();
fail();
}
}
public void testSinglePartitionConstraintFailure() throws IOException {
Client client = getClient();
try {
client.callProcedure("SinglePartitionConstraintError", 2);
fail();
}
catch (ProcCallException e) {}
catch (IOException e) {
e.printStackTrace();
fail();
}
try {
ClientResponse cr = client.callProcedure("SelectAll");
VoltTable[] results = cr.getResults();
assertEquals(results.length, 9);
// get the new order table
VoltTable table = results[6];
assertEquals(cr.toString(), 0, table.getRowCount());
// check the mat view
cr = client.callProcedure("ReadMatView", 2);
results = cr.getResults();
assertEquals(cr.toString(), 1, results.length);
assertEquals(cr.toString(), 0, results[0].getRowCount());
}
catch (ProcCallException e) {
e.printStackTrace();
fail();
}
catch (IOException e) {
e.printStackTrace();
fail();
}
try {
client.callProcedure("InsertNewOrder", 2, 2, 2);
} catch (ProcCallException e1) {
e1.printStackTrace();
fail();
}
try {
client.callProcedure("SinglePartitionUpdateConstraintError", 2);
fail();
}
catch (ProcCallException e) {}
catch (IOException e) {
e.printStackTrace();
fail();
}
try {
VoltTable[] results = client.callProcedure("SelectAll").getResults();
assertEquals(results.length, 9);
// get the new order table
VoltTable table = results[7];
assertTrue(table.getRowCount() == 1);
table.advanceRow();
assertEquals(2, table.getLong(0));
assertEquals(2, table.getLong(1));
assertEquals(2, table.getLong(2));
// check the mat view
results = client.callProcedure("ReadMatView", 2).getResults();
assertEquals(results.length, 1);
assertTrue(results[0].getRowCount() == 1);
results[0].advanceRow();
assertEquals(2, results[0].getLong(0));
assertEquals(1, results[0].getLong(1));
}
catch (ProcCallException e) {
e.printStackTrace();
fail();
}
catch (IOException e) {
e.printStackTrace();
fail();
}
}
public void testAllTypesJavaError() throws IOException {
allTypesTestHelper("AllTypesJavaError", null, 0);
}
public void testAllTypesJavaAbort() throws IOException {
allTypesTestHelper("AllTypesJavaAbort", null, 0);
}
public void testAllTypesUpdateJavaError() throws IOException {
allTypesTestHelper("AllTypesUpdateJavaError", null, 0);
}
public void testAllTypesUpdateJavaAbort() throws IOException {
allTypesTestHelper("AllTypesUpdateJavaAbort", null, 0);
}
// ENG-488
// public void testAllTypesMultiOpsJavaError() throws IOException {
// allTypesTestHelper("AllTypesMultiOpsJavaError",
// new int[] {AllTypesMultiOpsJavaError.INSERT,
// AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.DELETE},
// 3);
// allTypesTestHelper("AllTypesMultiOpsJavaError",
// new int[] {AllTypesMultiOpsJavaError.INSERT,
// AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.DELETE},
// 3);
// allTypesTestHelper("AllTypesMultiOpsJavaError",
// new int[] {AllTypesMultiOpsJavaError.INSERT,
// AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.UPDATE},
// 3);
// allTypesTestHelper("AllTypesMultiOpsJavaError",
// new int[] {AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.UPDATE},
// 7);
// allTypesTestHelper("AllTypesMultiOpsJavaError",
// new int[] {AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.DELETE},
// 7);
// allTypesTestHelper("AllTypesMultiOpsJavaError",
// new int[] {AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.DELETE,
// AllTypesMultiOpsJavaError.INSERT},
// 7);
// allTypesTestHelper("AllTypesMultiOpsJavaError",
// new int[] {AllTypesMultiOpsJavaError.DELETE,
// AllTypesMultiOpsJavaError.INSERT,
// AllTypesMultiOpsJavaError.UPDATE},
// 7);
// allTypesTestHelper("AllTypesMultiOpsJavaError",
// new int[] {AllTypesMultiOpsJavaError.DELETE,
// AllTypesMultiOpsJavaError.INSERT,
// AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.UPDATE},
// 7);
// allTypesTestHelper("AllTypesMultiOpsJavaError",
// new int[] {AllTypesMultiOpsJavaError.DELETE,
// AllTypesMultiOpsJavaError.INSERT,
// AllTypesMultiOpsJavaError.UPDATE,
// AllTypesMultiOpsJavaError.DELETE},
// 7);
// }
public void testTooLargeStringInsertAndUpdate() throws IOException {
final java.util.Random r = new java.util.Random();
StringBuilder sb = new StringBuilder(300);
for (int ii = 0; ii < 300; ii++) {
sb.append(r.nextInt(9));
}
final String insertQuery = "INSERT INTO CUSTOMER_NAME VALUES ( 0, 0, 0, 'foo','" + sb.toString() + "')";
final String updateQuery = "UPDATE CUSTOMER_NAME SET C_ID = 0, C_D_ID = 0, C_W_ID = 0, C_FIRST = 'foo', C_LAST ='" + sb.toString() + "'";
final Client client = getClient();
boolean threwException = false;
try {
client.callProcedure("@AdHoc", insertQuery);
} catch (ProcCallException e) {
threwException = true;
}
assertTrue(threwException);
VoltTable results[] = null;
try {
results = client.callProcedure("@AdHoc", "SELECT * FROM CUSTOMER_NAME").getResults();
} catch (ProcCallException e) {
fail();
}
assertNotNull(results);
assertEquals(1, results.length);
assertEquals(0, results[0].getRowCount());
try {
client.callProcedure("@AdHoc", "INSERT INTO CUSTOMER_NAME VALUES ( 0, 0, 0, 'foo', 'bar')");
} catch (ProcCallException e) {
fail();
}
threwException = false;
try {
client.callProcedure("@AdHoc", updateQuery);
} catch (ProcCallException e) {
e.printStackTrace();
threwException = true;
}
assertTrue(threwException);
results = null;
try {
results = client.callProcedure("@AdHoc", "SELECT * FROM CUSTOMER_NAME").getResults();
} catch (ProcCallException e) {
fail();
}
assertNotNull(results);
assertEquals(1, results.length);
assertEquals(1, results[0].getRowCount());
VoltTable result = results[0];
result.advanceRow();
assertEquals( 0, result.getLong(0));
assertEquals( 0, result.getLong(1));
assertEquals( 0, result.getLong(2));
assertTrue( "foo".equals(result.getString(3)));
assertTrue( "bar".equals(result.getString(4)));
}
//FIXME
// public void testSinglePartitionConstraintFailureAndContinue() throws IOException {
// Client client = getClient();
// VoltTable results[] = null;
// try {
// results = client.callProcedure("SinglePartitionConstraintFailureAndContinue", 2).getResults();
// }
// catch (ProcCallException e) {
// fail("Didn't expect a ProcCallException if the user caught the constraint failure");
// }
// catch (IOException e) {
// e.printStackTrace();
// fail();
// }
// assertNotNull(results);
// assertEquals( 1, results.length);
// assertEquals( 0, results[0].getRowCount());
//
// try {
// results = client.callProcedure("SelectAll").getResults();
// assertEquals(9, results.length);
//
// // get the new order table
// VoltTable table = results[7];
// assertTrue(table.getRowCount() == 0);
//
// }
// catch (ProcCallException e) {
// e.printStackTrace();
// fail();
// }
// catch (IOException e) {
// e.printStackTrace();
// fail();
// }
// }
public void testMultiPartitionJavaFailure() throws IOException {
Client client = getClient();
try {
client.callProcedure("MultiPartitionJavaError", 2);
fail();
}
catch (ProcCallException e) {}
catch (IOException e) {
e.printStackTrace();
fail();
}
try {
VoltTable[] results = client.callProcedure("SelectAll").getResults();
assertEquals(results.length, 9);
// get the new order table
VoltTable table = results[2];
assertTrue(table.getRowCount() == 0);
}
catch (ProcCallException e) {
e.printStackTrace();
fail();
}
catch (IOException e) {
e.printStackTrace();
fail();
}
}
public void testMultiPartitionJavaAbort() throws IOException {
Client client = getClient();
try {
client.callProcedure("MultiPartitionJavaAbort", 2);
fail();
}
catch (ProcCallException e) {}
catch (IOException e) {
e.printStackTrace();
fail();
}
try {
VoltTable[] results = client.callProcedure("SelectAll").getResults();
assertEquals(results.length, 9);
// get the new order table
VoltTable table = results[2];
assertTrue(table.getRowCount() == 0);
}
catch (ProcCallException e) {
e.printStackTrace();
fail();
}
catch (IOException e) {
e.printStackTrace();
fail();
}
}
public void testMultiPartitionConstraintFailure() throws IOException {
Client client = getClient();
try {
System.out.println("Calling MultiPartitionConstraintError");
System.out.flush();
client.callProcedure("MultiPartitionConstraintError", 2);
System.out.println("Called MultiPartitionConstraintError");
System.out.flush();
fail();
}
catch (ProcCallException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
fail();
}
try {
System.out.println("Calling SelectAll");
System.out.flush();
ClientResponse cr = client.callProcedure("SelectAll");
System.err.println(cr);
VoltTable[] results = cr.getResults();
System.out.println("Called SelectAll");
System.out.flush();
assertEquals(results.length, 9);
// get the new order table
VoltTable table = results[2];
System.out.println(table.toString());
assertEquals(cr.toString(), 0, table.getRowCount());
}
catch (ProcCallException e) {
e.printStackTrace();
fail();
}
catch (IOException e) {
e.printStackTrace();
fail();
}
}
// FIXME
// public void testOverflowMatView() throws IOException {
// Client client = getClient();
//
// try {
// client.callProcedure("InsertNewOrder", Long.MAX_VALUE - 2, 2, 2);
// client.callProcedure("InsertNewOrder", 1, 3, 2);
// }
// catch (Exception e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// String update = "UPDATE NEW_ORDER SET NO_O_ID = " + Long.MAX_VALUE + " WHERE NO_D_ID = 3;";
// client.callProcedure("@AdHoc", update);
// fail();
// }
// catch (ProcCallException e) {}
// catch (IOException e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// VoltTable[] results = client.callProcedure("SelectAll").getResults();
//
// assertEquals(results.length, 9);
//
// // get the new order table
// VoltTable table = results[7];
// assertTrue(table.getRowCount() == 2);
// table.advanceRow();
// assertEquals(Long.MAX_VALUE - 2, table.getLong(0));
// assertEquals(2, table.getLong(1));
// assertEquals(2, table.getLong(2));
// table.advanceRow();
// assertEquals(1, table.getLong(0));
// assertEquals(3, table.getLong(1));
// assertEquals(2, table.getLong(2));
//
// // check the mat view
// results = client.callProcedure("ReadMatView", 2).getResults();
// assertEquals(results.length, 1);
// table = results[0];
// table.advanceRow();
// System.out.println(table);
// assertTrue(table.getRowCount() == 1);
// long col1 = table.getLong(0);
// assertEquals(2, col1);
// long col2 = table.getLong(1);
// assertEquals(2, col2);
// long col3 = table.getLong(2);
// assertEquals(Long.MAX_VALUE - 1, col3);
// }
// catch (Exception e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// VoltTable[] results = client.callProcedure("FetchNORowUsingIndex", 2, 3, 1).getResults();
//
// assertEquals(results.length, 1);
// VoltTable table = results[0];
// int rowCount = table.getRowCount();
// assertEquals(1, rowCount);
// table.advanceRow();
// assertEquals(1, table.getLong(0));
// assertEquals(3, table.getLong(1));
// assertEquals(2, table.getLong(2));
// }
// catch (Exception e) {
// e.printStackTrace();
// fail();
// }
// }
//
//FIXME
// public void testUpdateViolatesUniqueConstraint() throws IOException {
// Client client = getClient();
//
// try {
// client.callProcedure("InsertNewOrder", 2, 2, 2);
// client.callProcedure("InsertNewOrder", 3, 4, 2);
// }
// catch (Exception e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// ClientResponse cr = client.callProcedure("@AdHoc", "SELECT * FROM NEW_ORDER;");
// System.err.println(cr);
// assertEquals(1, cr.getResults().length);
// VoltTable table = cr.getResults()[0];
// assertTrue(table.getRowCount() == 2);
// table.advanceRow();
// assertEquals(2, table.getLong(0));
// assertEquals(2, table.getLong(1));
// assertEquals(2, table.getLong(2));
// table.advanceRow();
// assertEquals(3, table.getLong(0));
// assertEquals(4, table.getLong(1));
// assertEquals(2, table.getLong(2));
//
// }
// catch (ProcCallException e) {
// e.printStackTrace();
// fail();
// }
// catch (IOException e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// String update = "UPDATE NEW_ORDER SET NO_O_ID = " + 2 + ", NO_D_ID = 2 WHERE NO_D_ID = 4;";
// client.callProcedure("@AdHoc", update);
// fail();
// }
// catch (ProcCallException e) {
// e.printStackTrace();
// }
// catch (IOException e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// ClientResponse cr = client.callProcedure("SelectAll");
// System.err.println(cr);
// VoltTable[] results = cr.getResults();
// assertEquals(results.length, 9);
//
// // get the new order table
// VoltTable table = results[7];
// System.out.println(table);
// assertTrue(table.getRowCount() == 2);
// table.advanceRow();
// assertEquals(2, table.getLong(0));
// assertEquals(2, table.getLong(1));
// assertEquals(2, table.getLong(2));
// table.advanceRow();
// assertEquals(3, table.getLong(0));
// assertEquals(4, table.getLong(1));
// assertEquals(2, table.getLong(2));
//
// // check the mat view
// results = client.callProcedure("ReadMatView", 2).getResults();
// assertEquals(results.length, 1);
// table = results[0];
// table.advanceRow();
// System.out.println(table);
// assertTrue(table.getRowCount() == 1);
// long col1 = table.getLong(0);
// assertEquals(2, col1);
// long col2 = table.getLong(1);
// assertEquals(2, col2);
// long col3 = table.getLong(2);
// assertEquals(5, col3);
// }
// catch (Exception e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// VoltTable[] results = client.callProcedure("FetchNORowUsingIndex", 2, 4, 3).getResults();
//
// assertEquals(results.length, 1);
// VoltTable table = results[0];
// int rowCount = table.getRowCount();
// assertEquals(1, rowCount);
// table.advanceRow();
// assertEquals(3, table.getLong(0));
// assertEquals(4, table.getLong(1));
// assertEquals(2, table.getLong(2));
// }
// catch (Exception e) {
// e.printStackTrace();
// fail();
// }
// }
//
// public void testUpdateViolatesNotNullConstraint() throws IOException {
// Client client = getClient();
//
// try {
// client.callProcedure("InsertNewOrder", 2, 2, 2);
// client.callProcedure("InsertNewOrder", 3, 4, 2);
// }
// catch (Exception e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// String update = "UPDATE NEW_ORDER SET NO_O_ID = -9223372036854775808, NO_D_ID = -9223372036854775808 WHERE NO_D_ID = 4;";
// client.callProcedure("@AdHoc", update);
// fail();
// }
// catch (ProcCallException e) {
//// e.printStackTrace();
// e.getCause().printStackTrace();
// }
// catch (IOException e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// VoltTable[] results = client.callProcedure("SelectAll").getResults();
//
// assertEquals(results.length, 9);
//
// // get the new order table
// VoltTable table = results[7];
// System.out.println(table);
// assertTrue(table.getRowCount() == 2);
// table.advanceRow();
// assertEquals(2, table.getLong(0));
// assertEquals(2, table.getLong(1));
// assertEquals(2, table.getLong(2));
// table.advanceRow();
// assertEquals(3, table.getLong(0));
// assertEquals(4, table.getLong(1));
// assertEquals(2, table.getLong(2));
//
// // check the mat view
// results = client.callProcedure("ReadMatView", 2).getResults();
// assertEquals(results.length, 1);
// table = results[0];
// table.advanceRow();
// System.out.println(table);
// assertTrue(table.getRowCount() == 1);
// long col1 = table.getLong(0);
// assertEquals(2, col1);
// long col2 = table.getLong(1);
// assertEquals(2, col2);
// long col3 = table.getLong(2);
// assertEquals(5, col3);
// }
// catch (Exception e) {
// e.printStackTrace();
// fail();
// }
//
// try {
// VoltTable[] results = client.callProcedure("FetchNORowUsingIndex", 2, 4, 3).getResults();
//
// assertEquals(results.length, 1);
// VoltTable table = results[0];
// int rowCount = table.getRowCount();
// assertEquals(1, rowCount);
// table.advanceRow();
// assertEquals(3, table.getLong(0));
// assertEquals(4, table.getLong(1));
// assertEquals(2, table.getLong(2));
// }
// catch (Exception e) {
// e.printStackTrace();
// fail();
// }
// }
/**
* Build a list of the tests that will be run when TestTPCCSuite gets run by JUnit.
* Use helper classes that are part of the RegressionSuite framework.
* This particular class runs all tests on the the local JNI backend with both
* one and two partition configurations, as well as on the hsql backend.
*
* @return The TestSuite containing all the tests to be run.
*/
static public Test suite() {
VoltServerConfig config = null;
// the suite made here will all be using the tests from this class
MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestRollbackSuite.class);
builder.setGlobalConfParameter("site.exec_adhoc_sql", true);
builder.setGlobalConfParameter("site.status_exec_info", true);
// build up a project builder for the workload
TPCCProjectBuilder project = new TPCCProjectBuilder();
project.addSchema(SinglePartitionJavaError.class.getResource("tpcc-extraview-ddl.sql"));
project.addDefaultPartitioning();
project.addProcedures(PROCEDURES);
project.addStmtProcedure("InsertNewOrder", "INSERT INTO NEW_ORDER VALUES (?, ?, ?);", "NEW_ORDER.NO_W_ID: 2");
boolean success;
/////////////////////////////////////////////////////////////
// CONFIG #1: 1 Local Site/Partitions running on JNI backend
/////////////////////////////////////////////////////////////
// get a server config for the native backend with one sites/partitions
config = new LocalSingleProcessServer("rollback-onesite.jar", 1, BackendTarget.NATIVE_EE_JNI);
success = config.compile(project);
assert(success);
builder.addServerConfig(config);
/////////////////////////////////////////////////////////////
// CONFIG #2: 2 Local Site/Partitions running on JNI backend
/////////////////////////////////////////////////////////////
// get a server config for the native backend with two sites/partitions
config = new LocalSingleProcessServer("rollback-twosites.jar", 2, BackendTarget.NATIVE_EE_JNI);
success = config.compile(project);
assert(success);
builder.addServerConfig(config);
/////////////////////////////////////////////////////////////
// CONFIG #3: Local Cluster (of processes)
/////////////////////////////////////////////////////////////
config = new LocalCluster("rollback-cluster.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
success = config.compile(project);
assert(success);
builder.addServerConfig(config);
return builder;
}
public static void main(String args[]) {
org.junit.runner.JUnitCore.runClasses(TestRollbackSuite.class);
}
}