Skip to content

Commit 3618009

Browse files
committed
fix: ensure runId is an int in tests
1 parent e800414 commit 3618009

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/scriptworker/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ async def run_task(context, to_cancellable_process):
657657
"""
658658
env = deepcopy(os.environ)
659659
env["TASK_ID"] = context.task_id or "None"
660-
env["RUN_ID"] = get_run_id(context.claim_task)
660+
env["RUN_ID"] = str(get_run_id(context.claim_task))
661661
env["TASKCLUSTER_ROOT_URL"] = context.config["taskcluster_root_url"]
662662
kwargs = {"stdout": PIPE, "stderr": PIPE, "stdin": None, "close_fds": True, "preexec_fn": lambda: os.setsid(), "env": env} # pragma: no branch
663663

tests/test_artifacts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def context(rw_context):
3939
"credentials": {"a": "b"},
4040
"status": {"taskId": "taskId"},
4141
"task": {"expires": now.shift(days=2).isoformat(), "dependencies": ["dependency1", "dependency2"], "taskGroupId": "dependency0", "payload": {}},
42-
"runId": "runId",
42+
"runId": 0,
4343
}
4444
yield rw_context
4545

@@ -142,7 +142,7 @@ async def test_create_artifact(context, fake_session, successful_queue):
142142
await create_artifact(context, path, "public/env/one.txt", content_type="text/plain", content_encoding=None, expires=expires)
143143
assert successful_queue.info == [
144144
"createArtifact",
145-
("taskId", "runId", "public/env/one.txt", {"storageType": "s3", "expires": expires, "contentType": "text/plain"}),
145+
("taskId", 0, "public/env/one.txt", {"storageType": "s3", "expires": expires, "contentType": "text/plain"}),
146146
{},
147147
]
148148

tests/test_task.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _craft_context(rw_context):
4747
"credentials": {"a": "b"},
4848
"status": {"taskId": "taskId"},
4949
"task": {"dependencies": ["dependency1", "dependency2"], "taskGroupId": "dependency0"},
50-
"runId": "runId",
50+
"runId": 0,
5151
}
5252
return rw_context
5353

@@ -483,7 +483,7 @@ def test_is_action(task, expected):
483483
def test_prepare_to_run_task(context):
484484
claim_task = context.claim_task
485485
context.claim_task = None
486-
expected = {"taskId": "taskId", "runId": "runId"}
486+
expected = {"taskId": "taskId", "runId": 0}
487487
path = os.path.join(context.config["work_dir"], "current_task_info.json")
488488
assert swtask.prepare_to_run_task(context, claim_task) == expected
489489
assert os.path.exists(path)
@@ -497,7 +497,7 @@ def test_prepare_to_run_task(context):
497497
async def test_run_task(context):
498498
status = await swtask.run_task(context, noop_to_cancellable_process)
499499
log_file = log.get_log_filename(context)
500-
assert read(log_file) in ("taskId\nrunId\nhttps://tc\nexit code: 1\n", "taskId\nrunId\nhttps://tc\nexit code: 1\n")
500+
assert read(log_file) in ("taskId\n0\nhttps://tc\nexit code: 1\n", "taskId\n0\nhttps://tc\nexit code: 1\n")
501501
assert status == 1
502502

503503

@@ -571,29 +571,29 @@ async def test_run_task_timeout(context):
571571
async def test_reportCompleted(context, successful_queue):
572572
context.temp_queue = successful_queue
573573
await swtask.complete_task(context, 0)
574-
assert successful_queue.info == ["reportCompleted", ("taskId", "runId"), {}]
574+
assert successful_queue.info == ["reportCompleted", ("taskId", 0), {}]
575575

576576

577577
@pytest.mark.asyncio
578578
async def test_reportFailed(context, successful_queue):
579579
context.temp_queue = successful_queue
580580
await swtask.complete_task(context, 1)
581-
assert successful_queue.info == ["reportFailed", ("taskId", "runId"), {}]
581+
assert successful_queue.info == ["reportFailed", ("taskId", 0), {}]
582582

583583

584584
@pytest.mark.asyncio
585585
async def test_reportException(context, successful_queue):
586586
context.temp_queue = successful_queue
587587
await swtask.complete_task(context, 2)
588-
assert successful_queue.info == ["reportException", ("taskId", "runId", {"reason": "worker-shutdown"}), {}]
588+
assert successful_queue.info == ["reportException", ("taskId", 0, {"reason": "worker-shutdown"}), {}]
589589

590590

591591
@pytest.mark.parametrize("exit_code", (245, 241))
592592
@pytest.mark.asyncio
593593
async def test_reversed_statuses(context, successful_queue, exit_code):
594594
context.temp_queue = successful_queue
595595
await swtask.complete_task(context, exit_code)
596-
assert successful_queue.info == ["reportException", ("taskId", "runId", {"reason": context.config["reversed_statuses"][exit_code]}), {}]
596+
assert successful_queue.info == ["reportException", ("taskId", 0, {"reason": context.config["reversed_statuses"][exit_code]}), {}]
597597

598598

599599
# complete_task {{{1

tests/test_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def context(rw_context):
3131
"credentials": {"a": "b"},
3232
"status": {"taskId": "taskId"},
3333
"task": {"dependencies": ["dependency1", "dependency2"], "taskGroupId": "dependency0"},
34-
"runId": "runId",
34+
"runId": 0,
3535
}
3636
yield rw_context
3737

0 commit comments

Comments
 (0)