/**
* testInitialize
*/
public void testInitialize() throws Exception {
Client client = this.getClient();
CatalogContext catalogContext = this.getCatalogContext();
SEATSLoader loader = this.initializeSEATSDatabase(catalogContext, client);
SEATSProfile profile = loader.getProfile();
assertNotNull(profile);
Set<String> allTables = new HashSet<String>();
CollectionUtil.addAll(allTables, SEATSConstants.TABLES_SCALING);
CollectionUtil.addAll(allTables, SEATSConstants.TABLES_DATAFILES);
Map<String, Long> expected = new HashMap<String, Long>();
expected.put(SEATSConstants.TABLENAME_FLIGHT, profile.num_flights);
expected.put(SEATSConstants.TABLENAME_CUSTOMER, profile.num_customers);
expected.put(SEATSConstants.TABLENAME_RESERVATION, profile.num_reservations);
String procName = VoltSystemProcedure.procCallName(AdHoc.class);
for (String tableName : allTables) {
String query = "SELECT COUNT(*) FROM " + tableName;
ClientResponse cresponse = client.callProcedure(procName, query);
assertEquals(Status.OK, cresponse.getStatus());
VoltTable results[] = cresponse.getResults();
assertEquals(1, results.length);
long count = results[0].asScalarLong();
if (expected.containsKey(tableName)) {
assertEquals(tableName, expected.get(tableName).longValue(), count);
}
else {
assertTrue(tableName + " -> " + count, count > 0);
}
} // FOR
// Make sure that our FLIGHT rows are correct
String query = "SELECT * FROM " + SEATSConstants.TABLENAME_FLIGHT;
ClientResponse cresponse = RegressionSuiteUtil.sql(client, query);
VoltTable results[] = cresponse.getResults();
assertEquals(profile.num_flights, results[0].getRowCount());
Table tbl = catalogContext.getTableByName(SEATSConstants.TABLENAME_FLIGHT);
assertEquals(tbl.getColumns().size(), results[0].getColumnCount());
List<Column> notNullCols = new ArrayList<Column>();
for (Column col : tbl.getColumns()) {
if (col.getNullable() == false) notNullCols.add(col);
}