diff --git a/test/test_tests_scan.py b/test/test_tests_scan.py index ee21228397..5f75be4a9c 100755 --- a/test/test_tests_scan.py +++ b/test/test_tests_scan.py @@ -195,6 +195,7 @@ def run_success_mock_pr(self, args: Sequence[str]) -> None: 'repo': self.repo, 'command_subject': None, 'report': None, + 'timeout': 120, 'secrets': ['github-token', 'image-download'], 'sha': self.revision, 'slug': f'pull-{self.pull_number}-{self.revision}-20240102-030405-fedora-nightly', @@ -271,6 +272,7 @@ def test_amqp_pr(self, mock_queue: unittest.mock.MagicMock) -> None: "sha": "abcdef", "slug": f"pull-{self.pull_number}-abcdef-20240102-030405-fedora-nightly", "command_subject": None, + "timeout": 120, "secrets": ["github-token", "image-download"], "env": { "BASE_BRANCH": "stable-1.0", @@ -311,6 +313,7 @@ def test_amqp_sha_nightly(self, mock_queue: unittest.mock.MagicMock) -> None: "labels": ["nightly"], }, "command_subject": None, + "timeout": 120, "secrets": ["github-token", "image-download"], "env": { "COCKPIT_BOTS_REF": "main", @@ -350,6 +353,7 @@ def test_anaconda_secrets(self, mock_queue: unittest.mock.MagicMock) -> None: "labels": ["nightly"], }, "command_subject": None, + "timeout": 120, "secrets": ["github-token", "image-download", "fedora-wiki", "fedora-wiki-staging"], "env": { "COCKPIT_BOTS_REF": "main", @@ -386,6 +390,7 @@ def test_amqp_sha_pr(self, mock_queue: unittest.mock.MagicMock) -> None: "sha": "abcdef", "slug": f"pull-{self.pull_number}-abcdef-20240102-030405-fedora-nightly", "command_subject": None, + "timeout": 120, "secrets": ["github-token", "image-download"], "env": { "BASE_BRANCH": "stable-1.0", @@ -435,6 +440,7 @@ def do_test_amqp_pr_cross_project( "report": None, "sha": "abcdef", "slug": f"pull-{self.pull_number}-abcdef-20240102-030405-fedora-nightly-{slug_repo_branch}", + "timeout": 120, "secrets": ["github-token", "image-download"], "env": { "BASE_BRANCH": branch, @@ -447,6 +453,36 @@ def do_test_amqp_pr_cross_project( }, } + @unittest.mock.patch("lib.distributed_queue.DistributedQueue") + def test_amqp_subman_rhel_goes_to_rhel_queue(self, mock_queue: unittest.mock.MagicMock) -> None: + args = ["--dry", "--context", "rhel-9-9/subscription-manager-1.29", + "--pull-number", "1", "--amqp", "amqp.example.com:1234"] + self.run_success(args, "") + + channel = mock_queue.return_value.__enter__.return_value.channel + channel.basic_publish.assert_called_once() + self.assertEqual(channel.basic_publish.call_args[0][1], "rhel") + + @unittest.mock.patch("lib.distributed_queue.DistributedQueue") + def test_amqp_subman_non_rhel_goes_to_public_queue(self, mock_queue: unittest.mock.MagicMock) -> None: + args = ["--dry", "--context", "fedora-41/subscription-manager-1.29", + "--pull-number", "1", "--amqp", "amqp.example.com:1234"] + self.run_success(args, "") + + channel = mock_queue.return_value.__enter__.return_value.channel + channel.basic_publish.assert_called_once() + self.assertEqual(channel.basic_publish.call_args[0][1], "public") + + @unittest.mock.patch("lib.distributed_queue.DistributedQueue") + def test_amqp_rhel_non_subman_goes_to_public_queue(self, mock_queue: unittest.mock.MagicMock) -> None: + args = ["--dry", "--context", "rhel-10-3", + "--pull-number", "1", "--amqp", "amqp.example.com:1234"] + self.run_success(args, "") + + channel = mock_queue.return_value.__enter__.return_value.channel + channel.basic_publish.assert_called_once() + self.assertEqual(channel.basic_publish.call_args[0][1], "public") + def test_amqp_sha_pr_cross_project_default_branch(self) -> None: """Default branch cross-project status event on PR""" diff --git a/tests-scan b/tests-scan index 35e0e33e76..0dc7007435 100755 --- a/tests-scan +++ b/tests-scan @@ -74,16 +74,11 @@ def build_policy(repo: str, requested_contexts: Collection[str]) -> Policy: return policy -def is_internal_context(context: str) -> bool: - for pattern in ["rhel"]: - if pattern in context: - return True - return False - - def queue_test(entry: QueueEntry, dq: distributed_queue.DistributedQueue) -> None: context = entry['job']['context'] - queue = 'rhel' if is_internal_context(context) else 'public' + repo = entry['job']['repo'] + is_subman = 'subscription-manager' in context or 'subscription-manager' in repo + queue = 'rhel' if is_subman and 'rhel' in context else 'public' priority = distributed_queue.MAX_PRIORITY if '/devel' in context else distributed_queue.BASELINE_PRIORITY properties = pika.BasicProperties(priority=priority) dq.channel.basic_publish('', queue, json.dumps(entry), properties=properties) @@ -285,6 +280,7 @@ def cockpit_tasks(api: github.GitHub, contexts: Sequence[str], opts: argparse.Na }, "command_subject": command_subject, "slug": slug, + "timeout": 120, "env": env, "secrets": secrets, },