use of com.jcabi.jdbc.JdbcSession in project phoenix by apache.
the class DataIngestIT method testRWWorkload.
@Test
public void testRWWorkload() throws Exception {
Connection connection = util.getConnection();
WorkloadExecutor executor = new WorkloadExecutor();
DataModel dataModel = parser.getDataModelByName("test_scenario");
List<DataModel> dataModels = new ArrayList<>();
dataModels.add(dataModel);
QueryExecutor qe = new QueryExecutor(parser, util, executor, dataModels, null, false);
executor.add(qe);
Scenario scenario = parser.getScenarioByName("testScenarioRW");
String sql = "select count(*) from " + scenario.getTableName();
try {
// Wait for data to load up.
executor.get();
executor.shutdown();
// Verify data has been loaded
Integer count = new JdbcSession(connection).sql(sql).select(new Outcome<Integer>() {
@Override
public Integer handle(ResultSet resultSet, Statement statement) throws SQLException {
while (resultSet.next()) {
return resultSet.getInt(1);
}
return null;
}
});
assertNotNull("Could not retrieve count. " + count);
// It would be better to sum up all the rowcounts for the scenarios, but this is fine
assertTrue("Could not query any rows for in " + scenario.getTableName(), count > 0);
} catch (Exception e) {
fail("Failed to load data. An exception was thrown: " + e.getMessage());
}
}
use of com.jcabi.jdbc.JdbcSession in project phoenix by apache.
the class DataIngestIT method assertExpectedNumberOfRecordsWritten.
private void assertExpectedNumberOfRecordsWritten(Scenario scenario) throws Exception, SQLException {
Connection connection = util.getConnection(scenario.getTenantId());
String sql = "select count(*) from " + scenario.getTableName();
Integer count = new JdbcSession(connection).sql(sql).select(new Outcome<Integer>() {
@Override
public Integer handle(ResultSet resultSet, Statement statement) throws SQLException {
while (resultSet.next()) {
return resultSet.getInt(1);
}
return null;
}
});
assertNotNull("Could not retrieve count. " + count);
assertEquals("Expected 100 rows to have been inserted", scenario.getRowCount(), count.intValue());
}
Aggregations