use of org.apache.gobblin.configuration.State in project incubator-gobblin by apache.
the class TaskMetricsTest method testTaskGetMetrics.
@Test
public void testTaskGetMetrics() {
String jobId = "job_456";
String taskId = "task_456";
String jobName = "jobName";
JobState jobState = new JobState(jobName, jobId);
JobMetrics jobMetrics = JobMetrics.get(jobState);
State props = new State();
props.setProp(ConfigurationKeys.JOB_ID_KEY, jobId);
props.setProp(ConfigurationKeys.TASK_ID_KEY, taskId);
SourceState sourceState = new SourceState(props, new ArrayList<WorkUnitState>());
WorkUnit workUnit = new WorkUnit(sourceState, null);
WorkUnitState workUnitState = new WorkUnitState(workUnit);
TaskState taskState = new TaskState(workUnitState);
TaskMetrics taskMetrics = new TaskMetrics(taskState);
Assert.assertNotNull(taskMetrics.getMetricContext());
Assert.assertTrue(taskMetrics.getMetricContext().getParent().isPresent());
Assert.assertEquals(taskMetrics.getMetricContext().getParent().get(), jobMetrics.getMetricContext());
}
use of org.apache.gobblin.configuration.State in project incubator-gobblin by apache.
the class JobMetricsTest method testCustomTags.
@Test
public void testCustomTags() {
Properties testProperties = new Properties();
Tag<String> expectedPropertyTag = new Tag<>("key1", "value1");
GobblinMetrics.addCustomTagToProperties(testProperties, expectedPropertyTag);
State testState = new State(testProperties);
List<Tag<?>> tags = GobblinMetrics.getCustomTagsFromState(testState);
Assert.assertEquals(Iterables.getFirst(tags, null), expectedPropertyTag);
Tag<String> expectedStateTag = new Tag<>("key2", "value2");
GobblinMetrics.addCustomTagToState(testState, expectedStateTag);
tags = GobblinMetrics.getCustomTagsFromState(testState);
Assert.assertTrue(tags.containsAll(ImmutableList.of(expectedPropertyTag, expectedStateTag)));
}
use of org.apache.gobblin.configuration.State in project incubator-gobblin by apache.
the class ForkOperatorUtilsTest method testGetPathForBranch.
@Test
public void testGetPathForBranch() {
State state = new State();
state.setProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + ".0", FORK_BRANCH_NAME_0);
state.setProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + ".1", FORK_BRANCH_NAME_1);
Assert.assertEquals(ForkOperatorUtils.getPathForBranch(state, PATH_FOO, 2, 0), PATH_FOO + "/" + FORK_BRANCH_NAME_0);
Assert.assertEquals(ForkOperatorUtils.getPathForBranch(state, PATH_FOO, 2, 1), PATH_FOO + "/" + FORK_BRANCH_NAME_1);
}
use of org.apache.gobblin.configuration.State in project incubator-gobblin by apache.
the class HadoopUtilsTest method testEncryptedStateToConfiguration.
@Test
public void testEncryptedStateToConfiguration() throws IOException {
Map<String, String> vals = Maps.newHashMap();
vals.put("test_key1", "test_val1");
vals.put("test_key2", "test_val2");
State state = new State();
for (Map.Entry<String, String> entry : vals.entrySet()) {
state.setProp(entry.getKey(), entry.getValue());
}
Map<String, String> encryptedVals = Maps.newHashMap();
encryptedVals.put("key1", "val1");
encryptedVals.put("key2", "val2");
final String encryptedPath = "encrypted.name.space";
for (Map.Entry<String, String> entry : encryptedVals.entrySet()) {
state.setProp(encryptedPath + "." + entry.getKey(), entry.getValue());
}
Configuration configuration = HadoopUtils.getConfFromState(state, Optional.of(encryptedPath));
for (Map.Entry<String, String> entry : vals.entrySet()) {
String val = configuration.get(entry.getKey());
Assert.assertEquals(val, entry.getValue());
}
for (Map.Entry<String, String> entry : encryptedVals.entrySet()) {
// Verify key with child path exist as decryption is unit tested in ConfigUtil.
Assert.assertNotNull(configuration.get(entry.getKey()));
}
}
use of org.apache.gobblin.configuration.State in project incubator-gobblin by apache.
the class HadoopUtilsTest method fsShortSerializationTest.
@Test
public void fsShortSerializationTest() {
State state = new State();
short mode = 420;
FsPermission perms = new FsPermission(mode);
HadoopUtils.serializeWriterFilePermissions(state, 0, 0, perms);
FsPermission deserializedPerms = HadoopUtils.deserializeWriterFilePermissions(state, 0, 0);
Assert.assertEquals(mode, deserializedPerms.toShort());
}
Aggregations