Search in sources :

Example 1 with RowLevelPolicyCheckerBuilderFactory

use of org.apache.gobblin.qualitychecker.row.RowLevelPolicyCheckerBuilderFactory in project incubator-gobblin by apache.

the class RowLevelQualityCheckerTest method testRowLevelPolicy.

@Test(groups = { "ignore" })
public void testRowLevelPolicy() throws Exception {
    State state = new State();
    state.setProp(ConfigurationKeys.ROW_LEVEL_POLICY_LIST, "org.apache.gobblin.qualitychecker.TestRowLevelPolicy");
    state.setProp(ConfigurationKeys.ROW_LEVEL_POLICY_LIST_TYPE, "FAIL");
    RowLevelPolicyChecker checker = new RowLevelPolicyCheckerBuilderFactory().newPolicyCheckerBuilder(state, -1).build();
    RowLevelPolicyCheckResults results = new RowLevelPolicyCheckResults();
    FileReader<GenericRecord> fileReader = openFile(state);
    for (GenericRecord datum : fileReader) {
        Assert.assertTrue(checker.executePolicies(datum, results));
    }
}
Also used : State(org.apache.gobblin.configuration.State) RowLevelPolicyChecker(org.apache.gobblin.qualitychecker.row.RowLevelPolicyChecker) RowLevelPolicyCheckResults(org.apache.gobblin.qualitychecker.row.RowLevelPolicyCheckResults) GenericRecord(org.apache.avro.generic.GenericRecord) RowLevelPolicyCheckerBuilderFactory(org.apache.gobblin.qualitychecker.row.RowLevelPolicyCheckerBuilderFactory) Test(org.testng.annotations.Test)

Example 2 with RowLevelPolicyCheckerBuilderFactory

use of org.apache.gobblin.qualitychecker.row.RowLevelPolicyCheckerBuilderFactory in project incubator-gobblin by apache.

the class RowLevelQualityCheckerTest method testWriteToErrFile.

@Test(groups = { "ignore" })
public void testWriteToErrFile() throws Exception {
    State state = new State();
    state.setProp(ConfigurationKeys.ROW_LEVEL_POLICY_LIST, "org.apache.gobblin.qualitychecker.TestRowLevelPolicyFail");
    state.setProp(ConfigurationKeys.ROW_LEVEL_POLICY_LIST_TYPE, "ERR_FILE");
    state.setProp(ConfigurationKeys.ROW_LEVEL_ERR_FILE, TestConstants.TEST_ERR_FILE);
    state.setProp(ConfigurationKeys.WRITER_FILE_SYSTEM_URI, TestConstants.TEST_FS_URI);
    RowLevelPolicyChecker checker = new RowLevelPolicyCheckerBuilderFactory().newPolicyCheckerBuilder(state, -1).build();
    RowLevelPolicyCheckResults results = new RowLevelPolicyCheckResults();
    FileReader<GenericRecord> fileReader = openFile(state);
    for (GenericRecord datum : fileReader) {
        Assert.assertFalse(checker.executePolicies(datum, results));
    }
    FileSystem fs = FileSystem.get(new URI(TestConstants.TEST_FS_URI), new Configuration());
    Path outputPath = new Path(TestConstants.TEST_ERR_FILE, state.getProp(ConfigurationKeys.ROW_LEVEL_POLICY_LIST).replaceAll("\\.", "-") + ".err");
    Assert.assertTrue(fs.exists(outputPath));
    fs.delete(new Path(TestConstants.TEST_ERR_FILE), true);
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) State(org.apache.gobblin.configuration.State) FileSystem(org.apache.hadoop.fs.FileSystem) RowLevelPolicyChecker(org.apache.gobblin.qualitychecker.row.RowLevelPolicyChecker) RowLevelPolicyCheckResults(org.apache.gobblin.qualitychecker.row.RowLevelPolicyCheckResults) GenericRecord(org.apache.avro.generic.GenericRecord) URI(java.net.URI) RowLevelPolicyCheckerBuilderFactory(org.apache.gobblin.qualitychecker.row.RowLevelPolicyCheckerBuilderFactory) Test(org.testng.annotations.Test)

Aggregations

GenericRecord (org.apache.avro.generic.GenericRecord)2 State (org.apache.gobblin.configuration.State)2 RowLevelPolicyCheckResults (org.apache.gobblin.qualitychecker.row.RowLevelPolicyCheckResults)2 RowLevelPolicyChecker (org.apache.gobblin.qualitychecker.row.RowLevelPolicyChecker)2 RowLevelPolicyCheckerBuilderFactory (org.apache.gobblin.qualitychecker.row.RowLevelPolicyCheckerBuilderFactory)2 Test (org.testng.annotations.Test)2 URI (java.net.URI)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1