forked from fedora-copr/copr
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backend: fix copr-backend-unknown-resalloc-tickets
And add a test-case now.
- Loading branch information
Showing
5 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#! /bin/sh | ||
|
||
cat <<EOF | ||
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | ||
root 1 0.2 0.0 76688 27632 ? Ss Aug20 164:48 /usr/lib/systemd/systemd --switched-root --system --deserialize=32 | ||
root 2 0.0 0.0 0 0 ? S Aug20 0:19 [kthreadd] | ||
root 3 0.0 0.0 0 0 ? S Aug20 0:00 [pool_workqueue_release] | ||
copr 25312 0.2 0.1 575840 114196 ? Sl 07:12 0:12 Builder for task 8112858-fedora-40-x86_64: Job 8112858-fedora-40-x86_64, host info: ResallocHost, ticket_id=5273994, hostname=2620:52:3:1:dead:beef:cafe:c197 (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112858 --chroot fedora-40-x86_64 --worker-id rpm_build_worker:8112858-fedora-40-x86_64) | ||
copr 25314 0.2 0.1 575840 114580 ? Sl 07:12 0:12 Builder for task 8112859-fedora-rawhide-x86_64: Job 8112859-fedora-rawhide-x86_64, host info: ResallocHost, ticket_id=5273992, hostname=2620:52:3:1:dead:beef:cafe:c15b (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112859 --chroot fedora-rawhide-x86_64 --worker-id rpm_build_worker:8112859-fedora-rawhide-x86_64) | ||
copr 25332 0.2 0.1 575832 113908 ? Sl 07:12 0:12 Builder for task 8112858-fedora-rawhide-x86_64: Job 8112858-fedora-rawhide-x86_64, host info: ResallocHost, ticket_id=5273997, hostname=2620:52:3:1:dead:beef:cafe:c192 (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112858 --chroot fedora-rawhide-x86_64 --worker-id rpm_build_worker:8112858-fedora-rawhide-x86_64) | ||
copr 25358 0.2 0.1 575840 114256 ? Sl 07:12 0:12 Builder for task 8112858-fedora-41-x86_64: Job 8112858-fedora-41-x86_64, host info: ResallocHost, ticket_id=5274000, hostname=2620:52:3:1:dead:beef:cafe:c1da (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112858 --chroot fedora-41-x86_64 --worker-id rpm_build_worker:8112858-fedora-41-x86_64) | ||
copr 25362 0.2 0.1 575828 114220 ? Sl 07:12 0:12 Builder for task 8112858-fedora-39-x86_64: Job 8112858-fedora-39-x86_64, host info: ResallocHost, ticket_id=5273999, hostname=2620:52:3:1:dead:beef:cafe:c1d8 (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112858 --chroot fedora-39-x86_64 --worker-id rpm_build_worker:8112858-fedora-39-x86_64) | ||
copr 26017 0.0 0.0 11720 8064 ? S 07:12 0:00 ssh -F /home/copr/.ssh/config mockbuilder@2620:52:3:1:dead:beef:cafe:c15b copr-rpmbuild-log | ||
copr 26055 0.0 0.0 11724 7880 ? S 07:12 0:00 ssh -F /home/copr/.ssh/config mockbuilder@2620:52:3:1:dead:beef:cafe:c1da copr-rpmbuild-log | ||
copr 26059 0.0 0.0 11724 7800 ? S 07:12 0:00 ssh -F /home/copr/.ssh/config mockbuilder@2620:52:3:1:dead:beef:cafe:c1d8 copr-rpmbuild-log | ||
copr 26061 0.0 0.0 11724 7476 ? S 07:12 0:00 ssh -F /home/copr/.ssh/config mockbuilder@2620:52:3:1:dead:beef:cafe:c192 copr-rpmbuild-log | ||
copr 166357 0.1 0.1 575832 114212 ? Sl 07:46 0:07 Builder for task 8112918-fedora-41-ppc64le: Job 8112918-fedora-41-ppc64le, host info: ResallocHost, ticket_id=5274329, hostname=2620:52:3:1:dead:beef:cafe:c20e (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112918 --chroot fedora-41-ppc64le --worker-id rpm_build_worker:8112918-fedora-41-ppc64le) | ||
root 300588 0.0 0.0 0 0 ? I 08:23 0:01 [kworker/u33:5-btrfs-delalloc] | ||
copr 414485 0.4 0.1 575828 114420 ? Sl 08:45 0:01 Builder for task 8112989-epel-9-aarch64: Job 8112989-epel-9-aarch64, host info: ResallocHost, ticket_id=5274764, hostname=50.17.171.12 (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112989 --chroot epel-9-aarch64 --worker-id rpm_build_worker:8112989-epel-9-aarch64) | ||
copr 414486 0.4 0.1 575828 114432 ? Sl 08:45 0:01 Builder for task 8112989-epel-9-x86_64: Job 8112989-epel-9-x86_64, host info: ResallocHost, ticket_id=5274768, hostname=2620:52:3:1:dead:beef:cafe:c150 (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112989 --chroot epel-9-x86_64 --worker-id rpm_build_worker:8112989-epel-9-x86_64) | ||
copr 414526 0.4 0.1 575840 114448 ? Sl 08:45 0:01 Builder for task 8112989-fedora-41-x86_64: Job 8112989-fedora-41-x86_64, host info: ResallocHost, ticket_id=5274772, hostname=2620:52:3:1:dead:beef:cafe:c154 (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112989 --chroot fedora-41-x86_64 --worker-id rpm_build_worker:8112989-fedora-41-x86_64) | ||
copr 414573 0.4 0.1 575832 114104 ? Sl 08:45 0:02 Builder for task 8112989-fedora-39-x86_64: Job 8112989-fedora-39-x86_64, host info: ResallocHost, ticket_id=5274773, hostname=2620:52:3:1:dead:beef:cafe:c112 (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112989 --chroot fedora-39-x86_64 --worker-id rpm_build_worker:8112989-fedora-39-x86_64) | ||
copr 414574 0.3 0.1 575700 114300 ? Sl 08:45 0:01 Builder for task 8112989-epel-8-s390x: Job 8112989-epel-8-s390x, host info: ResallocHost, ticket_id=5274775, hostname=150.239.87.207 (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112989 --chroot epel-8-s390x --worker-id rpm_build_worker:8112989-epel-8-s390x) | ||
copr 414575 0.3 0.1 575700 114064 ? Sl 08:45 0:01 Builder for task 8112989-fedora-41-s390x: Job 8112989-fedora-41-s390x, host info: ResallocHost, ticket_id=5274774, hostname=169.59.165.222 (command: /usr/bin/copr-backend-process-build --daemon --build-id 8112989 --chroot fedora-41-s390x --worker-id rpm_build_worker:8112989-fedora-41-s390x) | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
""" | ||
Test the ./run/copr-backend-unknown-resalloc-tickets.py script | ||
""" | ||
|
||
import contextlib | ||
import importlib | ||
import io | ||
from unittest import mock | ||
|
||
from testlib import patch_path_run, patch_path_fake_executables, patch_getpwuid | ||
|
||
SCRIPT_NAME = 'copr-backend-unknown-resalloc-tickets.py' | ||
SPEC = importlib.util.spec_from_file_location("spec", "run/" + SCRIPT_NAME) | ||
SCRIPT = importlib.util.module_from_spec(SPEC) | ||
SPEC.loader.exec_module(SCRIPT) | ||
|
||
EXPECTED_TICKETS = {5273992, 5273994, 5273997, 5273999, 5274000, 5274329, | ||
5274764, 5274768, 5274772, 5274773, 5274774, 5274775} | ||
|
||
|
||
def main_output(ids): | ||
with mock.patch.object(SCRIPT, "all_ids", return_value=ids): | ||
f = io.StringIO() | ||
with contextlib.redirect_stdout(f): | ||
SCRIPT._main() # pylint: disable=protected-access | ||
return f.getvalue() | ||
|
||
|
||
@patch_path_run | ||
@patch_path_fake_executables("unknown_tickets") | ||
@patch_getpwuid("resalloc") | ||
def test_unknown_tickets(): | ||
# not ticket found in DB | ||
assert main_output({}) == "no tickets taken\n" | ||
assert SCRIPT.used_ids() == EXPECTED_TICKETS | ||
|
||
# no unused ticket | ||
assert main_output(EXPECTED_TICKETS) == "" | ||
|
||
assert main_output(EXPECTED_TICKETS | {1}) == """\ | ||
These are old tickets, Copr only uses newer tickets, close them: | ||
resalloc ticket-close 1 | ||
""" | ||
assert main_output(EXPECTED_TICKETS | {6000000}) == """\ | ||
These tickets are relatively new for closing blindly, double check! | ||
resalloc ticket-check 6000000 | ||
""" | ||
assert main_output(EXPECTED_TICKETS | {1, 6000000}) == """\ | ||
resalloc ticket-close 1 | ||
resalloc ticket-check 6000000 | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters