예제 #1
0
    def test_retry_node__with_node_can_not_retry(self):
        # with service activity
        top_pipeline = PipelineObject(
            nodes={
                self.node_id:
                ServiceActivity(id=self.node_id, service=None, can_retry=False)
            })
        process = MockPipelineProcess(top_pipeline=top_pipeline)

        with patch(PIPELINE_PROCESS_GET, MagicMock(return_value=process)):
            act_result = api.retry_node(self.node_id)

            self.assertFalse(act_result.result)
            self.assertEqual(
                act_result.message,
                'the node is set to not be retried, try skip it please.')

        # with parallel gateway
        pg = ParallelGateway(id=self.node_id, converge_gateway_id=uniqid())
        setattr(pg, 'can_retry', False)
        top_pipeline = PipelineObject(nodes={self.node_id: pg})
        process = MockPipelineProcess(top_pipeline=top_pipeline)

        with patch(PIPELINE_PROCESS_GET, MagicMock(return_value=process)):
            act_result = api.retry_node(self.node_id)

            self.assertFalse(act_result.result)
            self.assertEqual(
                act_result.message,
                'the node is set to not be retried, try skip it please.')
예제 #2
0
    def test_retry_node__fail_with_can_not_get_process(self):
        act_result = api.retry_node(self.node_id)

        self.assertFalse(act_result.result)
        self.assertEqual(
            act_result.message,
            'can\'t not retry a subprocess or this process has been revoked')
예제 #3
0
파일: test_api.py 프로젝트: manlucas/atom
    def test_retry_node__fail_with_invalid_node_type(self):
        top_pipeline = PipelineObject(nodes={self.node_id: ServiceActObject()})
        process = MockPipelineProcess(top_pipeline=top_pipeline)

        with patch(PIPELINE_PROCESS_GET, MagicMock(return_value=process)):
            act_result = api.retry_node(self.node_id)

            self.assertFalse(act_result.result)
예제 #4
0
 def spec_nodes_timer_reset(self, node_id, username, inputs):
     if not self.has_node(node_id):
         return {'result': False, 'message': 'timer which be operated is not in this flow'}
     success = pipeline_api.forced_fail(node_id)
     if not success:
         return {'result': False, 'message': 'timer node not exits or is finished'}
     success = pipeline_api.retry_node(node_id, inputs)
     if not success:
         return {'result': False, 'message': 'reset timer failed, please try again later'}
     return {'result': True, 'data': 'success'}
예제 #5
0
파일: test_api.py 프로젝트: manlucas/atom
    def test_retry_node__with_retry_fail(self):
        node = ServiceActivity(id=self.node_id, service=None)
        top_pipeline = PipelineObject(nodes={self.node_id: node})
        process = MockPipelineProcess(top_pipeline=top_pipeline)

        with patch(PIPELINE_PROCESS_GET, MagicMock(return_value=process)):
            act_result = api.retry_node(self.node_id)

            Status.objects.retry.assert_called_once_with(process, node, None)

            self.assertFalse(act_result.result)
예제 #6
0
파일: test_api.py 프로젝트: manlucas/atom
    def test_retry_node__with_node_can_not_retry(self):
        # with service activity
        top_pipeline = PipelineObject(
            nodes={
                self.node_id:
                ServiceActivity(id=self.node_id, service=None, retryable=False)
            })
        process = MockPipelineProcess(top_pipeline=top_pipeline)

        with patch(PIPELINE_PROCESS_GET, MagicMock(return_value=process)):
            act_result = api.retry_node(self.node_id)

            self.assertFalse(act_result.result)

        # with parallel gateway
        pg = ParallelGateway(id=self.node_id, converge_gateway_id=uniqid())
        setattr(pg, 'retryable', False)
        top_pipeline = PipelineObject(nodes={self.node_id: pg})
        process = MockPipelineProcess(top_pipeline=top_pipeline)

        with patch(PIPELINE_PROCESS_GET, MagicMock(return_value=process)):
            act_result = api.retry_node(self.node_id)

            self.assertFalse(act_result.result)
예제 #7
0
 def spec_nodes_timer_reset(self, node_id, username, inputs):
     # TODO assert node_id is sub_node of pipeline
     success = pipeline_api.forced_fail(node_id)
     if not success:
         return {
             'result': False,
             'message': 'timer node not exits or is finished'
         }
     success = pipeline_api.retry_node(node_id, inputs)
     if not success:
         return {
             'result': False,
             'message': 'reset timer failed, please try again later'
         }
     return {'result': True, 'data': 'success'}
예제 #8
0
파일: test_api.py 프로젝트: manlucas/atom
    def test_retry_node__success(self):
        node = ServiceActivity(id=self.node_id, service=None)
        top_pipeline = PipelineObject(nodes={self.node_id: node})
        process = MockPipelineProcess(top_pipeline=top_pipeline)
        retry_inputs = {'id': self.node_id}

        with patch(PIPELINE_PROCESS_GET, MagicMock(return_value=process)):
            act_result = api.retry_node(self.node_id, inputs=retry_inputs)

            self.assertTrue(act_result.result)

            Status.objects.retry.assert_called_once_with(
                process, node, retry_inputs)

            PipelineProcess.objects.process_ready.assert_called_once_with(
                process_id=process.id)
예제 #9
0
 def spec_nodes_timer_reset(self, node_id, username, inputs):
     if not self.has_node(node_id):
         message = 'node[node_id={node_id}] not found in task[task_id={task_id}]'.format(
             node_id=node_id, task_id=self.id)
         return {'result': False, 'message': message}
     action_result = pipeline_api.forced_fail(node_id)
     if not action_result.result:
         return {
             'result': False,
             'message': 'timer node not exits or is finished'
         }
     action_result = pipeline_api.retry_node(node_id, inputs)
     if not action_result.result:
         return {
             'result': False,
             'message': 'reset timer failed, please try again later'
         }
     return {'result': True, 'data': 'success'}
예제 #10
0
def retry_activity(act_id, inputs=None):
    return api.retry_node(act_id, inputs=inputs)
예제 #11
0
파일: test_api.py 프로젝트: manlucas/atom
    def test_retry_node__fail_with_can_not_get_process(self):
        act_result = api.retry_node(self.node_id)

        self.assertFalse(act_result.result)