Search in sources :

Example 1 with MockPlugin

use of org.apache.inlong.manager.service.mocks.MockPlugin in project incubator-inlong by apache.

the class InlongGroupProcessOperationTest method before.

public void before(int status) {
    MockPlugin mockPlugin = new MockPlugin();
    serviceTaskListenerFactory.acceptPlugin(mockPlugin);
    InlongGroupRequest groupInfo = new InlongGroupRequest();
    groupInfo.setInlongGroupId(GROUP_ID);
    groupInfo.setName(GROUP_NAME);
    groupInfo.setInCharges(OPERATOR);
    groupInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
    InlongGroupPulsarInfo pulsarInfo = new InlongGroupPulsarInfo();
    pulsarInfo.setInlongGroupId(GROUP_ID);
    groupInfo.setMqExtInfo(pulsarInfo);
    groupService.save(groupInfo, OPERATOR);
    groupService.update(groupInfo, OPERATOR);
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) InlongGroupRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupRequest)

Example 2 with MockPlugin

use of org.apache.inlong.manager.service.mocks.MockPlugin in project incubator-inlong by apache.

the class DisableZkForSortTest method testCreateSortConfigInUpdateWorkflow.

@Test
public void testCreateSortConfigInUpdateWorkflow() {
    InlongGroupInfo groupInfo = initGroupForm("PULSAR");
    groupInfo.setZookeeperEnabled(0);
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    InlongStreamInfo streamInfo = createStreamInfo(groupInfo);
    createHiveSink(streamInfo);
    createKafkaSource(streamInfo);
    UpdateGroupProcessForm form = new UpdateGroupProcessForm();
    form.setGroupInfo(groupInfo);
    form.setOperateType(OperateType.SUSPEND);
    taskListenerFactory.acceptPlugin(new MockPlugin());
    WorkflowContext context = workflowEngine.processService().start(ProcessName.SUSPEND_GROUP_PROCESS.name(), applicant, form);
    WorkflowResult result = WorkflowBeanUtils.result(context);
    ProcessResponse response = result.getProcessInfo();
    Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
    WorkflowProcess process = context.getProcess();
    WorkflowTask task = process.getTaskByName("stopSort");
    Assert.assertTrue(task instanceof ServiceTask);
    Assert.assertEquals(2, task.getNameToListenerMap().size());
    List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
    Assert.assertTrue(listeners.get(1) instanceof CreateSortConfigListener);
    ProcessForm currentProcessForm = context.getProcessForm();
    InlongGroupInfo curGroupRequest = ((UpdateGroupProcessForm) currentProcessForm).getGroupInfo();
    Assert.assertTrue(curGroupRequest.getExtList().size() == 1);
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo) WorkflowServiceImplTest(org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest) Test(org.junit.Test)

Example 3 with MockPlugin

use of org.apache.inlong.manager.service.mocks.MockPlugin in project incubator-inlong by apache.

the class WorkflowServiceImplTest method testRestartProcess.

@Test
public void testRestartProcess() {
    InlongGroupInfo groupInfo = initGroupForm(Constant.MIDDLEWARE_PULSAR);
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.SUSPENDED.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    UpdateGroupProcessForm form = new UpdateGroupProcessForm();
    form.setGroupInfo(groupInfo);
    form.setOperateType(OperateType.RESTART);
    taskListenerFactory.acceptPlugin(new MockPlugin());
    WorkflowContext context = workflowEngine.processService().start(ProcessName.RESTART_GROUP_PROCESS.name(), applicant, form);
    WorkflowResult result = WorkflowBeanUtils.result(context);
    ProcessResponse response = result.getProcessInfo();
    Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
    WorkflowProcess process = context.getProcess();
    WorkflowTask restartSort = process.getTaskByName("restartSort");
    Assert.assertTrue(restartSort instanceof ServiceTask);
    List<TaskEventListener> listeners = Lists.newArrayList(restartSort.getNameToListenerMap().values());
    Assert.assertEquals(1, listeners.size());
    Assert.assertTrue(listeners.get(0) instanceof MockRestartSortListener);
    WorkflowTask restartSourceTask = process.getTaskByName("restartSource");
    Assert.assertTrue(restartSourceTask instanceof ServiceTask);
    listeners = Lists.newArrayList(restartSourceTask.getNameToListenerMap().values());
    Assert.assertEquals(2, listeners.size());
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) MockRestartSortListener(org.apache.inlong.manager.service.mocks.MockRestartSortListener) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 4 with MockPlugin

