use of org.apache.phoenix.pherf.configuration.Scenario in project phoenix by apache.
the class DataIngestIT method testMultiTenantViewWriteWorkload.
@Test
public /**
* Validates that Pherf can write data to a Multi-Tenant View in addition to
* standard Phoenix tables.
*/
void testMultiTenantViewWriteWorkload() throws Exception {
// Arrange
Scenario scenario = parser.getScenarioByName("testMTWriteScenario");
WorkloadExecutor executor = new WorkloadExecutor();
executor.add(new WriteWorkload(util, parser, scenario, GeneratePhoenixStats.NO));
// Act
try {
// Wait for data to load up.
executor.get();
executor.shutdown();
} catch (Exception e) {
fail("Failed to load data. An exception was thrown: " + e.getMessage());
}
assertExpectedNumberOfRecordsWritten(scenario);
}
use of org.apache.phoenix.pherf.configuration.Scenario 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 org.apache.phoenix.pherf.configuration.Scenario in project phoenix by apache.
the class DataIngestIT method testMultiTenantScenarioRunBeforeWriteWorkload.
@Test
public void testMultiTenantScenarioRunBeforeWriteWorkload() throws Exception {
// Arrange
Scenario scenario = parser.getScenarioByName("testMTDdlWriteScenario");
WorkloadExecutor executor = new WorkloadExecutor();
executor.add(new WriteWorkload(util, parser, scenario, GeneratePhoenixStats.NO));
// Act
try {
// Wait for data to load up.
executor.get();
executor.shutdown();
} catch (Exception e) {
fail("Failed to load data. An exception was thrown: " + e.getMessage());
}
assertExpectedNumberOfRecordsWritten(scenario);
}
use of org.apache.phoenix.pherf.configuration.Scenario in project phoenix by apache.
the class WriteWorkload method execute.
public Runnable execute() throws Exception {
return new Runnable() {
@Override
public void run() {
try {
DataLoadTimeSummary dataLoadTimeSummary = new DataLoadTimeSummary();
DataLoadThreadTime dataLoadThreadTime = new DataLoadThreadTime();
if (WriteWorkload.this.scenario == null) {
for (Scenario scenario : getParser().getScenarios()) {
exec(dataLoadTimeSummary, dataLoadThreadTime, scenario);
}
} else {
exec(dataLoadTimeSummary, dataLoadThreadTime, WriteWorkload.this.scenario);
}
resultUtil.write(dataLoadTimeSummary);
resultUtil.write(dataLoadThreadTime);
} catch (Exception e) {
logger.warn("", e);
}
}
};
}
use of org.apache.phoenix.pherf.configuration.Scenario in project phoenix by apache.
the class RuleGeneratorTest method testValueListRule.
@Test
public void testValueListRule() throws Exception {
List<String> expectedValues = new ArrayList();
expectedValues.add("aAAyYhnNbBs9kWk");
expectedValues.add("bBByYhnNbBs9kWu");
expectedValues.add("cCCyYhnNbBs9kWr");
XMLConfigParser parser = new XMLConfigParser(matcherScenario);
WriteWorkload loader = new WriteWorkload(parser);
RulesApplier rulesApplier = loader.getRulesApplier();
Scenario scenario = parser.getScenarios().get(0);
Column simPhxCol = new Column();
simPhxCol.setName("PARENT_ID");
simPhxCol.setType(DataTypeMapping.CHAR);
// Run this 10 times gives a reasonable chance that all the values will appear at least once
for (int i = 0; i < 10; i++) {
DataValue value = rulesApplier.getDataForRule(scenario, simPhxCol);
assertTrue("Got a value not in the list for the rule. :" + value.getValue(), expectedValues.contains(value.getValue()));
}
}
Aggregations