Skip to content

Commit

Permalink
tests-scan: re-enable cross-project 'job' creation
Browse files Browse the repository at this point in the history
Use the new 'command-subject' support in job-runner to bring back
cross-project support for creating 'Job' objects.

Co-authored-by: Martin Pitt <martin@piware.de>
  • Loading branch information
allisonkarlitskaya and martinpitt committed Mar 12, 2024
1 parent 4279386 commit 3f0c87c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
23 changes: 21 additions & 2 deletions test/test_tests_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def test_amqp_pr(self, mock_queue, _mock_strftime):
"report": None,
"sha": "abcdef",
"slug": f"pull-{self.pull_number}-abcdef-20240102-030405-fedora-nightly",
"command-subject": None,
"secrets": ["github-token", "image-download"],
"env": {
"BASE_BRANCH": "stable-1.0",
Expand Down Expand Up @@ -333,6 +334,7 @@ def test_amqp_sha_nightly(self, mock_queue, _mock_strftime):
"title": "Tests failed on 9988aa",
"labels": ["nightly"],
},
"command-subject": None,
"secrets": ["github-token", "image-download"],
"env": {
"COCKPIT_BOTS_REF": "main",
Expand Down Expand Up @@ -383,6 +385,7 @@ def test_amqp_sha_pr(self, mock_queue, _mock_strftime):
"report": None,
"sha": "abcdef",
"slug": f"pull-{self.pull_number}-abcdef-20240102-030405-fedora-nightly",
"command-subject": None,
"secrets": ["github-token", "image-download"],
"env": {
"BASE_BRANCH": "stable-1.0",
Expand Down Expand Up @@ -427,14 +430,30 @@ def do_test_amqp_pr_cross_project(self, status_branch, mock_queue, _mock_strftim
f'cd make-checkout-workdir && TEST_OS=fedora BASE_BRANCH={branch} COCKPIT_BOTS_REF=main '
'TEST_SCENARIO=nightly ../tests-invoke --pull-number 1 --revision abcdef --repo project/repo"')

slug_repo_branch = repo_branch.replace('@', '-').replace('/', '-')

assert request == {
"command": expected_command,
"type": "test",
"sha": "abcdef",
"ref": branch,
"name": f"pull-{self.pull_number}",
# job-runner currently disabled for cross-project tests (commit c377eb892)
"job": None,
"job": {
"context": f"fedora/nightly@{repo_branch}",
"repo": "project/repo",
"pull": int(self.pull_number),
"report": None,
"sha": "abcdef",
"slug": f"pull-{self.pull_number}-abcdef-20240102-030405-fedora-nightly-{slug_repo_branch}",
"command-subject": {"repo": "cockpit-project/cockpituous", "branch": branch},
"secrets": ["github-token", "image-download"],
"env": {
"BASE_BRANCH": branch,
"COCKPIT_BOTS_REF": "main",
"TEST_OS": "fedora",
"TEST_SCENARIO": "nightly",
}
}
}

def test_amqp_sha_pr_cross_project_default_branch(self):
Expand Down
8 changes: 5 additions & 3 deletions tests-scan
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ def queue_test(job: Job, channel, options: argparse.Namespace) -> None:
"sha": job.revision,
"ref": job.ref,
"name": job.name,

# job-runner doesn't support this yet...
"job": None if job.repo != options.repo else {
"job": {
"repo": options.repo,
"sha": job.revision,
"context": job.github_context,
Expand All @@ -236,6 +234,10 @@ def queue_test(job: Job, channel, options: argparse.Namespace) -> None:
"title": f"Tests failed on {job.revision}",
"labels": ["nightly"],
},
"command-subject": None if job.repo == options.repo else {
"repo": job.repo,
"branch": job.ref,
},
"slug": slug,
"env": env,
# for updating naughty trackers and downloading private images
Expand Down

0 comments on commit 3f0c87c

Please sign in to comment.