use of org.apache.inlong.manager.service.mocks.MockPlugin in project incubator-inlong by apache.

the class WorkflowServiceImplTest method testSuspendProcess.

@Test
public void testSuspendProcess() {
    InlongGroupInfo groupInfo = initGroupForm(Constant.MIDDLEWARE_PULSAR);
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    UpdateGroupProcessForm form = new UpdateGroupProcessForm();
    form.setGroupInfo(groupInfo);
    form.setOperateType(OperateType.SUSPEND);
    taskListenerFactory.acceptPlugin(new MockPlugin());
    WorkflowContext context = workflowEngine.processService().start(ProcessName.SUSPEND_GROUP_PROCESS.name(), applicant, form);
    WorkflowResult result = WorkflowBeanUtils.result(context);
    ProcessResponse response = result.getProcessInfo();
    Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
    WorkflowProcess process = context.getProcess();
    WorkflowTask stopSortTask = process.getTaskByName("stopSort");
    Assert.assertTrue(stopSortTask instanceof ServiceTask);
    List<TaskEventListener> listeners = Lists.newArrayList(stopSortTask.getNameToListenerMap().values());
    Assert.assertTrue(listeners.get(0) instanceof MockStopSortListener);
    WorkflowTask stopSourceTask = process.getTaskByName("stopSource");
    Assert.assertTrue(stopSourceTask instanceof ServiceTask);
    listeners = Lists.newArrayList(stopSourceTask.getNameToListenerMap().values());
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) MockStopSortListener(org.apache.inlong.manager.service.mocks.MockStopSortListener) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 5 with MockPlugin

use of org.apache.inlong.manager.service.mocks.MockPlugin in project incubator-inlong by apache.

the class WorkflowServiceImplTest method testStopProcess.

@Test
public void testStopProcess() {
    InlongGroupInfo groupInfo = initGroupForm(Constant.MIDDLEWARE_PULSAR);
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.SUSPENDED.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    UpdateGroupProcessForm form = new UpdateGroupProcessForm();
    form.setGroupInfo(groupInfo);
    form.setOperateType(OperateType.DELETE);
    taskListenerFactory.acceptPlugin(new MockPlugin());
    WorkflowContext context = workflowEngine.processService().start(ProcessName.DELETE_GROUP_PROCESS.name(), applicant, form);
    WorkflowResult result = WorkflowBeanUtils.result(context);
    ProcessResponse view = result.getProcessInfo();
    Assert.assertSame(view.getStatus(), ProcessStatus.COMPLETED);
    WorkflowProcess process = context.getProcess();
    WorkflowTask deleteSort = process.getTaskByName("deleteSort");
    Assert.assertTrue(deleteSort instanceof ServiceTask);
    List<TaskEventListener> listeners = Lists.newArrayList(deleteSort.getNameToListenerMap().values());
    Assert.assertEquals(1, listeners.size());
    Assert.assertTrue(listeners.get(0) instanceof MockDeleteSortListener);
    WorkflowTask deleteSourceTask = process.getTaskByName("deleteSource");
    Assert.assertTrue(deleteSourceTask instanceof ServiceTask);
    listeners = Lists.newArrayList(deleteSourceTask.getNameToListenerMap().values());
    Assert.assertEquals(2, listeners.size());
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) MockDeleteSortListener(org.apache.inlong.manager.service.mocks.MockDeleteSortListener) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Aggregations

MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)5 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)4 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)4 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)4 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)4 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)4 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)4 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)4 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)4 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)4 Test (org.junit.Test)4 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)3 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)1 InlongGroupRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupRequest)1 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)1 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)1 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)1 MockDeleteSortListener (org.apache.inlong.manager.service.mocks.MockDeleteSortListener)1 MockRestartSortListener (org.apache.inlong.manager.service.mocks.MockRestartSortListener)1 MockStopSortListener (org.apache.inlong.manager.service.mocks.MockStopSortListener)1