Search in sources :

Example 11 with FlowConfig

use of org.apache.gobblin.service.FlowConfig in project incubator-gobblin by apache.

the class GobblinServiceManagerTest method testBadUpdate.

@Test
public void testBadUpdate() throws Exception {
    Map<String, String> flowProperties = Maps.newHashMap();
    flowProperties.put("param1", "value1b");
    flowProperties.put("param2", "value2b");
    FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_DUMMY_GROUP_NAME).setFlowName(TEST_DUMMY_FLOW_NAME)).setTemplateUris(TEST_TEMPLATE_URI).setSchedule(new Schedule().setCronSchedule(TEST_SCHEDULE)).setProperties(new StringMap(flowProperties));
    try {
        this.flowConfigClient.updateFlowConfig(flowConfig);
    } catch (RestLiResponseException e) {
        Assert.fail("Bad update should pass without complaining that the spec does not exists.");
    }
    cleanUpDir(FLOW_SPEC_STORE_DIR);
}
Also used : FlowConfig(org.apache.gobblin.service.FlowConfig) FlowId(org.apache.gobblin.service.FlowId) StringMap(com.linkedin.data.template.StringMap) Schedule(org.apache.gobblin.service.Schedule) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) Test(org.testng.annotations.Test)

Example 12 with FlowConfig

use of org.apache.gobblin.service.FlowConfig in project incubator-gobblin by apache.

the class GobblinServiceManagerTest method testGet.

@Test(dependsOnMethods = "testCreateAgain")
public void testGet() throws Exception {
    FlowId flowId = new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME);
    FlowConfig flowConfig = this.flowConfigClient.getFlowConfig(flowId);
    Assert.assertEquals(flowConfig.getId().getFlowGroup(), TEST_GROUP_NAME);
    Assert.assertEquals(flowConfig.getId().getFlowName(), TEST_FLOW_NAME);
    Assert.assertEquals(flowConfig.getSchedule().getCronSchedule(), TEST_SCHEDULE);
    Assert.assertEquals(flowConfig.getTemplateUris(), TEST_TEMPLATE_URI);
    Assert.assertFalse(flowConfig.getSchedule().isRunImmediately());
    // Add this assert back when getFlowSpec() is changed to return the raw flow spec
    // Assert.assertEquals(flowConfig.getProperties().size(), 1);
    Assert.assertEquals(flowConfig.getProperties().get("param1"), "value1");
}
Also used : FlowId(org.apache.gobblin.service.FlowId) FlowConfig(org.apache.gobblin.service.FlowConfig) Test(org.testng.annotations.Test)

Example 13 with FlowConfig

use of org.apache.gobblin.service.FlowConfig in project incubator-gobblin by apache.

the class GobblinServiceManagerTest method testUpdate.

@Test(dependsOnMethods = "testGet")
public void testUpdate() throws Exception {
    FlowId flowId = new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME);
    Map<String, String> flowProperties = Maps.newHashMap();
    flowProperties.put("param1", "value1b");
    flowProperties.put("param2", "value2b");
    flowProperties.put(ServiceConfigKeys.FLOW_SOURCE_IDENTIFIER_KEY, TEST_SOURCE_NAME);
    flowProperties.put(ServiceConfigKeys.FLOW_DESTINATION_IDENTIFIER_KEY, TEST_SINK_NAME);
    FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME)).setTemplateUris(TEST_TEMPLATE_URI).setSchedule(new Schedule().setCronSchedule(TEST_SCHEDULE)).setProperties(new StringMap(flowProperties));
    this.flowConfigClient.updateFlowConfig(flowConfig);
    FlowConfig retrievedFlowConfig = this.flowConfigClient.getFlowConfig(flowId);
    Assert.assertEquals(retrievedFlowConfig.getId().getFlowGroup(), TEST_GROUP_NAME);
    Assert.assertEquals(retrievedFlowConfig.getId().getFlowName(), TEST_FLOW_NAME);
    Assert.assertEquals(retrievedFlowConfig.getSchedule().getCronSchedule(), TEST_SCHEDULE);
    Assert.assertEquals(retrievedFlowConfig.getTemplateUris(), TEST_TEMPLATE_URI);
    // Add this asssert when getFlowSpec() is changed to return the raw flow spec
    // Assert.assertEquals(flowConfig.getProperties().size(), 2);
    Assert.assertEquals(retrievedFlowConfig.getProperties().get("param1"), "value1b");
    Assert.assertEquals(retrievedFlowConfig.getProperties().get("param2"), "value2b");
}
Also used : FlowId(org.apache.gobblin.service.FlowId) FlowConfig(org.apache.gobblin.service.FlowConfig) StringMap(com.linkedin.data.template.StringMap) Schedule(org.apache.gobblin.service.Schedule) Test(org.testng.annotations.Test)

