Search in sources :

Example 26 with StringMap

use of com.linkedin.data.template.StringMap in project incubator-gobblin by apache.

the class GobblinServiceHATest method testUpdate.

@Test(dependsOnMethods = "testGet")
public void testUpdate() throws Exception {
    // Update on one node and retrieve from another
    FlowId flowId = new FlowId().setFlowGroup(TEST_GROUP_NAME_1).setFlowName(TEST_FLOW_NAME_1);
    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_1).setFlowName(TEST_FLOW_NAME_1)).setTemplateUris(TEST_TEMPLATE_URI_1).setSchedule(new Schedule().setCronSchedule(TEST_SCHEDULE_1)).setProperties(new StringMap(flowProperties));
    this.node1FlowConfigClient.updateFlowConfig(flowConfig);
    FlowConfig retrievedFlowConfig = this.node2FlowConfigClient.getFlowConfig(flowId);
    Assert.assertEquals(retrievedFlowConfig.getId().getFlowGroup(), TEST_GROUP_NAME_1);
    Assert.assertEquals(retrievedFlowConfig.getId().getFlowName(), TEST_FLOW_NAME_1);
    Assert.assertEquals(retrievedFlowConfig.getSchedule().getCronSchedule(), TEST_SCHEDULE_1);
    Assert.assertEquals(retrievedFlowConfig.getTemplateUris(), TEST_TEMPLATE_URI_1);
    Assert.assertFalse(retrievedFlowConfig.getSchedule().isRunImmediately());
    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 27 with StringMap

use of com.linkedin.data.template.StringMap 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 28 with StringMap

use of com.linkedin.data.template.StringMap 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 29 with StringMap

use of com.linkedin.data.template.StringMap 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 30 with StringMap

use of com.linkedin.data.template.StringMap in project incubator-gobblin by apache.

the class FlowConfigTest method testCreateBadSchedule.

@Test
public void testCreateBadSchedule() throws Exception {
    Map<String, String> flowProperties = Maps.newHashMap();
    flowProperties.put("param1", "value1");
    FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME)).setTemplateUris(TEST_TEMPLATE_URI).setSchedule(new Schedule().setCronSchedule("bad schedule").setRunImmediately(true)).setProperties(new StringMap(flowProperties));
    try {
        _client.createFlowConfig(flowConfig);
    } catch (RestLiResponseException e) {
        Assert.assertEquals(e.getStatus(), HttpStatus.S_422_UNPROCESSABLE_ENTITY.getCode());
        return;
    }
    Assert.fail("Get should have gotten a 422 error");
}
Also used : StringMap(com.linkedin.data.template.StringMap) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) Test(org.testng.annotations.Test)

Aggregations

StringMap (com.linkedin.data.template.StringMap)47 Test (org.testng.annotations.Test)26 RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)9 FlowConfig (org.apache.gobblin.service.FlowConfig)9 FlowId (org.apache.gobblin.service.FlowId)9 Schedule (org.apache.gobblin.service.Schedule)9 Map (java.util.Map)8 IndividualRequest (com.linkedin.restli.common.multiplexer.IndividualRequest)6 IndividualRequestMap (com.linkedin.restli.common.multiplexer.IndividualRequestMap)5 TaskExecutionInfo (org.apache.gobblin.rest.TaskExecutionInfo)5 ByteString (com.linkedin.data.ByteString)4 DataMap (com.linkedin.data.DataMap)4 Meter (com.codahale.metrics.Meter)3 RestRequest (com.linkedin.r2.message.rest.RestRequest)3 RoutingResult (com.linkedin.restli.internal.server.RoutingResult)3 PreparedStatement (java.sql.PreparedStatement)3 AbstractMap (java.util.AbstractMap)3 JobExecutionInfo (org.apache.gobblin.rest.JobExecutionInfo)3 Metric (org.apache.gobblin.rest.Metric)3 MetricArray (org.apache.gobblin.rest.MetricArray)3