Skip to content

Commit

Permalink
Changed SmallBankLoader so that all accounts are guaranteed to have a…
Browse files Browse the repository at this point in the history
… CHECKING and SAVINGS acct. This removes the spurious errors in TestSmallBankSuite. I'm not sure why I even did this in the first place...
  • Loading branch information
apavlo committed May 14, 2013
1 parent e596540 commit edccaa0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
Expand Up @@ -48,7 +48,7 @@ public abstract class SmallBankConstants {
public static final String TABLENAME_SAVINGS = "SAVINGS";
public static final String TABLENAME_CHECKING = "CHECKING";

public static final int BATCH_SIZE = 1000;
public static final int BATCH_SIZE = 5000;

// ----------------------------------------------------------------
// ACCOUNT INFORMATION
Expand All @@ -63,12 +63,6 @@ public abstract class SmallBankConstants {
// ADDITIONAL CONFIGURATION SETTINGS
// ----------------------------------------------------------------

// Percentage of customers that do not have a SAVINGS account [0-100%]
public static final int PERCENTAGE_NO_SAVINGS = 0;

// Percentage of customers that do not have a CHECKING account [0-100%]
public static final int PERCENTAGE_NO_CHECKING = 0;

// Initial balance amount
public static final int MIN_BALANCE = 100;
public static final int MAX_BALANCE = 5000;
Expand Down
Expand Up @@ -132,16 +132,10 @@ public void run() {
this.acctsTable.addRow(acctId, acctName);

// CHECKINGS
if (rand.nextInt(100) > SmallBankConstants.PERCENTAGE_NO_CHECKING) {
double balance = this.randBalance.nextInt();
this.checkingTable.addRow(acctId, balance);
}
this.checkingTable.addRow(acctId, this.randBalance.nextInt());

// SAVINGS
if (rand.nextInt(100) > SmallBankConstants.PERCENTAGE_NO_SAVINGS) {
double balance = this.randBalance.nextInt();
this.savingsTable.addRow(acctId, balance);
}
this.savingsTable.addRow(acctId, this.randBalance.nextInt());

if (++batchSize >= SmallBankConstants.BATCH_SIZE) {
this.loadTables();
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/edu/brown/hstore/HStoreThreadManager.java
Expand Up @@ -183,7 +183,7 @@ public HStoreThreadManager(HStoreSite hstore_site) {
}
else if (this.num_cores <= host_partitions.size()) {
LOG.warn(String.format("Unable to set CPU affinity on %s because there are %d partitions " +
"but only %d available cores",
"but only %d available CPU cores",
host.getIpaddr(), host_partitions.size(), this.num_cores));
this.disable = true;
}
Expand Down
Expand Up @@ -48,7 +48,6 @@ public class TestDependencyTrackerPrefetch extends BaseTestCase {

private static final Class<? extends VoltProcedure> TARGET_PROCEDURE = neworder.class;
private static final String TARGET_STATEMENT = "getStockInfo";


private HStoreSite hstore_site;
private PartitionExecutor executor;
Expand Down
Expand Up @@ -58,12 +58,18 @@ public static long getRowCount(Client client, String tableName) throws Exception
ClientResponse cresponse = getStats(client, SysProcSelector.TABLE);
VoltTable result = cresponse.getResults()[0];

long count = 0;
boolean found = false;
while (result.advanceRow()) {
if (tableName.equalsIgnoreCase(result.getString("TABLE_NAME"))) {
return result.getLong("TUPLE_COUNT");
found = true;
count += result.getLong("TUPLE_COUNT");
}
} // WHILE
throw new IllegalArgumentException("Invalid table '" + tableName + "'");
if (found == false) {
throw new IllegalArgumentException("Invalid table '" + tableName + "'");
}
return (count);
}

/**
Expand Down
Expand Up @@ -8,13 +8,13 @@
import org.voltdb.client.Client;
import org.voltdb.client.ClientResponse;
import org.voltdb.client.ProcCallException;
import org.voltdb.utils.VoltTableUtil;

import edu.brown.benchmark.smallbank.SmallBankConstants;
import edu.brown.benchmark.smallbank.SmallBankLoader;
import edu.brown.benchmark.smallbank.SmallBankProjectBuilder;
import edu.brown.benchmark.smallbank.procedures.SendPayment;
import edu.brown.hstore.Hstoreservice.Status;
import edu.brown.utils.CollectionUtil;

/**
* Simple test suite for the SmallBank benchmark
Expand All @@ -23,7 +23,7 @@
public class TestSmallBankSuite extends RegressionSuite {

private static final String PREFIX = "smallbank";
private static final double SCALEFACTOR = 0.001;
private static final double SCALEFACTOR = 0.0001;

/**
* Constructor needed for JUnit. Should just pass on parameters to superclass.
Expand All @@ -41,9 +41,13 @@ private void checkBalance(Client client, long acctId, double expected) throws Ex
assertEquals(Status.OK, cresponse.getStatus());
VoltTable results[] = cresponse.getResults();
assertEquals(1, results.length);
assertEquals(1, results[0].getRowCount());

if (results[0].getRowCount() == 0) {
System.err.println(VoltTableUtil.format(results[0]));
}
assertEquals("No rows for acctId "+acctId, 1, results[0].getRowCount());
assertTrue(results[0].advanceRow());
assertEquals(expected, results[0].getDouble("bal"));
assertEquals("Mismatched balance for acctId "+acctId, expected, results[0].getDouble("bal"));
}

private void updateBalance(Client client, long acctId, double balance) throws Exception {
Expand Down Expand Up @@ -72,6 +76,7 @@ public void testSendPayment() throws Exception {

long num_rows = RegressionSuiteUtil.getRowCount(client, SmallBankConstants.TABLENAME_ACCOUNTS);
assert(num_rows > acctIds[acctIds.length-1]);
// System.err.println("# of Rows: " + num_rows);

for (int i = 0; i < acctIds.length; i++) {
this.updateBalance(client, acctIds[i], balances[i]);
Expand Down

0 comments on commit edccaa0

Please sign in to comment.