Example 14 with FlowConfig

use of org.apache.gobblin.service.FlowConfig in project incubator-gobblin by apache.

the class GobblinServiceManagerTest method testCreate.

@Test
public void testCreate() throws Exception {
    Map<String, String> flowProperties = Maps.newHashMap();
    flowProperties.put("param1", "value1");
    flowProperties.put(ServiceConfigKeys.FLOW_SOURCE_IDENTIFIER_KEY, TEST_SOURCE_NAME);
    flowProperties.put(ServiceConfigKeys.FLOW_DESTINATION_IDENTIFIER_KEY, TEST_SINK_NAME);
    FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME)).setTemplateUris(TEST_TEMPLATE_URI).setSchedule(new Schedule().setCronSchedule(TEST_SCHEDULE).setRunImmediately(true)).setProperties(new StringMap(flowProperties));
    this.flowConfigClient.createFlowConfig(flowConfig);
    Assert.assertTrue(this.gobblinServiceManager.flowCatalog.getSpecs().size() == 1, "Flow that was created is not " + "reflecting in FlowCatalog");
}
Also used : FlowConfig(org.apache.gobblin.service.FlowConfig) FlowId(org.apache.gobblin.service.FlowId) StringMap(com.linkedin.data.template.StringMap) Schedule(org.apache.gobblin.service.Schedule) Test(org.testng.annotations.Test)

Example 15 with FlowConfig

use of org.apache.gobblin.service.FlowConfig in project incubator-gobblin by apache.

the class FlowConfigUtilsTest method testFlowConfigWithoutTemplateUri.

public void testFlowConfigWithoutTemplateUri() {
    FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowName("SN_CRMSYNC").setFlowGroup("DYNAMICS-USER-123456789"));
    flowConfig.setSchedule(new Schedule().setCronSchedule("0 58 2/12 ? * * *"));
    Properties properties = new Properties();
    properties.put("gobblin.flow.sourceIdentifier", "dynamicsCrm");
    properties.put("gobblin.flow.destinationIdentifier", "espresso");
    flowConfig.setProperties(new StringMap(Maps.fromProperties(properties)));
    try {
        FlowConfigResourceLocalHandler.createFlowSpecForConfig(flowConfig);
        Assert.fail("Should not get to here");
    } catch (RequiredFieldNotPresentException e) {
        Assert.assertTrue(true, "templateUri cannot be empty");
    }
    testSerDer(flowConfig);
}
Also used : FlowConfig(org.apache.gobblin.service.FlowConfig) FlowId(org.apache.gobblin.service.FlowId) RequiredFieldNotPresentException(com.linkedin.data.template.RequiredFieldNotPresentException) StringMap(com.linkedin.data.template.StringMap) Schedule(org.apache.gobblin.service.Schedule) Properties(java.util.Properties)

Aggregations

FlowConfig (org.apache.gobblin.service.FlowConfig)20 FlowId (org.apache.gobblin.service.FlowId)19 StringMap (com.linkedin.data.template.StringMap)15 Schedule (org.apache.gobblin.service.Schedule)14 Test (org.testng.annotations.Test)13 RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)7 Properties (java.util.Properties)5 FlowConfigClient (org.apache.gobblin.service.FlowConfigClient)2 RequiredFieldNotPresentException (com.linkedin.data.template.RequiredFieldNotPresentException)1 RemoteInvocationException (com.linkedin.r2.RemoteInvocationException)1 IOException (java.io.IOException)1