use of org.apache.gobblin.runtime.api.SpecExecutor in project incubator-gobblin by apache.
the class IdentityFlowToJobSpecCompilerTest method testCompilerWithTemplateCatalog.
@Test
public void testCompilerWithTemplateCatalog() {
FlowSpec flowSpec = initFlowSpec();
// Run compiler on flowSpec
Map<Spec, SpecExecutor> specExecutorMapping = this.compilerWithTemplateCalague.compileFlow(flowSpec);
// Assert pre-requisites
Assert.assertNotNull(specExecutorMapping, "Expected non null mapping.");
Assert.assertTrue(specExecutorMapping.size() == 1, "Exepected 1 executor for FlowSpec.");
// Assert FlowSpec compilation
Spec spec = specExecutorMapping.keySet().iterator().next();
Assert.assertTrue(spec instanceof JobSpec, "Expected JobSpec compiled from FlowSpec.");
// Assert JobSpec properties
JobSpec jobSpec = (JobSpec) spec;
Assert.assertEquals(jobSpec.getConfig().getString("testProperty1"), "testValue1");
Assert.assertEquals(jobSpec.getConfig().getString("testProperty2"), "test.Value1");
Assert.assertEquals(jobSpec.getConfig().getString("testProperty3"), "100");
Assert.assertEquals(jobSpec.getConfig().getString(ServiceConfigKeys.FLOW_SOURCE_IDENTIFIER_KEY), TEST_SOURCE_NAME);
Assert.assertFalse(jobSpec.getConfig().hasPath(ConfigurationKeys.JOB_SCHEDULE_KEY));
Assert.assertEquals(jobSpec.getConfig().getString(ConfigurationKeys.JOB_NAME_KEY), TEST_FLOW_NAME);
Assert.assertEquals(jobSpec.getConfig().getString(ConfigurationKeys.JOB_GROUP_KEY), TEST_FLOW_GROUP);
Assert.assertEquals(jobSpec.getConfig().getString(ConfigurationKeys.FLOW_NAME_KEY), TEST_FLOW_NAME);
Assert.assertEquals(jobSpec.getConfig().getString(ConfigurationKeys.FLOW_GROUP_KEY), TEST_FLOW_GROUP);
Assert.assertTrue(jobSpec.getConfig().hasPath(ConfigurationKeys.FLOW_EXECUTION_ID_KEY));
}
use of org.apache.gobblin.runtime.api.SpecExecutor in project incubator-gobblin by apache.
the class IdentityFlowToJobSpecCompilerTest method initTopologySpec.
private TopologySpec initTopologySpec() {
Properties properties = new Properties();
properties.put("specStore.fs.dir", TOPOLOGY_SPEC_STORE_DIR);
properties.put("specExecInstance.capabilities", TEST_SOURCE_NAME + ":" + TEST_SINK_NAME);
Config config = ConfigUtils.propertiesToConfig(properties);
SpecExecutor specExecutorInstance = new InMemorySpecExecutor(config);
TopologySpec.Builder topologySpecBuilder = TopologySpec.builder(computeTopologySpecURI(SPEC_STORE_PARENT_DIR, TOPOLOGY_SPEC_STORE_DIR)).withConfig(config).withDescription(SPEC_DESCRIPTION).withVersion(SPEC_VERSION).withSpecExecutor(specExecutorInstance);
return topologySpecBuilder.build();
}
use of org.apache.gobblin.runtime.api.SpecExecutor in project incubator-gobblin by apache.
the class MultiHopsFlowToJobSpecCompilerTest method initTopologySpec.
// The topology is: Src - A - B - Dest
private TopologySpec initTopologySpec(String storeDir, String... args) {
Properties properties = new Properties();
properties.put("specStore.fs.dir", storeDir);
String capabilitiesString = "";
for (int i = 0; i < args.length - 1; i++) {
capabilitiesString = capabilitiesString + (args[i] + ":" + args[i + 1] + ",");
}
Assert.assertEquals(capabilitiesString.charAt(capabilitiesString.length() - 1), ',');
capabilitiesString = capabilitiesString.substring(0, capabilitiesString.length() - 1);
properties.put("specExecInstance.capabilities", capabilitiesString);
properties.put("executorAttrs", new Properties());
Config config = ConfigUtils.propertiesToConfig(properties);
SpecExecutor specExecutorInstance = new InMemorySpecExecutor(config);
TopologySpec.Builder topologySpecBuilder = TopologySpec.builder(IdentityFlowToJobSpecCompilerTest.computeTopologySpecURI(SPEC_STORE_PARENT_DIR, storeDir)).withConfig(config).withDescription(SPEC_DESCRIPTION).withVersion(SPEC_VERSION).withSpecExecutor(specExecutorInstance);
return topologySpecBuilder.build();
}
use of org.apache.gobblin.runtime.api.SpecExecutor in project incubator-gobblin by apache.
the class OrchestratorTest method deleteFlowSpec.
@Test(dependsOnMethods = "createFlowSpec")
public void deleteFlowSpec() throws Exception {
// Since only 1 Flow has been added in previous test it should be available
IdentityFlowToJobSpecCompiler specCompiler = (IdentityFlowToJobSpecCompiler) this.orchestrator.getSpecCompiler();
SpecExecutor sei = specCompiler.getTopologySpecMap().values().iterator().next().getSpecExecutor();
// List Current Specs
Collection<Spec> specs = flowCatalog.getSpecs();
logger.info("[Before Delete] Number of specs: " + specs.size());
int i = 0;
for (Spec spec : specs) {
FlowSpec flowSpec = (FlowSpec) spec;
logger.info("[Before Delete] Spec " + i++ + ": " + gson.toJson(flowSpec));
}
// Make sure FlowCatalog has the previously added Flow
Assert.assertTrue(specs.size() == 1, "Spec store should contain 1 Flow that was added in last test");
// Orchestrator is a no-op listener for any new FlowSpecs, so no FlowSpecs should be around
int specsInSEI = ((List) (sei.getProducer().get().listSpecs().get())).size();
Assert.assertTrue(specsInSEI == 0, "SpecProducer should contain 0 " + "Spec after addition because Orchestrator is a no-op listener for any new FlowSpecs");
// Remove the flow
this.flowCatalog.remove(flowSpec.getUri());
// List Specs after adding
specs = flowCatalog.getSpecs();
logger.info("[After Delete] Number of specs: " + specs.size());
i = 0;
for (Spec spec : specs) {
flowSpec = (FlowSpec) spec;
logger.info("[After Delete] Spec " + i++ + ": " + gson.toJson(flowSpec));
}
// Make sure FlowCatalog has the Flow removed
Assert.assertTrue(specs.size() == 0, "Spec store should not contain Spec after deletion");
// Make sure FlowCatalog Listener knows about the deletion
specsInSEI = ((List) (sei.getProducer().get().listSpecs().get())).size();
Assert.assertTrue(specsInSEI == 0, "SpecProducer should not contain " + "Spec after deletion");
}
use of org.apache.gobblin.runtime.api.SpecExecutor in project incubator-gobblin by apache.
the class OrchestratorTest method initTopologySpec.
private TopologySpec initTopologySpec() {
Properties properties = new Properties();
properties.put("specStore.fs.dir", TOPOLOGY_SPEC_STORE_DIR);
properties.put("specExecInstance.capabilities", "source:destination");
Config config = ConfigUtils.propertiesToConfig(properties);
SpecExecutor specExecutorInstance = new InMemorySpecExecutor(config);
TopologySpec.Builder topologySpecBuilder = TopologySpec.builder(computeTopologySpecURI(SPEC_STORE_PARENT_DIR, TOPOLOGY_SPEC_STORE_DIR)).withConfig(config).withDescription(SPEC_DESCRIPTION).withVersion(SPEC_VERSION).withSpecExecutor(specExecutorInstance);
return topologySpecBuilder.build();
}
Aggregations