2020-03-06 04:00:28 +03:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
2020-04-07 15:02:16 +03:00
|
|
|
import pytest
|
2020-06-16 15:32:45 +03:00
|
|
|
from _pytest.monkeypatch import MonkeyPatch
|
2020-04-07 15:02:16 +03:00
|
|
|
|
2020-03-06 04:00:28 +03:00
|
|
|
from bugbug import repository, test_scheduling
|
2020-06-16 15:32:45 +03:00
|
|
|
from bugbug.repository import CommitDict
|
|
|
|
from bugbug.test_scheduling import ConfigGroup, Group, Revision, Task
|
2020-03-06 04:00:28 +03:00
|
|
|
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
def test_rename_runnables() -> None:
|
2022-03-16 13:55:55 +03:00
|
|
|
assert test_scheduling.rename_runnables(
|
|
|
|
"label",
|
|
|
|
(Task("test-linux64/opt-mochitest-browser-chrome-e10s-2"),),
|
|
|
|
) == (Task("test-linux1804-64/opt-mochitest-browser-chrome-e10s-2"),)
|
|
|
|
assert test_scheduling.rename_runnables(
|
|
|
|
"label",
|
|
|
|
(Task("test-linux64-shippable/opt-mochitest-browser-chrome-e10s-2"),),
|
|
|
|
) == (Task("test-linux1804-64/opt-mochitest-browser-chrome-e10s-2"),)
|
|
|
|
assert test_scheduling.rename_runnables(
|
|
|
|
"label",
|
|
|
|
(Task("test-linux64-shippable-qr/opt-mochitest-browser-chrome-e10s-2"),),
|
|
|
|
) == (Task("test-linux1804-64-qr/opt-mochitest-browser-chrome-e10s-2"),)
|
2020-05-25 21:26:37 +03:00
|
|
|
assert test_scheduling.rename_runnables(
|
|
|
|
"label",
|
|
|
|
(
|
2020-07-28 17:26:53 +03:00
|
|
|
Task("test-linux64/opt-mochitest-browser-chrome-e10s-2"),
|
|
|
|
Task("test-linux64-qr/opt-web-platform-tests-wdspec-e10s-1"),
|
2020-05-25 21:26:37 +03:00
|
|
|
),
|
|
|
|
) == (
|
2020-07-28 17:26:53 +03:00
|
|
|
Task("test-linux1804-64/opt-mochitest-browser-chrome-e10s-2"),
|
|
|
|
Task("test-linux1804-64-qr/opt-web-platform-tests-wdspec-e10s-1"),
|
2020-05-25 21:26:37 +03:00
|
|
|
)
|
|
|
|
assert test_scheduling.rename_runnables(
|
|
|
|
"label",
|
|
|
|
(
|
2020-06-16 15:32:45 +03:00
|
|
|
Task(
|
|
|
|
"test-android-hw-p2-8-0-android-aarch64/pgo-geckoview-mochitest-media-e10s-2"
|
|
|
|
),
|
2020-05-25 21:26:37 +03:00
|
|
|
),
|
|
|
|
) == (
|
2020-06-16 15:32:45 +03:00
|
|
|
Task(
|
2020-07-28 17:26:53 +03:00
|
|
|
"test-android-hw-p2-8-0-android-aarch64/opt-geckoview-mochitest-media-e10s-2"
|
2020-06-16 15:32:45 +03:00
|
|
|
),
|
2020-05-25 21:26:37 +03:00
|
|
|
)
|
|
|
|
|
2022-03-16 13:55:55 +03:00
|
|
|
assert test_scheduling.rename_runnables(
|
|
|
|
"group",
|
|
|
|
(
|
|
|
|
Group(
|
|
|
|
"toolkit/components/extensions/test/mochitest/mochitest-remote.ini:toolkit/components/extensions/test/mochitest/mochitest-common.ini"
|
2020-06-16 15:32:45 +03:00
|
|
|
),
|
2022-03-16 13:55:55 +03:00
|
|
|
),
|
|
|
|
) == (Group("toolkit/components/extensions/test/mochitest/mochitest-remote.ini"),)
|
2020-06-16 15:32:45 +03:00
|
|
|
assert test_scheduling.rename_runnables(
|
|
|
|
"group", (Group("dom/prova/mochitest.ini"),)
|
|
|
|
) == (Group("dom/prova/mochitest.ini"),)
|
2020-05-25 21:26:37 +03:00
|
|
|
|
|
|
|
assert test_scheduling.rename_runnables(
|
|
|
|
"config_group",
|
|
|
|
(
|
2020-06-16 15:32:45 +03:00
|
|
|
ConfigGroup(
|
|
|
|
(
|
|
|
|
"test-linux64-shippable/opt-*-e10s",
|
|
|
|
Group(
|
|
|
|
"toolkit/components/extensions/test/mochitest/mochitest-remote.ini:toolkit/components/extensions/test/mochitest/mochitest-common.ini"
|
|
|
|
),
|
|
|
|
)
|
2020-05-25 21:26:37 +03:00
|
|
|
),
|
|
|
|
),
|
|
|
|
) == (
|
2020-06-16 15:32:45 +03:00
|
|
|
ConfigGroup(
|
|
|
|
(
|
2020-07-28 17:26:53 +03:00
|
|
|
"test-linux1804-64/opt-*-e10s",
|
2020-06-16 15:32:45 +03:00
|
|
|
Group(
|
|
|
|
"toolkit/components/extensions/test/mochitest/mochitest-remote.ini"
|
|
|
|
),
|
|
|
|
)
|
2020-05-25 21:26:37 +03:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
def test_touched_together(monkeypatch: MonkeyPatch) -> None:
|
2020-03-06 04:00:28 +03:00
|
|
|
test_scheduling.touched_together = None
|
|
|
|
|
|
|
|
repository.path_to_component = {
|
|
|
|
"dom/file1.cpp": "Core::DOM",
|
|
|
|
"dom/file2.cpp": "Core::DOM",
|
|
|
|
"layout/file.cpp": "Core::Layout",
|
|
|
|
"dom/tests/manifest1.ini": "Core::DOM",
|
|
|
|
"dom/tests/manifest2.ini": "Core::DOM",
|
|
|
|
}
|
|
|
|
|
2020-03-13 02:52:01 +03:00
|
|
|
commits = [
|
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commit1",
|
|
|
|
author="author1",
|
|
|
|
desc="commit1",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commitbackedout",
|
|
|
|
author="author1",
|
|
|
|
desc="commitbackedout",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="commitbackout",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commit2",
|
|
|
|
author="author2",
|
|
|
|
desc="commit2",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author2@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["dom/file2.cpp", "layout/tests/manifest2.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commit3",
|
|
|
|
author="author1",
|
|
|
|
desc="commit3",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer2"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["layout/file.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commit4",
|
|
|
|
author="author1",
|
|
|
|
desc="commit4",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
]
|
|
|
|
commits = [c.to_dict() for c in commits]
|
|
|
|
|
2021-12-01 19:27:14 +03:00
|
|
|
def mock_get_commits() -> list[CommitDict]:
|
2020-03-13 02:52:01 +03:00
|
|
|
return commits
|
|
|
|
|
|
|
|
monkeypatch.setattr(repository, "get_commits", mock_get_commits)
|
|
|
|
|
|
|
|
update_touched_together_gen = test_scheduling.update_touched_together()
|
|
|
|
next(update_touched_together_gen)
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
update_touched_together_gen.send(Revision("commit2"))
|
2020-03-13 02:52:01 +03:00
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/tests", "dom/file1.cpp") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests/manifest1.ini") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file2.cpp", "layout/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("dom", "layout/tests/manifest2.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/file2.cpp") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("layout/file.cpp", "dom/tests") == 0
|
|
|
|
assert test_scheduling.get_touched_together("layout", "dom/tests") == 0
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
update_touched_together_gen.send(Revision("commit4"))
|
2020-03-13 02:52:01 +03:00
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/tests") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom/tests", "dom/file1.cpp") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests/manifest1.ini") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file2.cpp", "layout/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("dom", "layout/tests/manifest2.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/file2.cpp") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("layout/file.cpp", "dom/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("layout", "dom/tests/manifest1.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("layout", "dom/tests") == 1
|
|
|
|
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
def test_touched_together_restart(monkeypatch: MonkeyPatch) -> None:
|
2020-03-13 02:52:01 +03:00
|
|
|
test_scheduling.touched_together = None
|
|
|
|
|
|
|
|
repository.path_to_component = {
|
|
|
|
"dom/file1.cpp": "Core::DOM",
|
|
|
|
"dom/file2.cpp": "Core::DOM",
|
|
|
|
"layout/file.cpp": "Core::Layout",
|
|
|
|
"dom/tests/manifest1.ini": "Core::DOM",
|
|
|
|
"dom/tests/manifest2.ini": "Core::DOM",
|
2020-03-06 04:00:28 +03:00
|
|
|
}
|
|
|
|
|
2020-03-13 02:52:01 +03:00
|
|
|
commits = [
|
|
|
|
repository.Commit(
|
|
|
|
node="commit1",
|
|
|
|
author="author1",
|
|
|
|
desc="commit1",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-13 02:52:01 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-13 02:52:01 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
|
|
|
repository.Commit(
|
|
|
|
node="commitbackedout",
|
|
|
|
author="author1",
|
|
|
|
desc="commitbackedout",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-13 02:52:01 +03:00
|
|
|
backedoutby="commitbackout",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-13 02:52:01 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
|
|
|
repository.Commit(
|
|
|
|
node="commit2",
|
|
|
|
author="author2",
|
|
|
|
desc="commit2",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-13 02:52:01 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author2@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1"],
|
2020-03-13 02:52:01 +03:00
|
|
|
).set_files(["dom/file2.cpp", "layout/tests/manifest2.ini"], {}),
|
|
|
|
repository.Commit(
|
|
|
|
node="commit3",
|
|
|
|
author="author1",
|
|
|
|
desc="commit3",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-13 02:52:01 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer2"],
|
2020-03-13 02:52:01 +03:00
|
|
|
).set_files(["layout/file.cpp", "dom/tests/manifest1.ini"], {}),
|
|
|
|
repository.Commit(
|
|
|
|
node="commit4",
|
|
|
|
author="author1",
|
|
|
|
desc="commit4",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-13 02:52:01 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-13 02:52:01 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
|
|
|
]
|
|
|
|
commits = [c.to_dict() for c in commits]
|
|
|
|
|
2021-12-01 19:27:14 +03:00
|
|
|
def mock_get_commits() -> list[CommitDict]:
|
2020-03-13 02:52:01 +03:00
|
|
|
return commits
|
2020-03-06 04:00:28 +03:00
|
|
|
|
|
|
|
monkeypatch.setattr(repository, "get_commits", mock_get_commits)
|
|
|
|
|
|
|
|
update_touched_together_gen = test_scheduling.update_touched_together()
|
|
|
|
next(update_touched_together_gen)
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
update_touched_together_gen.send(Revision("commit2"))
|
2020-03-06 04:00:28 +03:00
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/tests", "dom/file1.cpp") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests/manifest1.ini") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file2.cpp", "layout/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("dom", "layout/tests/manifest2.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/file2.cpp") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("layout/file.cpp", "dom/tests") == 0
|
|
|
|
assert test_scheduling.get_touched_together("layout", "dom/tests") == 0
|
|
|
|
|
2020-03-13 02:52:01 +03:00
|
|
|
try:
|
|
|
|
update_touched_together_gen.send(None)
|
|
|
|
except StopIteration:
|
|
|
|
pass
|
|
|
|
|
2020-03-17 05:03:37 +03:00
|
|
|
# Ensure we can still read the DB after closing.
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 1
|
2020-06-14 18:47:41 +03:00
|
|
|
test_scheduling.close_touched_together_db()
|
2020-03-13 02:52:01 +03:00
|
|
|
|
|
|
|
update_touched_together_gen = test_scheduling.update_touched_together()
|
|
|
|
next(update_touched_together_gen)
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
update_touched_together_gen.send(Revision("commit4"))
|
2020-03-06 04:00:28 +03:00
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/tests") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom/tests", "dom/file1.cpp") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests/manifest1.ini") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file2.cpp", "layout/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("dom", "layout/tests/manifest2.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/file2.cpp") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("layout/file.cpp", "dom/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("layout", "dom/tests/manifest1.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("layout", "dom/tests") == 1
|
|
|
|
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
def test_touched_together_not_in_order(monkeypatch: MonkeyPatch) -> None:
|
2020-03-06 04:00:28 +03:00
|
|
|
test_scheduling.touched_together = None
|
|
|
|
|
|
|
|
repository.path_to_component = {
|
|
|
|
"dom/file1.cpp": "Core::DOM",
|
|
|
|
"dom/file2.cpp": "Core::DOM",
|
|
|
|
"layout/file.cpp": "Core::Layout",
|
|
|
|
"dom/tests/manifest1.ini": "Core::DOM",
|
|
|
|
"dom/tests/manifest2.ini": "Core::DOM",
|
|
|
|
}
|
|
|
|
|
2020-03-13 02:52:01 +03:00
|
|
|
commits = [
|
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commit1",
|
|
|
|
author="author1",
|
|
|
|
desc="commit1",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commitbackedout",
|
|
|
|
author="author1",
|
|
|
|
desc="commitbackedout",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="commitbackout",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commit2",
|
|
|
|
author="author2",
|
|
|
|
desc="commit2",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author2@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["dom/file2.cpp", "layout/tests/manifest2.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commit3",
|
|
|
|
author="author1",
|
|
|
|
desc="commit3",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer2"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["layout/file.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-06 04:00:28 +03:00
|
|
|
node="commit4",
|
|
|
|
author="author1",
|
|
|
|
desc="commit4",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-06 04:00:28 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-06 04:00:28 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
]
|
|
|
|
commits = [c.to_dict() for c in commits]
|
2020-03-06 04:00:28 +03:00
|
|
|
|
2021-12-01 19:27:14 +03:00
|
|
|
def mock_get_commits() -> list[CommitDict]:
|
2020-03-13 02:52:01 +03:00
|
|
|
return commits
|
2020-03-06 04:00:28 +03:00
|
|
|
|
|
|
|
monkeypatch.setattr(repository, "get_commits", mock_get_commits)
|
|
|
|
|
|
|
|
update_touched_together_gen = test_scheduling.update_touched_together()
|
|
|
|
next(update_touched_together_gen)
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
update_touched_together_gen.send(Revision("commit2"))
|
2020-03-06 04:00:28 +03:00
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/tests", "dom/file1.cpp") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests/manifest1.ini") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file2.cpp", "layout/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("dom", "layout/tests/manifest2.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/file2.cpp") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("layout/file.cpp", "dom/tests") == 0
|
|
|
|
assert test_scheduling.get_touched_together("layout", "dom/tests") == 0
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
update_touched_together_gen.send(Revision("commit1"))
|
2020-03-06 04:00:28 +03:00
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/tests", "dom/file1.cpp") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests/manifest1.ini") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file2.cpp", "layout/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("dom", "layout/tests/manifest2.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/file2.cpp") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("layout/file.cpp", "dom/tests") == 0
|
|
|
|
assert test_scheduling.get_touched_together("layout", "dom/tests") == 0
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
update_touched_together_gen.send(Revision("commit4"))
|
2020-03-06 04:00:28 +03:00
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/tests") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom/tests", "dom/file1.cpp") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests/manifest1.ini") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests") == 2
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file2.cpp", "layout/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("dom", "layout/tests/manifest2.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/file2.cpp") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("layout/file.cpp", "dom/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("layout", "dom/tests/manifest1.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("layout", "dom/tests") == 1
|
2020-03-11 18:55:10 +03:00
|
|
|
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
def test_touched_together_with_backout(monkeypatch: MonkeyPatch) -> None:
|
2020-03-11 18:55:10 +03:00
|
|
|
test_scheduling.touched_together = None
|
|
|
|
|
|
|
|
repository.path_to_component = {
|
|
|
|
"dom/file1.cpp": "Core::DOM",
|
|
|
|
"dom/file2.cpp": "Core::DOM",
|
|
|
|
"layout/file.cpp": "Core::Layout",
|
|
|
|
"dom/tests/manifest1.ini": "Core::DOM",
|
|
|
|
"dom/tests/manifest2.ini": "Core::DOM",
|
|
|
|
}
|
|
|
|
|
2020-03-13 02:52:01 +03:00
|
|
|
commits = [
|
|
|
|
repository.Commit(
|
2020-03-11 18:55:10 +03:00
|
|
|
node="commit1",
|
|
|
|
author="author1",
|
|
|
|
desc="commit1",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-11 18:55:10 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-11 18:55:10 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-11 18:55:10 +03:00
|
|
|
node="commitbackedout",
|
|
|
|
author="author1",
|
|
|
|
desc="commitbackedout",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-11 18:55:10 +03:00
|
|
|
backedoutby="commitbackout",
|
|
|
|
author_email="author1@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1", "reviewer2"],
|
2020-03-11 18:55:10 +03:00
|
|
|
).set_files(["dom/file1.cpp", "dom/tests/manifest1.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
repository.Commit(
|
2020-03-11 18:55:10 +03:00
|
|
|
node="commit2",
|
|
|
|
author="author2",
|
|
|
|
desc="commit2",
|
|
|
|
pushdate=datetime(2019, 1, 1),
|
|
|
|
bug_id=123,
|
2020-04-28 22:29:49 +03:00
|
|
|
backsout=[],
|
2020-03-11 18:55:10 +03:00
|
|
|
backedoutby="",
|
|
|
|
author_email="author2@mozilla.org",
|
2020-07-17 16:29:17 +03:00
|
|
|
reviewers=["reviewer1"],
|
2020-03-11 18:55:10 +03:00
|
|
|
).set_files(["dom/file2.cpp", "layout/tests/manifest2.ini"], {}),
|
2020-03-13 02:52:01 +03:00
|
|
|
]
|
|
|
|
commits = [c.to_dict() for c in commits]
|
2020-03-11 18:55:10 +03:00
|
|
|
|
2021-12-01 19:27:14 +03:00
|
|
|
def mock_get_commits() -> list[CommitDict]:
|
2020-03-13 02:52:01 +03:00
|
|
|
return commits
|
2020-03-11 18:55:10 +03:00
|
|
|
|
|
|
|
monkeypatch.setattr(repository, "get_commits", mock_get_commits)
|
|
|
|
|
|
|
|
update_touched_together_gen = test_scheduling.update_touched_together()
|
|
|
|
next(update_touched_together_gen)
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
update_touched_together_gen.send(Revision("commitbackedout"))
|
2020-03-11 18:55:10 +03:00
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/tests", "dom/file1.cpp") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests/manifest1.ini") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file2.cpp", "layout/tests") == 0
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("dom", "layout/tests/manifest2.ini") == 0
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 0
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/file2.cpp") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("layout/file.cpp", "dom/tests") == 0
|
|
|
|
assert test_scheduling.get_touched_together("layout", "dom/tests") == 0
|
|
|
|
|
2020-06-16 15:32:45 +03:00
|
|
|
update_touched_together_gen.send(Revision("commit2"))
|
2020-03-11 18:55:10 +03:00
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/tests", "dom/file1.cpp") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests/manifest1.ini") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom", "dom") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("dom/file2.cpp", "layout/tests") == 1
|
|
|
|
assert (
|
|
|
|
test_scheduling.get_touched_together("dom", "layout/tests/manifest2.ini") == 1
|
|
|
|
)
|
|
|
|
assert test_scheduling.get_touched_together("dom", "layout/tests") == 1
|
|
|
|
assert test_scheduling.get_touched_together("dom/file1.cpp", "dom/file2.cpp") == 0
|
|
|
|
|
|
|
|
assert test_scheduling.get_touched_together("layout/file.cpp", "dom/tests") == 0
|
|
|
|
assert test_scheduling.get_touched_together("layout", "dom/tests") == 0
|
2020-04-07 15:02:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("granularity", ["group", "label"])
|
2020-06-16 15:32:45 +03:00
|
|
|
def test_generate_data(granularity: str) -> None:
|
2020-06-14 18:12:29 +03:00
|
|
|
past_failures = test_scheduling.get_past_failures(granularity, False)
|
2020-04-07 15:02:16 +03:00
|
|
|
|
|
|
|
commits = [
|
2020-06-16 15:32:45 +03:00
|
|
|
CommitDict(
|
|
|
|
{
|
|
|
|
"types": ["C/C++"],
|
|
|
|
"files": ["dom/file1.cpp"],
|
|
|
|
"directories": ["dom"],
|
|
|
|
"components": ["DOM"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
CommitDict(
|
|
|
|
{
|
|
|
|
"types": ["C/C++"],
|
|
|
|
"files": ["dom/file1.cpp", "dom/file2.cpp"],
|
|
|
|
"directories": ["dom"],
|
|
|
|
"components": ["DOM"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
CommitDict(
|
|
|
|
{
|
|
|
|
"types": ["C/C++"],
|
|
|
|
"files": ["layout/file.cpp"],
|
|
|
|
"directories": ["layout"],
|
|
|
|
"components": ["Layout"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
CommitDict(
|
|
|
|
{
|
|
|
|
"types": ["C/C++"],
|
|
|
|
"files": ["layout/file.cpp"],
|
|
|
|
"directories": ["layout"],
|
|
|
|
"components": ["Layout"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
CommitDict(
|
|
|
|
{
|
|
|
|
"types": ["JavaScript", "C/C++"],
|
|
|
|
"files": ["dom/file1.cpp", "dom/file1.js"],
|
|
|
|
"directories": ["dom"],
|
|
|
|
"components": ["DOM"],
|
|
|
|
}
|
|
|
|
),
|
2020-04-07 15:02:16 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
data = list(
|
|
|
|
test_scheduling.generate_data(
|
2020-06-16 15:32:45 +03:00
|
|
|
granularity,
|
|
|
|
past_failures,
|
|
|
|
commits[0],
|
|
|
|
1,
|
|
|
|
["runnable1", "runnable2"],
|
|
|
|
[],
|
|
|
|
[],
|
2020-04-07 15:02:16 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
assert len(data) == 2
|
2020-06-16 16:32:46 +03:00
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 0,
|
|
|
|
"failures_in_components": 0,
|
|
|
|
"failures_in_directories": 0,
|
|
|
|
"failures_in_files": 0,
|
|
|
|
"failures_in_types": 0,
|
|
|
|
"failures_past_1400_pushes": 0,
|
|
|
|
"failures_past_1400_pushes_in_components": 0,
|
|
|
|
"failures_past_1400_pushes_in_directories": 0,
|
|
|
|
"failures_past_1400_pushes_in_files": 0,
|
|
|
|
"failures_past_1400_pushes_in_types": 0,
|
|
|
|
"failures_past_2800_pushes": 0,
|
|
|
|
"failures_past_2800_pushes_in_components": 0,
|
|
|
|
"failures_past_2800_pushes_in_directories": 0,
|
|
|
|
"failures_past_2800_pushes_in_files": 0,
|
|
|
|
"failures_past_2800_pushes_in_types": 0,
|
|
|
|
"failures_past_700_pushes": 0,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 0,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": False,
|
|
|
|
"name": "runnable1",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[0] == obj
|
|
|
|
|
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 0,
|
|
|
|
"failures_in_components": 0,
|
|
|
|
"failures_in_directories": 0,
|
|
|
|
"failures_in_files": 0,
|
|
|
|
"failures_in_types": 0,
|
|
|
|
"failures_past_1400_pushes": 0,
|
|
|
|
"failures_past_1400_pushes_in_components": 0,
|
|
|
|
"failures_past_1400_pushes_in_directories": 0,
|
|
|
|
"failures_past_1400_pushes_in_files": 0,
|
|
|
|
"failures_past_1400_pushes_in_types": 0,
|
|
|
|
"failures_past_2800_pushes": 0,
|
|
|
|
"failures_past_2800_pushes_in_components": 0,
|
|
|
|
"failures_past_2800_pushes_in_directories": 0,
|
|
|
|
"failures_past_2800_pushes_in_files": 0,
|
|
|
|
"failures_past_2800_pushes_in_types": 0,
|
|
|
|
"failures_past_700_pushes": 0,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 0,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": False,
|
|
|
|
"name": "runnable2",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[1] == obj
|
2020-04-07 15:02:16 +03:00
|
|
|
|
|
|
|
data = list(
|
|
|
|
test_scheduling.generate_data(
|
2020-06-16 15:32:45 +03:00
|
|
|
granularity,
|
|
|
|
past_failures,
|
|
|
|
commits[1],
|
|
|
|
2,
|
|
|
|
["runnable1", "runnable2"],
|
|
|
|
["runnable1"],
|
|
|
|
[],
|
2020-04-07 15:02:16 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
assert len(data) == 2
|
2020-06-16 16:32:46 +03:00
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 0,
|
|
|
|
"failures_in_components": 0,
|
|
|
|
"failures_in_directories": 0,
|
|
|
|
"failures_in_files": 0,
|
|
|
|
"failures_in_types": 0,
|
|
|
|
"failures_past_1400_pushes": 0,
|
|
|
|
"failures_past_1400_pushes_in_components": 0,
|
|
|
|
"failures_past_1400_pushes_in_directories": 0,
|
|
|
|
"failures_past_1400_pushes_in_files": 0,
|
|
|
|
"failures_past_1400_pushes_in_types": 0,
|
|
|
|
"failures_past_2800_pushes": 0,
|
|
|
|
"failures_past_2800_pushes_in_components": 0,
|
|
|
|
"failures_past_2800_pushes_in_directories": 0,
|
|
|
|
"failures_past_2800_pushes_in_files": 0,
|
|
|
|
"failures_past_2800_pushes_in_types": 0,
|
|
|
|
"failures_past_700_pushes": 0,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 0,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": True,
|
|
|
|
"name": "runnable1",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[0] == obj
|
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 0,
|
|
|
|
"failures_in_components": 0,
|
|
|
|
"failures_in_directories": 0,
|
|
|
|
"failures_in_files": 0,
|
|
|
|
"failures_in_types": 0,
|
|
|
|
"failures_past_1400_pushes": 0,
|
|
|
|
"failures_past_1400_pushes_in_components": 0,
|
|
|
|
"failures_past_1400_pushes_in_directories": 0,
|
|
|
|
"failures_past_1400_pushes_in_files": 0,
|
|
|
|
"failures_past_1400_pushes_in_types": 0,
|
|
|
|
"failures_past_2800_pushes": 0,
|
|
|
|
"failures_past_2800_pushes_in_components": 0,
|
|
|
|
"failures_past_2800_pushes_in_directories": 0,
|
|
|
|
"failures_past_2800_pushes_in_files": 0,
|
|
|
|
"failures_past_2800_pushes_in_types": 0,
|
|
|
|
"failures_past_700_pushes": 0,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 0,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": False,
|
|
|
|
"name": "runnable2",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[1] == obj
|
2020-04-07 15:02:16 +03:00
|
|
|
|
|
|
|
data = list(
|
|
|
|
test_scheduling.generate_data(
|
2020-06-16 15:32:45 +03:00
|
|
|
granularity,
|
|
|
|
past_failures,
|
|
|
|
commits[2],
|
|
|
|
3,
|
|
|
|
["runnable1", "runnable2"],
|
|
|
|
[],
|
|
|
|
["runnable2"],
|
2020-04-07 15:02:16 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
assert len(data) == 2
|
2020-06-16 16:32:46 +03:00
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 1,
|
|
|
|
"failures_in_components": 0,
|
|
|
|
"failures_in_directories": 0,
|
|
|
|
"failures_in_files": 0,
|
|
|
|
"failures_in_types": 1,
|
|
|
|
"failures_past_1400_pushes": 1,
|
|
|
|
"failures_past_1400_pushes_in_components": 0,
|
|
|
|
"failures_past_1400_pushes_in_directories": 0,
|
|
|
|
"failures_past_1400_pushes_in_files": 0,
|
|
|
|
"failures_past_1400_pushes_in_types": 1,
|
|
|
|
"failures_past_2800_pushes": 1,
|
|
|
|
"failures_past_2800_pushes_in_components": 0,
|
|
|
|
"failures_past_2800_pushes_in_directories": 0,
|
|
|
|
"failures_past_2800_pushes_in_files": 0,
|
|
|
|
"failures_past_2800_pushes_in_types": 1,
|
|
|
|
"failures_past_700_pushes": 1,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 1,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": False,
|
|
|
|
"name": "runnable1",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[0] == obj
|
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 0,
|
|
|
|
"failures_in_components": 0,
|
|
|
|
"failures_in_directories": 0,
|
|
|
|
"failures_in_files": 0,
|
|
|
|
"failures_in_types": 0,
|
|
|
|
"failures_past_1400_pushes": 0,
|
|
|
|
"failures_past_1400_pushes_in_components": 0,
|
|
|
|
"failures_past_1400_pushes_in_directories": 0,
|
|
|
|
"failures_past_1400_pushes_in_files": 0,
|
|
|
|
"failures_past_1400_pushes_in_types": 0,
|
|
|
|
"failures_past_2800_pushes": 0,
|
|
|
|
"failures_past_2800_pushes_in_components": 0,
|
|
|
|
"failures_past_2800_pushes_in_directories": 0,
|
|
|
|
"failures_past_2800_pushes_in_files": 0,
|
|
|
|
"failures_past_2800_pushes_in_types": 0,
|
|
|
|
"failures_past_700_pushes": 0,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 0,
|
|
|
|
"is_likely_regression": True,
|
|
|
|
"is_possible_regression": False,
|
|
|
|
"name": "runnable2",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[1] == obj
|
2020-04-07 15:02:16 +03:00
|
|
|
|
|
|
|
data = list(
|
|
|
|
test_scheduling.generate_data(
|
2020-06-16 15:32:45 +03:00
|
|
|
granularity, past_failures, commits[3], 4, ["runnable1"], [], []
|
2020-04-07 15:02:16 +03:00
|
|
|
)
|
|
|
|
)
|
|
|
|
assert len(data) == 1
|
2020-06-16 16:32:46 +03:00
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 1,
|
|
|
|
"failures_in_components": 0,
|
|
|
|
"failures_in_directories": 0,
|
|
|
|
"failures_in_files": 0,
|
|
|
|
"failures_in_types": 1,
|
|
|
|
"failures_past_1400_pushes": 1,
|
|
|
|
"failures_past_1400_pushes_in_components": 0,
|
|
|
|
"failures_past_1400_pushes_in_directories": 0,
|
|
|
|
"failures_past_1400_pushes_in_files": 0,
|
|
|
|
"failures_past_1400_pushes_in_types": 1,
|
|
|
|
"failures_past_2800_pushes": 1,
|
|
|
|
"failures_past_2800_pushes_in_components": 0,
|
|
|
|
"failures_past_2800_pushes_in_directories": 0,
|
|
|
|
"failures_past_2800_pushes_in_files": 0,
|
|
|
|
"failures_past_2800_pushes_in_types": 1,
|
|
|
|
"failures_past_700_pushes": 1,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 1,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": False,
|
|
|
|
"name": "runnable1",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[0] == obj
|
2020-04-07 15:02:16 +03:00
|
|
|
|
|
|
|
data = list(
|
|
|
|
test_scheduling.generate_data(
|
2020-06-16 15:32:45 +03:00
|
|
|
granularity,
|
2020-04-07 15:02:16 +03:00
|
|
|
past_failures,
|
|
|
|
commits[4],
|
|
|
|
1500,
|
|
|
|
["runnable1", "runnable2"],
|
|
|
|
["runnable1", "runnable2"],
|
|
|
|
[],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert len(data) == 2
|
2020-06-16 16:32:46 +03:00
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 1,
|
|
|
|
"failures_in_components": 1,
|
|
|
|
"failures_in_directories": 1,
|
|
|
|
"failures_in_files": 1,
|
|
|
|
"failures_in_types": 1,
|
|
|
|
"failures_past_1400_pushes": 0,
|
|
|
|
"failures_past_1400_pushes_in_components": 0,
|
|
|
|
"failures_past_1400_pushes_in_directories": 0,
|
|
|
|
"failures_past_1400_pushes_in_files": 0,
|
|
|
|
"failures_past_1400_pushes_in_types": 0,
|
|
|
|
"failures_past_2800_pushes": 1,
|
|
|
|
"failures_past_2800_pushes_in_components": 1,
|
|
|
|
"failures_past_2800_pushes_in_directories": 1,
|
|
|
|
"failures_past_2800_pushes_in_files": 1,
|
|
|
|
"failures_past_2800_pushes_in_types": 1,
|
|
|
|
"failures_past_700_pushes": 0,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 0,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": True,
|
|
|
|
"name": "runnable1",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[0] == obj
|
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 1,
|
|
|
|
"failures_in_components": 0,
|
|
|
|
"failures_in_directories": 0,
|
|
|
|
"failures_in_files": 0,
|
|
|
|
"failures_in_types": 1,
|
|
|
|
"failures_past_1400_pushes": 0,
|
|
|
|
"failures_past_1400_pushes_in_components": 0,
|
|
|
|
"failures_past_1400_pushes_in_directories": 0,
|
|
|
|
"failures_past_1400_pushes_in_files": 0,
|
|
|
|
"failures_past_1400_pushes_in_types": 0,
|
|
|
|
"failures_past_2800_pushes": 1,
|
|
|
|
"failures_past_2800_pushes_in_components": 0,
|
|
|
|
"failures_past_2800_pushes_in_directories": 0,
|
|
|
|
"failures_past_2800_pushes_in_files": 0,
|
|
|
|
"failures_past_2800_pushes_in_types": 1,
|
|
|
|
"failures_past_700_pushes": 0,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 0,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": True,
|
|
|
|
"name": "runnable2",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[1] == obj
|
2020-04-07 15:02:16 +03:00
|
|
|
|
|
|
|
data = list(
|
|
|
|
test_scheduling.generate_data(
|
2020-06-16 15:32:45 +03:00
|
|
|
granularity,
|
2020-04-07 15:02:16 +03:00
|
|
|
past_failures,
|
|
|
|
commits[4],
|
|
|
|
2400,
|
|
|
|
["runnable1", "runnable2"],
|
|
|
|
["runnable1", "runnable2"],
|
|
|
|
[],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert len(data) == 2
|
2020-06-16 16:32:46 +03:00
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 2,
|
|
|
|
"failures_in_components": 2,
|
|
|
|
"failures_in_directories": 2,
|
|
|
|
"failures_in_files": 3,
|
|
|
|
"failures_in_types": 3,
|
|
|
|
"failures_past_1400_pushes": 1,
|
|
|
|
"failures_past_1400_pushes_in_components": 1,
|
|
|
|
"failures_past_1400_pushes_in_directories": 1,
|
|
|
|
"failures_past_1400_pushes_in_files": 2,
|
|
|
|
"failures_past_1400_pushes_in_types": 2,
|
|
|
|
"failures_past_2800_pushes": 2,
|
|
|
|
"failures_past_2800_pushes_in_components": 2,
|
|
|
|
"failures_past_2800_pushes_in_directories": 2,
|
|
|
|
"failures_past_2800_pushes_in_files": 3,
|
|
|
|
"failures_past_2800_pushes_in_types": 3,
|
|
|
|
"failures_past_700_pushes": 0,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 0,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": True,
|
|
|
|
"name": "runnable1",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[0] == obj
|
|
|
|
obj = {
|
2020-04-07 15:02:16 +03:00
|
|
|
"failures": 2,
|
|
|
|
"failures_in_components": 1,
|
|
|
|
"failures_in_directories": 1,
|
|
|
|
"failures_in_files": 2,
|
|
|
|
"failures_in_types": 3,
|
|
|
|
"failures_past_1400_pushes": 1,
|
|
|
|
"failures_past_1400_pushes_in_components": 1,
|
|
|
|
"failures_past_1400_pushes_in_directories": 1,
|
|
|
|
"failures_past_1400_pushes_in_files": 2,
|
|
|
|
"failures_past_1400_pushes_in_types": 2,
|
|
|
|
"failures_past_2800_pushes": 2,
|
|
|
|
"failures_past_2800_pushes_in_components": 1,
|
|
|
|
"failures_past_2800_pushes_in_directories": 1,
|
|
|
|
"failures_past_2800_pushes_in_files": 2,
|
|
|
|
"failures_past_2800_pushes_in_types": 3,
|
|
|
|
"failures_past_700_pushes": 0,
|
|
|
|
"failures_past_700_pushes_in_components": 0,
|
|
|
|
"failures_past_700_pushes_in_directories": 0,
|
|
|
|
"failures_past_700_pushes_in_files": 0,
|
|
|
|
"failures_past_700_pushes_in_types": 0,
|
|
|
|
"is_likely_regression": False,
|
|
|
|
"is_possible_regression": True,
|
|
|
|
"name": "runnable2",
|
|
|
|
}
|
2020-06-16 16:32:46 +03:00
|
|
|
if granularity == "group":
|
|
|
|
obj["touched_together_directories"] = 0
|
|
|
|
obj["touched_together_files"] = 0
|
|
|
|
assert data[1] == obj
|