def test_verify_payload(): """Verify that the decision task produces tasks with a valid payload""" from tools.ci.tc.decision import decide r = requests.get("https://community-tc.services.mozilla.com/schemas/queue/v1/create-task-request.json") r.raise_for_status() create_task_schema = r.json() r = requests.get("https://community-tc.services.mozilla.com/references/schemas/docker-worker/v1/payload.json") r.raise_for_status() payload_schema = r.json() jobs = ["lint", "manifest_upload", "resources_unittest", "tools_unittest", "wpt_integration", "wptrunner_infrastructure", "wptrunner_unittest"] for filename in ["pr_event.json", "master_push_event.json"]: with open(data_path(filename), encoding="utf8") as f: event = json.load(f) with mock.patch("tools.ci.tc.decision.get_fetch_rev", return_value=(None, event["after"], None)): with mock.patch("tools.ci.tc.decision.get_run_jobs", return_value=set(jobs)): task_id_map = decide(event) for name, (task_id, task_data) in task_id_map.items(): try: validate(instance=task_data, schema=create_task_schema) validate(instance=task_data["payload"], schema=payload_schema) except Exception as e: print("Validation failed for task '%s':\n%s" % (name, json.dumps(task_data, indent=2))) raise e
def test_schedule_tasks(event_path, is_pr, files_changed, expected): with mock.patch("tools.ci.tc.decision.get_fetch_rev", return_value=(None, None, None)): with mock.patch("tools.wpt.testfiles.repo_files_changed", return_value=files_changed): with open(data_path(event_path), encoding="utf8") as event_file: event = json.load(event_file) scheduled = decision.decide(event) assert list(scheduled.keys()) == expected
def test_verify_payload(): """Verify that the decision task produces tasks with a valid payload""" from tools.ci.tc.decision import decide r = requests.get( "https://community-tc.services.mozilla.com/schemas/queue/v1/create-task-request.json" ) r.raise_for_status() create_task_schema = r.json() # TODO(Hexcles): Change it to https://community-tc.services.mozilla.com/references/schemas/docker-worker/v1/payload.json # after the next Community-TC release (see https://bugzilla.mozilla.org/show_bug.cgi?id=1639732).. r = requests.get( "https://raw.githubusercontent.com/taskcluster/taskcluster/" "3ed511ef9119da54fc093e976b7b5955874c9b54/workers/docker-worker/schemas/v1/payload.json" ) r.raise_for_status() payload_schema = r.json() jobs = [ "lint", "manifest_upload", "resources_unittest", "tools_unittest", "wpt_integration", "wptrunner_infrastructure", "wptrunner_unittest" ] for filename in ["pr_event.json", "master_push_event.json"]: with open(data_path(filename), encoding="utf8") as f: event = json.load(f) with mock.patch("tools.ci.tc.decision.get_fetch_rev", return_value=(None, event["after"], None)): with mock.patch("tools.ci.tc.decision.get_run_jobs", return_value=set(jobs)): task_id_map = decide(event) for name, (task_id, task_data) in task_id_map.items(): try: validate(instance=task_data, schema=create_task_schema) validate(instance=task_data["payload"], schema=payload_schema) except Exception as e: print("Validation failed for task '%s':\n%s" % (name, json.dumps(task_data, indent=2))) raise e