Beispiel #1
0
 def test_find_activity(self):
     func, args, kwargs, meta, params = find_activity(FakeHistory(), scheduled_id=5)
     expect(str(func)).to.match(r'^Activity\(name=tests.integration.workflow.sleep,')
     expect(args).to.equal([37])
     expect(kwargs).to.equal({})
     expect(meta).to.equal({})
     expect(params["id"]).to.equal("activity-tests.integration.workflow.sleep-1")
Beispiel #2
0
 def test_find_activity(self):
     func, args, kwargs, params = find_activity(FakeHistory(),
                                                scheduled_id=5)
     expect(func.__name__).to.equal("sleep")
     expect(args).to.equal([37])
     expect(kwargs).to.equal({})
     expect(params["id"]).to.equal(
         "activity-tests.integration.workflow.sleep-1")
 def test_find_activity(self):
     func, args, kwargs, meta, params = find_activity(FakeHistory(),
                                                      scheduled_id=5)
     expect(str(func)).to.match(
         r'^Activity\(name=tests.integration.workflow.sleep,')
     expect(args).to.equal([37])
     expect(kwargs).to.equal({})
     expect(meta).to.equal({})
     expect(params["id"]).to.equal(
         "activity-tests.integration.workflow.sleep-1")
Beispiel #4
0
def activity_rerun(domain, workflow_id, run_id, input, scheduled_id,
                   activity_id):
    # handle params
    if not activity_id and not scheduled_id:
        logger.error("Please supply --scheduled-id or --activity-id.")
        sys.exit(1)

    input_override = None
    if input:
        input_override = format.decode(input)

    # find workflow execution
    try:
        wfe = helpers.get_workflow_execution(domain, workflow_id, run_id)
    except (swf.exceptions.DoesNotExistError, IndexError):
        logger.error("Couldn't find execution, exiting.")
        sys.exit(1)
    logger.info("Found execution: workflowId={} runId={}".format(
        wfe.workflow_id, wfe.run_id))

    # now rerun the specified activity
    history = History(wfe.history())
    history.parse()
    task, args, kwargs, meta, params = helpers.find_activity(
        history,
        scheduled_id=scheduled_id,
        activity_id=activity_id,
        input=input_override,
    )
    kwargs["context"].update({
        "workflow_id": wfe.workflow_id,
        "run_id": wfe.run_id,
    })
    logger.debug("Found activity. Last execution:")
    for line in json_dumps(params, pretty=True).split("\n"):
        logger.debug(line)
    if input_override:
        logger.info("NB: input will be overriden with the passed one!")
    logger.info("Will re-run: {}(*{}, **{}) [+meta={}]".format(
        task, args, kwargs, meta))

    # download binaries if needed
    download_binaries(meta.get("binaries", {}))

    # execute the activity task with the correct arguments
    instance = ActivityTask(task, *args, **kwargs)
    result = instance.execute()
    if hasattr(instance, "post_execute"):
        instance.post_execute()
    logger.info("Result (JSON): {}".format(json_dumps(result, compact=False)))
Beispiel #5
0
def activity_rerun(domain,
                   workflow_id,
                   run_id,
                   input,
                   scheduled_id,
                   activity_id):
    # handle params
    if not activity_id and not scheduled_id:
        logger.error("Please supply --scheduled-id or --activity-id.")
        sys.exit(1)

    input_override = None
    if input:
        input_override = format.decode(input)

    # find workflow execution
    try:
        wfe = helpers.get_workflow_execution(domain, workflow_id, run_id)
    except (swf.exceptions.DoesNotExistError, IndexError):
        logger.error("Couldn't find execution, exiting.")
        sys.exit(1)
    logger.info("Found execution: workflowId={} runId={}".format(wfe.workflow_id, wfe.run_id))

    # now rerun the specified activity
    history = History(wfe.history())
    history.parse()
    task, args, kwargs, meta, params = helpers.find_activity(
        history, scheduled_id=scheduled_id, activity_id=activity_id, input=input_override,
    )
    logger.debug("Found activity. Last execution:")
    for line in json_dumps(params, pretty=True).split("\n"):
        logger.debug(line)
    if input_override:
        logger.info("NB: input will be overriden with the passed one!")
    logger.info("Will re-run: {}(*{}, **{}) [+meta={}]".format(task, args, kwargs, meta))

    # download binaries if needed
    download_binaries(meta.get("binaries", {}))

    # execute the activity task with the correct arguments
    instance = ActivityTask(task, *args, **kwargs)
    result = instance.execute()
    if hasattr(instance, 'post_execute'):
        instance.post_execute()
    logger.info("Result (JSON): {}".format(json_dumps(result, compact=False)))
Beispiel #6
0
 def test_find_activity(self):
     func, args, kwargs, meta, params = find_activity(FakeHistory(),
                                                      scheduled_id=5)
     expect(str(func)).to.match(
         r"^Activity\(name=tests.integration.workflow.sleep,")
     expect(args).to.equal([37])
     expect(kwargs).to.equal({
         "context": {
             "activity_id": "activity-tests.integration.workflow.sleep-1",
             "input": {
                 "args": [37]
             },
             "name": "tests.integration.workflow.sleep",
             "version": None,
         }
     })
     expect(meta).to.equal({})
     expect(params["id"]).to.equal(
         "activity-tests.integration.workflow.sleep-1")
Beispiel #7
0
def activity_rerun(domain, workflow_id, run_id, input, scheduled_id,
                   activity_id):
    # handle params
    if not activity_id and not scheduled_id:
        logger.error("Please supply --scheduled-id or --activity-id.")
        sys.exit(1)

    input_override = None
    if input:
        input_override = json.loads(input)

    # find workflow execution
    try:
        wfe = helpers.get_workflow_execution(domain, workflow_id, run_id)
    except (swf.exceptions.DoesNotExistError, IndexError):
        logger.error("Couldn't find execution, exiting.")
        sys.exit(1)
    logger.info("Found execution: workflowId={} runId={}".format(
        wfe.workflow_id, wfe.run_id))

    # now rerun the specified activity
    history = History(wfe.history())
    history.parse()
    func, args, kwargs, params = helpers.find_activity(
        history,
        scheduled_id=scheduled_id,
        activity_id=activity_id,
        input=input_override,
    )
    logger.debug("Found activity. Last execution:")
    for line in json_dumps(params, pretty=True).split("\n"):
        logger.debug(line)
    if input_override:
        logger.info("NB: input will be overriden with the passed one!")
    logger.info("Will re-run: {}(*{}, **{})".format(func.__name__, args,
                                                    kwargs))

    # finally replay the function with the correct arguments
    result = func(*args, **kwargs)
    logger.info("Result (JSON): {}".format(json_dumps(result)))
Beispiel #8
0
 def test_find_activity_with_overriden_input(self):
     _, args, _, _ = find_activity(FakeHistory(), scheduled_id=5, input={"args": [4]})
     expect(args).to.equal([4])
Beispiel #9
0
 def test_find_activity_with_overriden_input(self):
     _, args, _, _, _ = find_activity(FakeHistory(), scheduled_id=5, input={"args": [4]})
     expect(args).to.equal([4])