test_new_config.py (3619B)
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 from tryselect.selectors.auto import TRY_AUTO_PARAMETERS 7 8 pytestmark = pytest.mark.slow 9 10 PARAMS = TRY_AUTO_PARAMETERS.copy() 11 PARAMS.update({ 12 "head_repository": "https://hg.mozilla.org/try", 13 "project": "try", 14 "target_kind": "mochitest", 15 # These ensure this isn't considered a backstop. The pushdate must 16 # be slightly higher than the one in data/pushes.json, and 17 # pushlog_id must not be a multiple of 10. 18 "pushdate": 1593029536, 19 "pushlog_id": "2", 20 }) 21 22 PARAMS_NEW_CONFIG = TRY_AUTO_PARAMETERS.copy() 23 PARAMS_NEW_CONFIG.update({ 24 "head_repository": "https://hg.mozilla.org/try", 25 "project": "try", 26 "target_kind": "mochitest", 27 # These ensure this isn't considered a backstop. The pushdate must 28 # be slightly higher than the one in data/pushes.json, and 29 # pushlog_id must not be a multiple of 10. 30 "pushdate": 1593029536, 31 "pushlog_id": "2", 32 "try_task_config": {"new-test-config": True}, 33 "try_mode": "try_task_config", 34 "target_tasks_method": "try_tasks", 35 "test_manifest_loader": "default", 36 }) 37 38 39 @pytest.mark.parametrize( 40 "func,min_expected", 41 ( 42 pytest.param( 43 lambda t: ( 44 t.kind == "mochitest" 45 and t.attributes["unittest_suite"] == "mochitest-browser-chrome" 46 and t.attributes["test_platform"] == "linux2404-64/opt" 47 and ( 48 "spi-nw" not in t.label 49 and "a11y-checks" not in t.label 50 and "vt" not in t.label 51 and "ioi" not in t.label 52 and "trainhop" not in t.label 53 and "tsan" not in t.label 54 ) 55 ), 56 32, 57 id="mochitest-browser-chrome", 58 ), 59 ), 60 ) 61 def test_tasks_new_config_false(full_task_graph, filter_tasks, func, min_expected): 62 """Ensure when using new-test-config that we have -cf tasks and they are half the total tasks.""" 63 tasks = [t.label for t in filter_tasks(full_task_graph, func)] 64 assert len(tasks) == min_expected 65 66 cf_tasks = [ 67 t.label for t in filter_tasks(full_task_graph, func) if t.label.endswith("-cf") 68 ] 69 assert len(cf_tasks) == min_expected / 2 70 71 72 @pytest.mark.parametrize( 73 "func,min_expected", 74 ( 75 pytest.param( 76 lambda t: ( 77 t.kind == "mochitest" 78 and t.attributes["unittest_suite"] == "mochitest-browser-chrome" 79 and t.attributes["test_platform"] == "linux2404-64/opt" 80 and ( 81 "spi-nw" not in t.label 82 and "a11y-checks" not in t.label 83 and "vt" not in t.label 84 and "ioi" not in t.label 85 and "trainhop" not in t.label 86 and "tsan" not in t.label 87 ) 88 ), 89 32, 90 id="mochitest-browser-chrome", 91 ), 92 ), 93 ) 94 def test_tasks_new_config_true( 95 full_task_graph_new_config, filter_tasks, func, min_expected 96 ): 97 """Ensure when using new-test-config that no -cf tasks are scheduled and we have 2x the default and NO -cf.""" 98 tasks = [t.label for t in filter_tasks(full_task_graph_new_config, func)] 99 assert len(tasks) == min_expected 100 101 cf_tasks = [ 102 t.label 103 for t in filter_tasks(full_task_graph_new_config, func) 104 if t.label.endswith("-cf") 105 ] 106 assert len(cf_tasks) == 0 107 108 109 if __name__ == "__main__": 110 main()