def test_land_pr_after_status_change(env, git_gecko, git_wpt, hg_gecko_upstream, upstream_gecko_commit): bug = "1234" test_changes = {"README": "Change README\n"} rev = upstream_gecko_commit(test_changes=test_changes, bug=bug, message="Change README") update_repositories(git_gecko, git_wpt, wait_gecko_commit=rev) pushed, landed, failed = upstream.gecko_push(git_gecko, git_wpt, "autoland", rev, raise_on_error=True) syncs = upstream.UpstreamSync.for_bug(git_gecko, git_wpt, bug) assert syncs.keys() == ["open"] assert len(syncs["open"]) == 1 sync = syncs["open"].pop() env.gh_wpt.get_pull(sync.pr).mergeable = True env.gh_wpt.set_status(sync.pr, "failure", "http://test/", "tests failed", "continuous-integration/travis-ci/pr") with SyncLock("upstream", None) as lock: with sync.as_mut(lock): upstream.commit_status_changed( git_gecko, git_wpt, sync, "continuous-integration/travis-ci/pr", "failure", "http://test/", sync.wpt_commits.head.sha1) assert sync.last_pr_check == { "state": "failure", "sha": sync.wpt_commits.head.sha1 } hg_gecko_upstream.bookmark("mozilla/central", "-r", rev) update_repositories(git_gecko, git_wpt, wait_gecko_commit=rev) pushed, landed, failed = upstream.gecko_push(git_gecko, git_wpt, "mozilla-central", rev, raise_on_error=True) env.gh_wpt.set_status(sync.pr, "success", "http://test/", "tests failed", "continuous-integration/travis-ci/pr") with SyncLock("upstream", None) as lock: with sync.as_mut(lock): upstream.commit_status_changed( git_gecko, git_wpt, sync, "continuous-integration/travis-ci/pr", "success", "http://test/", sync.wpt_commits.head.sha1) assert sync.last_pr_check == { "state": "success", "sha": sync.wpt_commits.head.sha1 } assert sync.gecko_landed() assert sync.status == "wpt-merged"
def test_land_pr_after_status_change(env, git_gecko, git_wpt, hg_gecko_upstream, upstream_gecko_commit, set_pr_status): bug = 1234 test_changes = {"README": b"Change README\n"} rev = upstream_gecko_commit(test_changes=test_changes, bug=bug, message=b"Change README") update_repositories(git_gecko, git_wpt, wait_gecko_commit=rev) pushed, landed, failed = upstream.gecko_push(git_gecko, git_wpt, "autoland", rev, raise_on_error=True) syncs = upstream.UpstreamSync.for_bug(git_gecko, git_wpt, bug) assert list(syncs.keys()) == ["open"] assert len(syncs["open"]) == 1 sync = syncs["open"].pop() env.gh_wpt.get_pull(sync.pr).mergeable = True set_pr_status(sync.pr, "failure") with SyncLock("upstream", None) as lock: with sync.as_mut(lock): upstream.commit_check_changed(git_gecko, git_wpt, sync) pr = env.gh_wpt.get_pull(sync.pr) assert sync.last_pr_check == { "state": "failure", "sha": pr._commits[-1].sha } hg_gecko_upstream.bookmark("mozilla/central", "-r", rev) update_repositories(git_gecko, git_wpt, wait_gecko_commit=rev) pushed, landed, failed = upstream.gecko_push(git_gecko, git_wpt, "mozilla-central", rev, raise_on_error=True) set_pr_status(sync.pr, "success") with SyncLock("upstream", None) as lock: with sync.as_mut(lock): upstream.commit_check_changed(git_gecko, git_wpt, sync) assert sync.last_pr_check == { "state": "success", "sha": pr._commits[-1].sha } assert sync.gecko_landed() assert sync.status == "wpt-merged"
def test_processname_seq_id(git_gecko, local_gecko_commit): process_name_no_seq_id = base.ProcessName("sync", "upstream", "1234", "0") with SyncLock("upstream", None) as lock: sync.SyncData.create(lock, git_gecko, process_name_no_seq_id, {"test": 1}) process_name_seq_id = base.ProcessName.with_seq_id(git_gecko, "sync", "upstream", "1234") assert process_name_seq_id.seq_id == 1
def test_ref_duplicate(git_gecko): def create_initial(): p = base.ProcessName("sync", "upstream", "1", "0") with SyncLock("upstream", None) as lock: sync.SyncData.create(lock, git_gecko, p, {"test": 1}) create_initial() # Ensure that the p object has been gc'd gc.collect() q = base.ProcessName("sync", "upstream", "1", "0") with pytest.raises(ValueError): with SyncLock("upstream", None) as lock: sync.SyncData.create(lock, git_gecko, q, {"test": 2})
def test_land_try(env, git_gecko, git_wpt, git_wpt_upstream, pull_request, set_pr_status, hg_gecko_try, mock_mach): pr = pull_request([(b"Test commit", { "README": b"example_change", "resources/testdriver_vendor.js": b"Some change" })]) head_rev = pr._commits[0]["sha"] trypush.Mach = mock_mach downstream.new_wpt_pr(git_gecko, git_wpt, pr) sync = set_pr_status(pr.number, "success") git_wpt_upstream.head.commit = head_rev git_wpt.remotes.origin.fetch() landing.wpt_push(git_gecko, git_wpt, [head_rev], create_missing=False) with SyncLock.for_process(sync.process_name) as downstream_lock: with sync.as_mut(downstream_lock): sync.data["force-metadata-ready"] = True tree.is_open = lambda x: True landing_sync = landing.update_landing(git_gecko, git_wpt) assert landing_sync is not None with SyncLock("landing", None) as lock: with landing_sync.as_mut(lock): worktree = landing_sync.gecko_worktree.get() # Check that files we shouldn't move aren't assert not os.path.exists( os.path.join(worktree.working_dir, env.config["gecko"]["path"]["wpt"], ".git")) with open( os.path.join(worktree.working_dir, env.config["gecko"]["path"]["wpt"], "resources/testdriver_vendor.js"), "rb") as f: assert f.read() == b"Initial testdriver_vendor\n" try_push = sync.latest_try_push assert try_push is None mach_command = mock_mach.get_log()[-1] assert mach_command["command"] == "mach" assert mach_command["args"] == ("try", "fuzzy", "-q", "web-platform-tests !ccov !shippable", "-q", "web-platform-tests linux-32 shippable", "-q", "web-platform-tests mac !debug shippable", "--disable-target-task-filter", "--artifact")
def test_try_push_retriggers_failures(git_gecko, git_wpt, landing_with_try_push, mock_tasks, env, mock_mach): # 20% failure rate, okay tasks = Mock(return_value=mock_tasks( failed=["foo"], completed=["bar", "baz", "boo", "faz"]) ) sync = landing_with_try_push try_push = sync.latest_try_push with SyncLock("landing", None) as lock: with sync.as_mut(lock), try_push.as_mut(lock): with patch.object(tc.TaskGroup, "tasks", property(tasks)): with patch('sync.trypush.auth_tc.retrigger', return_value=["job"] * trypush.TryPushTasks._retrigger_count): try_push.Mach = mock_mach with try_push.as_mut(lock): try_push["stability"] = True try_push.taskgroup_id = "12345678" landing.try_push_complete(git_gecko, git_wpt, try_push, sync) assert "Retriggered failing web-platform-test tasks" in env.bz.output.getvalue() assert try_push.status != "complete"
def landing_with_try_push(env, git_gecko, git_wpt, git_wpt_upstream, upstream_wpt_commit, MockTryCls, mock_mach): base_commit = git_wpt_upstream.head.commit new_commit = upstream_wpt_commit(b"First change", {"README": b"Example change\n"}) git_wpt.remotes.origin.fetch() with SyncLock("landing", None) as lock: landing_sync = landing.LandingSync.new(lock, git_gecko, git_wpt, base_commit.hexsha, new_commit.hexsha) with landing_sync.as_mut(lock): with patch("sync.tree.is_open", Mock(return_value=True)): try_push = trypush.TryPush.create(lock, landing_sync, hacks=False, try_cls=MockTryCls, exclude=["pgo", "ccov", "msvc"]) trypush.Mach = mock_mach tree.is_open = lambda x: True with try_push.as_mut(lock): try_push.taskgroup_id = "abcdef" return landing_sync
def create_initial(): p = base.ProcessName("sync", "upstream", "1", "0") with SyncLock("upstream", None) as lock: sync.SyncData.create(lock, git_gecko, p, {"test": 1})