Search in sources :

Example 1 with WorkUnitState

use of org.apache.gobblin.configuration.WorkUnitState in project incubator-gobblin by apache.

the class InstrumentedDataWriterTest method test.

@Test
public void test() throws IOException {
    WorkUnitState state = new WorkUnitState();
    state.setProp(ConfigurationKeys.METRICS_ENABLED_KEY, Boolean.toString(true));
    TestInstrumentedDataWriter writer = new TestInstrumentedDataWriter(state);
    testBase(writer);
}
Also used : WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) Test(org.testng.annotations.Test)

Example 2 with WorkUnitState

use of org.apache.gobblin.configuration.WorkUnitState in project incubator-gobblin by apache.

the class AbstractSourceTest method setUpBeforeClass.

@BeforeClass
public void setUpBeforeClass() {
    this.testSource = new TestSource<>();
    WorkUnitState committedWorkUnitState = new WorkUnitState();
    committedWorkUnitState.setWorkingState(WorkingState.COMMITTED);
    WorkUnitState successfulWorkUnitState = new WorkUnitState();
    successfulWorkUnitState.setWorkingState(WorkingState.SUCCESSFUL);
    WorkUnitState failedWorkUnitState = new WorkUnitState();
    failedWorkUnitState.setWorkingState(WorkingState.FAILED);
    this.previousWorkUnitStates = Lists.newArrayList(committedWorkUnitState, successfulWorkUnitState, failedWorkUnitState);
    this.expectedPreviousWorkUnitStates = Lists.newArrayList(successfulWorkUnitState, failedWorkUnitState);
}
Also used : WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with WorkUnitState

use of org.apache.gobblin.configuration.WorkUnitState in project incubator-gobblin by apache.

the class AbstractSourceTest method testGetPreviousWorkUnitStatesEnabledRetry.

/**
 * Test the always-retry policy, with WORK_UNIT_RETRY_ENABLED_KEY enabled.
 */
@Test
public void testGetPreviousWorkUnitStatesEnabledRetry() {
    SourceState sourceState = new SourceState(new State(), this.previousWorkUnitStates);
    sourceState.setProp(ConfigurationKeys.WORK_UNIT_RETRY_ENABLED_KEY, Boolean.TRUE);
    List<WorkUnitState> returnedWorkUnitStates = this.testSource.getPreviousWorkUnitStatesForRetry(sourceState);
    Assert.assertEquals(returnedWorkUnitStates, this.expectedPreviousWorkUnitStates);
}
Also used : SourceState(org.apache.gobblin.configuration.SourceState) WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) State(org.apache.gobblin.configuration.State) WorkingState(org.apache.gobblin.configuration.WorkUnitState.WorkingState) SourceState(org.apache.gobblin.configuration.SourceState) WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) Test(org.testng.annotations.Test)

Example 4 with WorkUnitState

use of org.apache.gobblin.configuration.WorkUnitState in project incubator-gobblin by apache.

the class EncryptionConfigParserTest method testConverterWithEntityPrefix.

@Test
public void testConverterWithEntityPrefix() {
    final String entityName = "MyConverter";
    WorkUnitState wuState = new WorkUnitState();
    wuState.getJobState().setProp(EncryptionConfigParser.CONVERTER_ENCRYPT_PREFIX + "." + EncryptionConfigParser.ENCRYPTION_ALGORITHM_KEY, "any");
    wuState.getJobState().setProp(EncryptionConfigParser.CONVERTER_ENCRYPT_PREFIX + "." + entityName + "." + EncryptionConfigParser.ENCRYPTION_ALGORITHM_KEY, "aes_rotating");
    wuState.getJobState().setProp(EncryptionConfigParser.CONVERTER_ENCRYPT_PREFIX + "." + EncryptionConfigParser.ENCRYPTION_KEYSTORE_PATH_KEY, "/tmp/foobar");
    wuState.getJobState().setProp(EncryptionConfigParser.CONVERTER_ENCRYPT_PREFIX + "." + EncryptionConfigParser.ENCRYPTION_KEYSTORE_PASSWORD_KEY, "abracadabra");
    wuState.getJobState().setProp(EncryptionConfigParser.CONVERTER_ENCRYPT_PREFIX + "." + EncryptionConfigParser.ENCRYPTION_KEY_NAME, "keyname");
    wuState.setProp(EncryptionConfigParser.CONVERTER_ENCRYPT_PREFIX + "abc.def", "foobar");
    Map<String, Object> parsedProperties = EncryptionConfigParser.getConfigForBranch(EncryptionConfigParser.EntityType.CONVERTER_ENCRYPT, entityName, wuState);
    Assert.assertNotNull(parsedProperties, "Expected parser to only return one record");
    Assert.assertEquals(parsedProperties.size(), 4, "Did not expect abc.def to be picked up in config");
    Assert.assertEquals(EncryptionConfigParser.getEncryptionType(parsedProperties), "aes_rotating");
    Map<String, Object> parsedWriterProperties = EncryptionConfigParser.getConfigForBranch(EncryptionConfigParser.EntityType.WRITER, wuState);
    Assert.assertNull(parsedWriterProperties, "Did not expect to find writer properties");
}
Also used : WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 5 with WorkUnitState

use of org.apache.gobblin.configuration.WorkUnitState in project incubator-gobblin by apache.

the class InstrumentedExtractorTest method test.

@Test
public void test() throws DataRecordException, IOException {
    WorkUnitState state = new WorkUnitState();
    state.setProp(ConfigurationKeys.METRICS_ENABLED_KEY, Boolean.toString(true));
    TestInstrumentedExtractor extractor = new TestInstrumentedExtractor(state);
    testBase(extractor);
}
Also used : WorkUnitState(org.apache.gobblin.configuration.WorkUnitState) Test(org.testng.annotations.Test)

Aggregations

WorkUnitState (org.apache.gobblin.configuration.WorkUnitState)222 Test (org.testng.annotations.Test)143 State (org.apache.gobblin.configuration.State)48 SourceState (org.apache.gobblin.configuration.SourceState)39 WorkUnit (org.apache.gobblin.source.workunit.WorkUnit)39 Schema (org.apache.avro.Schema)29 Path (org.apache.hadoop.fs.Path)26 GenericRecord (org.apache.avro.generic.GenericRecord)19 JsonObject (com.google.gson.JsonObject)17 ArrayList (java.util.ArrayList)16 File (java.io.File)14 TaskState (org.apache.hadoop.mapreduce.v2.api.records.TaskState)12 List (java.util.List)11 Configuration (org.apache.hadoop.conf.Configuration)11 IOException (java.io.IOException)10 LongWatermark (org.apache.gobblin.source.extractor.extract.LongWatermark)10 Extract (org.apache.gobblin.source.workunit.Extract)10 FileSystem (org.apache.hadoop.fs.FileSystem)10 Closer (com.google.common.io.Closer)8 JsonParser (com.google.gson.JsonParser)8