summaryrefslogtreecommitdiffstats
path: root/taskcluster/gecko_taskgraph/test/test_morph.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /taskcluster/gecko_taskgraph/test/test_morph.py
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'taskcluster/gecko_taskgraph/test/test_morph.py')
-rw-r--r--taskcluster/gecko_taskgraph/test/test_morph.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/taskcluster/gecko_taskgraph/test/test_morph.py b/taskcluster/gecko_taskgraph/test/test_morph.py
index c29fb58207..c3c499769c 100644
--- a/taskcluster/gecko_taskgraph/test/test_morph.py
+++ b/taskcluster/gecko_taskgraph/test/test_morph.py
@@ -26,6 +26,102 @@ def make_taskgraph():
return inner
+@pytest.mark.parametrize(
+ "params,expected",
+ (
+ pytest.param(
+ {
+ "try_mode": "try_task_config",
+ "try_task_config": {
+ "rebuild": 10,
+ "tasks": ["b"],
+ },
+ "project": "try",
+ },
+ {"b": 10},
+ id="duplicates no chunks",
+ ),
+ pytest.param(
+ {
+ "try_mode": "try_task_config",
+ "try_task_config": {
+ "rebuild": 10,
+ "tasks": ["a-*"],
+ },
+ "project": "try",
+ },
+ {"a-1": 10, "a-2": 10},
+ id="duplicates with chunks",
+ ),
+ pytest.param(
+ {
+ "try_mode": "try_task_config",
+ "try_task_config": {
+ "rebuild": 10,
+ "tasks": ["a-*", "b"],
+ },
+ "project": "try",
+ },
+ {"a-1": 10, "a-2": 10, "b": 10},
+ id="duplicates with and without chunks",
+ ),
+ pytest.param(
+ {
+ "try_mode": "try_task_config",
+ "try_task_config": {
+ "tasks": ["a-*"],
+ },
+ "project": "try",
+ },
+ {"a-1": -1, "a-2": -1},
+ id="no rebuild, no duplicates",
+ ),
+ pytest.param(
+ {
+ "try_mode": "try_task_config",
+ "try_task_config": {
+ "rebuild": 0,
+ "tasks": ["a-*"],
+ },
+ "project": "try",
+ },
+ {"a-1": -1, "a-2": -1},
+ id="rebuild of zero",
+ ),
+ pytest.param(
+ {
+ "try_mode": "try_task_config",
+ "try_task_config": {
+ "rebuild": 100,
+ "tasks": ["a-*"],
+ },
+ "project": "try",
+ },
+ {"a-1": 100, "a-2": 100},
+ id="rebuild 100",
+ ),
+ ),
+)
+def test_try_task_duplicates(make_taskgraph, graph_config, params, expected):
+ taskb = Task(kind="test", label="b", attributes={}, task={})
+ task1 = Task(kind="test", label="a-1", attributes={}, task={})
+ task2 = Task(kind="test", label="a-2", attributes={}, task={})
+ taskgraph, label_to_taskid = make_taskgraph(
+ {
+ taskb.label: taskb,
+ task1.label: task1,
+ task2.label: task2,
+ }
+ )
+
+ taskgraph, label_to_taskid = morph._add_try_task_duplicates(
+ taskgraph, label_to_taskid, params, graph_config
+ )
+ for label in expected:
+ task = taskgraph.tasks[label]
+ assert task.attributes.get("task_duplicates", -1) == expected[label]
+
+
def test_make_index_tasks(make_taskgraph, graph_config):
task_def = {
"routes": [