Search in sources :

Example 1 with Scenario

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);
}
Also used : WriteWorkload(org.apache.phoenix.pherf.workload.WriteWorkload) WorkloadExecutor(org.apache.phoenix.pherf.workload.WorkloadExecutor) SQLException(java.sql.SQLException) Scenario(org.apache.phoenix.pherf.configuration.Scenario) Test(org.junit.Test)

Example 2 with 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());
    }
}
Also used : JdbcSession(com.jcabi.jdbc.JdbcSession) SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) WorkloadExecutor(org.apache.phoenix.pherf.workload.WorkloadExecutor) SQLException(java.sql.SQLException) Scenario(org.apache.phoenix.pherf.configuration.Scenario) DataModel(org.apache.phoenix.pherf.configuration.DataModel) QueryExecutor(org.apache.phoenix.pherf.workload.QueryExecutor) ResultSet(java.sql.ResultSet) Test(org.junit.Test)

Example 3 with Scenario

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);
}
Also used : WriteWorkload(org.apache.phoenix.pherf.workload.WriteWorkload) WorkloadExecutor(org.apache.phoenix.pherf.workload.WorkloadExecutor) SQLException(java.sql.SQLException) Scenario(org.apache.phoenix.pherf.configuration.Scenario) Test(org.junit.Test)

Example 4 with 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);
            }
        }
    };
}
Also used : DataLoadThreadTime(org.apache.phoenix.pherf.result.DataLoadThreadTime) DataLoadTimeSummary(org.apache.phoenix.pherf.result.DataLoadTimeSummary) PherfException(org.apache.phoenix.pherf.exception.PherfException) SQLException(java.sql.SQLException) Scenario(org.apache.phoenix.pherf.configuration.Scenario)

Example 5 with Scenario

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()));
    }
}
Also used : RulesApplier(org.apache.phoenix.pherf.rules.RulesApplier) Column(org.apache.phoenix.pherf.configuration.Column) DataValue(org.apache.phoenix.pherf.rules.DataValue) WriteWorkload(org.apache.phoenix.pherf.workload.WriteWorkload) ArrayList(java.util.ArrayList) XMLConfigParser(org.apache.phoenix.pherf.configuration.XMLConfigParser) Scenario(org.apache.phoenix.pherf.configuration.Scenario) Test(org.junit.Test)

Aggregations

Scenario (org.apache.phoenix.pherf.configuration.Scenario)8 SQLException (java.sql.SQLException)6 Test (org.junit.Test)6 WriteWorkload (org.apache.phoenix.pherf.workload.WriteWorkload)5 Column (org.apache.phoenix.pherf.configuration.Column)4 WorkloadExecutor (org.apache.phoenix.pherf.workload.WorkloadExecutor)4 ArrayList (java.util.ArrayList)3 DataValue (org.apache.phoenix.pherf.rules.DataValue)3 RulesApplier (org.apache.phoenix.pherf.rules.RulesApplier)3 Connection (java.sql.Connection)2 DataModel (org.apache.phoenix.pherf.configuration.DataModel)2 XMLConfigParser (org.apache.phoenix.pherf.configuration.XMLConfigParser)2 QueryExecutor (org.apache.phoenix.pherf.workload.QueryExecutor)2 JdbcSession (com.jcabi.jdbc.JdbcSession)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 Map (java.util.Map)1 PherfException (org.apache.phoenix.pherf.exception.PherfException)1