From 1e991f552a17bee998c5ca4febc43644c512a0cf Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Mon, 7 Oct 2024 22:19:23 +0200 Subject: [PATCH] backend: fix copr-backend-unknown-resalloc-tickets And add a test-case now. --- backend/copr-backend.spec | 1 + backend/fake_executables | 0 .../copr-backend-unknown-resalloc-tickets.py | 5 +- .../tests/fake_executables/unknown_tickets/ps | 25 +++++++++ .../tests/test_unknown_resalloc_tickets.py | 51 +++++++++++++++++++ backend/tests/testlib/__init__.py | 36 ++++++++++++- 6 files changed, 116 insertions(+), 2 deletions(-) create mode 100755 backend/fake_executables create mode 100755 backend/tests/fake_executables/unknown_tickets/ps create mode 100644 backend/tests/test_unknown_resalloc_tickets.py diff --git a/backend/copr-backend.spec b/backend/copr-backend.spec index 74dc57a16..1a449ec2c 100644 --- a/backend/copr-backend.spec +++ b/backend/copr-backend.spec @@ -59,6 +59,7 @@ BuildRequires: python3-zstandard BuildRequires: python3-cachetools BuildRequires: modulemd-tools >= 0.6 BuildRequires: prunerepo >= %prunerepo_version +BuildRequires: resalloc-server BuildRequires: dnf Requires: (copr-selinux if selinux-policy-targeted) diff --git a/backend/fake_executables b/backend/fake_executables new file mode 100755 index 000000000..e69de29bb diff --git a/backend/run/copr-backend-unknown-resalloc-tickets.py b/backend/run/copr-backend-unknown-resalloc-tickets.py index f54fca191..65abb8f31 100755 --- a/backend/run/copr-backend-unknown-resalloc-tickets.py +++ b/backend/run/copr-backend-unknown-resalloc-tickets.py @@ -20,6 +20,7 @@ from copr_common.helpers import script_requires_user + def used_ids(): """ Return a `set()` of ticket IDs currently in use by @@ -34,7 +35,8 @@ def used_ids(): output = output.strip() tickets = set() for ticket_id in output.split("\n"): - if ticket_id: # ignore empty lines + ticket_id = ticket_id.strip() + if not ticket_id: # ignore empty lines continue assert ticket_id.isdigit() tickets.add(int(ticket_id)) @@ -64,6 +66,7 @@ def print_once(message): print(message) storage[message] = True + def _main(): script_requires_user("resalloc") diff --git a/backend/tests/fake_executables/unknown_tickets/ps b/backend/tests/fake_executables/unknown_tickets/ps new file mode 100755 index 000000000..f3c59168b --- /dev/null +++ b/backend/tests/fake_executables/unknown_tickets/ps @@ -0,0 +1,25 @@ +#! /bin/sh + +cat <