Search in sources :

Example 6 with DataModel

use of org.apache.phoenix.pherf.configuration.DataModel in project phoenix by apache.

the class SchemaReaderIT method assertApplySchemaTest.

private void assertApplySchemaTest() {
    try {
        util.setZookeeper("localhost");
        SchemaReader reader = new SchemaReader(util, ".*datamodel/.*test.*sql");
        List<Path> resources = new ArrayList<>(reader.getResourceList());
        assertTrue("Could not pull list of schema files.", resources.size() > 0);
        assertNotNull("Could not read schema file.", this.getClass().getResourceAsStream(PherfConstants.RESOURCE_DATAMODEL + "/" + resources.get(0).getFileName().toString()));
        assertNotNull("Could not read schema file.", reader.resourceToString(resources.get(0)));
        try {
            reader.applySchema();
        } catch (SQLException e) {
            fail("Failed to apply schema " + e.getMessage());
        }
        Connection connection = null;
        URL resourceUrl = getClass().getResource("/scenario/test_scenario.xml");
        assertNotNull("Test data XML file is missing", resourceUrl);
        connection = util.getConnection();
        Path resourcePath = Paths.get(resourceUrl.toURI());
        DataModel data = XMLConfigParser.readDataModel(resourcePath);
        List<Scenario> scenarioList = data.getScenarios();
        Scenario scenario = scenarioList.get(0);
        List<Column> columnList = util.getColumnsFromPhoenix(scenario.getSchemaName(), scenario.getTableNameWithoutSchemaName(), connection);
        assertTrue("Could not retrieve Metadata from Phoenix", columnList.size() > 0);
    } catch (Exception e) {
        fail("Could not initialize SchemaReader");
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) SchemaReader(org.apache.phoenix.pherf.schema.SchemaReader) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) URL(java.net.URL) SQLException(java.sql.SQLException) Scenario(org.apache.phoenix.pherf.configuration.Scenario) Column(org.apache.phoenix.pherf.configuration.Column) DataModel(org.apache.phoenix.pherf.configuration.DataModel)

Aggregations

DataModel (org.apache.phoenix.pherf.configuration.DataModel)6 Column (org.apache.phoenix.pherf.configuration.Column)5 Test (org.junit.Test)5 XMLConfigParser (org.apache.phoenix.pherf.configuration.XMLConfigParser)4 RulesApplier (org.apache.phoenix.pherf.rules.RulesApplier)4 WriteWorkload (org.apache.phoenix.pherf.workload.WriteWorkload)4 ArrayList (java.util.ArrayList)3 DataValue (org.apache.phoenix.pherf.rules.DataValue)3 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 Scenario (org.apache.phoenix.pherf.configuration.Scenario)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 DataSequence (org.apache.phoenix.pherf.configuration.DataSequence)1 SchemaReader (org.apache.phoenix.pherf.schema.SchemaReader)1 QueryExecutor (org.apache.phoenix.pherf.workload.QueryExecutor)1 WorkloadExecutor (org.apache.phoenix.pherf.workload.WorkloadExecutor)1