Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions test/test_tests_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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"""

Expand Down
12 changes: 4 additions & 8 deletions tests-scan
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to discuss this, there is a pull request to get rid of this.

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)
Expand Down Expand Up @@ -285,6 +280,7 @@ def cockpit_tasks(api: github.GitHub, contexts: Sequence[str], opts: argparse.Na
},
"command_subject": command_subject,
"slug": slug,
"timeout": 120,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda long, but lets keep the old timeout alive for now.

"env": env,
"secrets": secrets,
},
Expand Down
Loading