Exemple #1
0
 def setUp(self):
     self.domain = Domain("test-domain")
     self.activity_type = ActivityType(
         self.domain,
         "test-name",
         "test-version"
     )
Exemple #2
0
    def __init__(self,
                 domain,
                 workflow_id,
                 run_id=None,
                 status=STATUS_OPEN,
                 workflow_type=None,
                 task_list=None,
                 child_policy=None,
                 close_status=None,
                 execution_timeout=None,
                 input=None,
                 tag_list=None,
                 decision_tasks_timeout=None,
                 close_timestamp=None,
                 start_timestamp=None,
                 cancel_requested=None,
                 latest_execution_context=None,
                 latest_activity_task_timestamp=None,
                 open_counts=None,
                 parent=None,
                 *args,
                 **kwargs):
        Domain.check(domain)
        self.domain = domain
        self.workflow_id = workflow_id
        self.run_id = run_id
        self.status = status
        self.workflow_type = workflow_type
        self.task_list = task_list
        self.child_policy = child_policy
        self.close_status = close_status
        self.execution_timeout = execution_timeout
        self.input = input
        self.tag_list = tag_list or []
        self.decision_tasks_timeout = decision_tasks_timeout
        self.close_timestamp = close_timestamp
        self.start_timestamp = start_timestamp
        self.cancel_requested = cancel_requested
        self.latest_execution_context = latest_execution_context
        self.latest_activity_task_timestamp = latest_activity_task_timestamp
        self.open_counts = open_counts or {
        }  # so we can query keys in any case
        self.parent = parent or {}  # so we can query keys in any case

        # immutable decorator rebinds class name,
        # so have to use generice self.__class__
        super(self.__class__, self).__init__(*args, **kwargs)
Exemple #3
0
    def __init__(self, domain, workflow_id, run_id=None,
                 status=STATUS_OPEN, workflow_type=None,
                 task_list=None, child_policy=None,
                 close_status=None, execution_timeout=None,
                 input=None, tag_list=None,
                 decision_tasks_timeout=None,
                 close_timestamp=None,
                 start_timestamp=None,
                 cancel_requested=None,
                 latest_execution_context=None,
                 latest_activity_task_timestamp=None,
                 open_counts=None,
                 parent=None,
                 *args, **kwargs):
        Domain.check(domain)
        self.domain = domain
        self.workflow_id = workflow_id
        self.run_id = run_id
        self.status = status
        self.workflow_type = workflow_type
        self.task_list = task_list
        self.child_policy = child_policy
        self.close_status = close_status
        self.execution_timeout = execution_timeout
        self.input = input
        self.tag_list = tag_list or []
        self.decision_tasks_timeout = decision_tasks_timeout
        self.close_timestamp = close_timestamp
        self.start_timestamp = start_timestamp
        self.cancel_requested = cancel_requested
        self.latest_execution_context = latest_execution_context
        self.latest_activity_task_timestamp = latest_activity_task_timestamp
        self.open_counts = open_counts or {}  # so we can query keys in any case
        self.parent = parent or {}  # so we can query keys in any case

        # immutable decorator rebinds class name,
        # so have to use generice self.__class__
        super(self.__class__, self).__init__(*args, **kwargs)
    def test_dispatch_is_catched_correctly(self):
        domain = Domain("test-domain")
        poller = ActivityPoller(domain, "task-list")

        # this activity does not exist, so it will provoke an
        # ImportError when dispatching
        activity_type = FakeActivityType("activity.does.not.exist")
        task = ActivityTask(domain, "task-list", activity_type=activity_type)

        worker = ActivityWorker()

        with patch.object(poller, "fail_with_retry") as mock:
            worker.process(poller, "token", task)

        self.assertEquals(1, mock.call_count)
        self.assertEquals(mock.call_args[0], ("token", task))
        self.assertIn("No module named ", mock.call_args[1]["reason"])
Exemple #5
0
    def test_sigterm_handling(self):
        """
        Tests that SIGTERM is correctly ignored by the poller.
        """
        poller = FakePoller(Domain("test-domain"), "test-task-list")
        # restore default signal handling for SIGTERM: signal binding HAS to be
        # done at execution time, not in the Poller() initialization, because in
        # the real world that step is performed at the Supervisor() level, not in
        # the worker subprocess.
        signal.signal(signal.SIGTERM, signal.SIG_DFL)

        process = multiprocessing.Process(target=poller.start)
        process.start()
        time.sleep(0.5)

        os.kill(process.pid, signal.SIGTERM)
        time.sleep(0.5)

        # now test that we're still in the second sleep, and that we're not
        # in "zombie" mode yet (which would be the case if SIGTERM had its
        # default effect)
        expect(Process(process.pid).status()).to.contain("sleeping")
Exemple #6
0
 def __init__(self, domain, *args, **kwargs):
     super(BaseWorkflowQuerySet, self).__init__(*args, **kwargs)
     Domain.check(domain)
     self.domain = domain
Exemple #7
0
 def setUp(self):
     self.domain = Domain("TestDomain")
     self.actor = Actor(self.domain, "test-task-list")
Exemple #8
0
 def __init__(self, domain, *args, **kwargs):
     super(BaseWorkflowQuerySet, self).__init__(*args, **kwargs)
     Domain.check(domain)
     self.domain = domain
Exemple #9
0
 def build_history(self, workflow_input):
     domain = Domain("TestDomain")
     self.executor = Executor(domain, self.WORKFLOW)
     self.history = builder.History(self.WORKFLOW, input=workflow_input)