test_mozilla_central.py (2035B)
1 # Any copyright is dedicated to the public domain. 2 # http://creativecommons.org/publicdomain/zero/1.0/ 3 4 import pytest 5 from mozunit import main 6 7 pytestmark = pytest.mark.slow 8 PARAMS = { 9 "head_repository": "https://hg.mozilla.org/mozilla-central", 10 "project": "central", 11 } 12 13 14 def test_generate_graph(optimized_task_graph): 15 """Simply tests that generating the graph does not fail.""" 16 assert len(optimized_task_graph.tasks) > 0 17 18 19 @pytest.mark.parametrize( 20 "func,min_expected", 21 ( 22 pytest.param( 23 lambda t: t.kind == "build" and "fuzzing" in t.attributes["build_platform"], 24 5, 25 id="fuzzing builds", 26 ), 27 ), 28 ) 29 def test_tasks_are_scheduled(optimized_task_graph, filter_tasks, func, min_expected): 30 """Ensure the specified tasks are scheduled on mozilla-central.""" 31 tasks = [t.label for t in filter_tasks(optimized_task_graph, func)] 32 print(tasks) 33 assert len(tasks) >= min_expected 34 35 36 def test_test_setting(full_task_graph, filter_tasks): 37 """Verify that all test tasks' ``test-setting`` object conforms to the schema.""" 38 from gecko_taskgraph.transforms.test.other import test_setting_description_schema 39 from taskgraph.util.schema import validate_schema 40 41 tasks = filter_tasks(full_task_graph, lambda t: t.kind == "test") 42 43 failures = [] 44 for task in tasks: 45 try: 46 validate_schema( 47 test_setting_description_schema, 48 dict(task.task["extra"]["test-setting"]), 49 task.label, 50 ) 51 except Exception as e: 52 failures.append(e) 53 54 if failures: 55 more = None 56 # Only display a few failures at once. 57 if len(failures) > 10: 58 more = len(failures) - 10 59 failures = failures[:10] 60 61 failstr = "\n\n" + "\n\n".join(str(e) for e in failures) 62 if more: 63 failstr += "\n\n" + f"... and {more} more" 64 65 pytest.fail(f"Task validation errors:{failstr}") 66 67 68 if __name__ == "__main__": 69 main()