Import from CS git

This commit is contained in:
eabdullin 2025-06-24 11:34:57 +00:00
parent 5bdc5cf293
commit b71dc1da3a
7 changed files with 10454 additions and 1 deletions

View File

@ -0,0 +1,91 @@
From 397975d6b63ff70755ea41b8ec8fc413966218e4 Mon Sep 17 00:00:00 2001
From: Petr Stodulka <pstodulk@redhat.com>
Date: Fri, 30 May 2025 14:13:35 +0200
Subject: [PATCH 38/43] Makefile: Non-zero exit code on failed tests in
container
Previously all exit codes from execution of tests inside
container have been ignored and make command ended with zero always.
Also drop testing of el7toel8 repository for Python 3.6 on RHEL 8.
The test started to fail for unknown reason (changes in pytest or
another nonstandard python module?). As we are in the middle of
dropping all el7toel8 and python2 related content, let's just drop
it. Keeping the full removal of Py2 and el7toel8 content on separate
PR.
---
Makefile | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
index ceb013ab..6769b2f3 100644
--- a/Makefile
+++ b/Makefile
@@ -164,9 +164,9 @@ help:
@echo " PR=7 SUFFIX='my_additional_suffix' make <target>"
@echo " MR=6 COPR_CONFIG='path/to/the/config/copr/file' make <target>"
@echo " ACTOR=<actor> TEST_LIBS=y make test"
- @echo " BUILD_CONTAINER=el7 make build_container"
+ @echo " BUILD_CONTAINER=rhel8 make build_container"
@echo " TEST_CONTAINER=f34 make test_container"
- @echo " CONTAINER_TOOL=docker TEST_CONTAINER=rhel7 make test_container_no_lint"
+ @echo " CONTAINER_TOOL=docker TEST_CONTAINER=rhel8 make test_container_no_lint"
@echo ""
clean:
@@ -459,30 +459,33 @@ test_container:
$(_CONTAINER_TOOL) ps -q -f name=$$_CONT_NAME && { $(_CONTAINER_TOOL) kill $$_CONT_NAME; $(_CONTAINER_TOOL) rm $$_CONT_NAME; }; \
$(_CONTAINER_TOOL) run -di --name $$_CONT_NAME -v "$$PWD":/repo:Z -e PYTHON_VENV=$$_VENV $$TEST_IMAGE && \
$(_CONTAINER_TOOL) exec $$_CONT_NAME rsync -aur --delete --exclude "tut*" /repo/ /repocopy && \
+ export res=0; \
case $$_VENV in \
python2.7) \
- TEST_CONT_IPU=el7toel8 $(MAKE) _test_container_ipu; \
+ TEST_CONT_IPU=el7toel8 $(MAKE) _test_container_ipu || res=1; \
;;\
python3.6) \
- TEST_CONT_IPU=el7toel8 $(MAKE) _test_container_ipu; \
- TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu; \
+ echo "INFO: Skipping testing of el7toel8 repository. Obsoleted"; \
+ TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu || res=1; \
;; \
python3.9) \
- TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu; \
- TEST_CONT_IPU=el9toel10 $(MAKE) _test_container_ipu; \
+ TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu || res=1; \
+ TEST_CONT_IPU=el9toel10 $(MAKE) _test_container_ipu || res=1; \
;; \
python3.12) \
- TEST_CONT_IPU=el9toel10 $(MAKE) _test_container_ipu; \
+ TEST_CONT_IPU=el9toel10 $(MAKE) _test_container_ipu || res=1; \
;; \
*) \
- TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu; \
- ;;\
+ TEST_CONT_IPU=el8toel9 $(MAKE) _test_container_ipu || res=1; \
+ ;; \
esac; \
$(_CONTAINER_TOOL) kill $$_CONT_NAME; \
- $(_CONTAINER_TOOL) rm $$_CONT_NAME
+ $(_CONTAINER_TOOL) rm $$_CONT_NAME; \
+ [ $$res -ne 0 ] && echo "TIP: If you do not see an error in the end of logs, scroll up. Multiple tests could be executed." ; \
+ exit $$res
test_container_all:
- @for container in "f34" "rhel7" "rhel8"; do \
+ @for container in "f34" "rhel7" "rhel8" "rhel9"; do \
TEST_CONTAINER=$$container $(MAKE) test_container || exit 1; \
done
@@ -490,7 +493,7 @@ test_container_no_lint:
@_TEST_CONT_TARGET="test_no_lint" $(MAKE) test_container
test_container_all_no_lint:
- @for container in "f34" "rhel7" "rhel8"; do \
+ @for container in "f34" "rhel7" "rhel8" "rhel9"; do \
TEST_CONTAINER=$$container $(MAKE) test_container_no_lint || exit 1; \
done
--
2.49.0

View File

@ -0,0 +1,82 @@
From 4e87908b2e17d87b69bcec29ba1e9b777439a0fe Mon Sep 17 00:00:00 2001
From: Petr Stodulka <pstodulk@redhat.com>
Date: Fri, 30 May 2025 15:02:53 +0200
Subject: [PATCH 39/43] CI: Unit-tests: Rename tasks & tests executions
Previous name have been very long, repeating, and it has been
problem to read the whole informatino about what tests are performed
as the description has been shortened in WebUI, e.g.:
Unit Tests / Run unit tests in containers (Run python linters for el8toel9 and common repositories on p...
Let's change the name so it's shortened and easier read what test
has been actually performed. Also, no need to mention that tests are
running in container anymore, as we are not running unit-tests outside
of the container in upstream. Example of new style names:
Unit Tests / Run: Linters (python:3.9; repos:el9toel10,common) (pull_request)
Unit Tests / Run: Unit Tests (python:3.9; repos:el9toel10,common) (pull_request)
---
.github/workflows/unit-tests.yml | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
index 37748396..ed82e0e5 100644
--- a/.github/workflows/unit-tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -9,43 +9,43 @@ on:
jobs:
test:
- name: Run unit tests in containers
+ name: 'Run: ${{ matrix.scenarios.name }}'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
scenarios:
# 9to10
- - name: Run unit tests for el9toel10 and common repositories on python 3.12
+ - name: 'Unit tests (python:3.12; repos:el9toel10,common)'
python: python3.12
repos: 'el9toel10,common'
container: ubi9
- - name: Run python linters for el9toel10 and common repositories on python 3.12
+ - name: 'Linters (python:3.12; repos:el9toel10,common)'
python: python3.12
repos: 'el9toel10,common'
container: ubi9-lint
- - name: Run unit tests for el9toel10 and common repositories on python 3.9
+ - name: 'Unit tests (python:3.9; repos:el9toel10,common)'
python: python3.9
repos: 'el9toel10,common'
container: ubi9
- - name: Run python linters for el9toel10 and common repositories on python 3.9
+ - name: 'Linters (python:3.9; repos:el9toel10,common)'
python: python3.9
repos: 'el9toel10,common'
container: ubi9-lint
# 8to9
- - name: Run unit tests for el8toel9 and common repositories on python 3.9
+ - name: 'Unit tests (python:3.9; repos:el8toel9,common)'
python: python3.9
repos: 'el8toel9,common'
container: ubi9
- - name: Run python linters for el8toel9 and common repositories on python 3.9
+ - name: 'Linters (python:3.9; repos:el8toel9,common)'
python: python3.9
repos: 'el8toel9,common'
container: ubi9-lint
- - name: Run unit tests for el8toel9 and common repositories on python 3.6
+ - name: 'Unit tests (python:3.6; repos:el8toel9,common)'
python: python3.6
repos: 'el8toel9,common'
container: ubi8
- - name: Run python linters for el8toel9 and common repositories on python 3.6
+ - name: 'Linters (python:3.6; repos:el8toel9,common)'
python: python3.6
repos: 'el8toel9,common'
container: ubi8-lint
--
2.49.0

View File

@ -0,0 +1,166 @@
From 2646484407bef15688fb4838c2f61d06f2098f81 Mon Sep 17 00:00:00 2001
From: Petr Stodulka <pstodulk@redhat.com>
Date: Wed, 30 Apr 2025 12:54:22 +0200
Subject: [PATCH 40/43] Fix parsing of the kernel cmdline
Original parsing has been splitting string tokens by "=" without a
limit, means that e.g.
root=UUID=some-id
has been split to
(root, UUID, some-id)
and and stored just "root" and "UUID" strings in the parsed msg,
instead of "root" and "UUID=some-id".
So split the key=value just based on the first occurence of "="
instead.
JIRA: RHELMISC-12490
Co-Authored-By: Karolina Kula <kkula@redhat.com>
---
.../common/actors/scankernelcmdline/actor.py | 16 ++---
.../libraries/scankernelcmdline.py | 23 +++++++
.../tests/test_scankernelcmdline.py | 67 +++++++++++++++++++
3 files changed, 94 insertions(+), 12 deletions(-)
create mode 100644 repos/system_upgrade/common/actors/scankernelcmdline/libraries/scankernelcmdline.py
create mode 100644 repos/system_upgrade/common/actors/scankernelcmdline/tests/test_scankernelcmdline.py
diff --git a/repos/system_upgrade/common/actors/scankernelcmdline/actor.py b/repos/system_upgrade/common/actors/scankernelcmdline/actor.py
index 9f8fef30..2f1a5ae2 100644
--- a/repos/system_upgrade/common/actors/scankernelcmdline/actor.py
+++ b/repos/system_upgrade/common/actors/scankernelcmdline/actor.py
@@ -1,12 +1,12 @@
from leapp.actors import Actor
-from leapp.libraries.stdlib import run
-from leapp.models import KernelCmdline, KernelCmdlineArg
+from leapp.libraries.actor import scankernelcmdline
+from leapp.models import KernelCmdline
from leapp.tags import FactsPhaseTag, IPUWorkflowTag
class ScanKernelCmdline(Actor):
"""
- No documentation has been provided for the scan_kernel_cmdline actor.
+ Scan the kernel command line of the booted system.
"""
name = 'scan_kernel_cmdline'
@@ -15,12 +15,4 @@ class ScanKernelCmdline(Actor):
tags = (FactsPhaseTag, IPUWorkflowTag)
def process(self):
- cmdline = run(['cat', '/proc/cmdline'])['stdout'].strip()
- parameters = []
- for parameter in cmdline.split(' '):
- if '=' in parameter:
- kv = parameter.split('=')
- parameters.append(KernelCmdlineArg(key=kv[0], value=kv[1]))
- else:
- parameters.append(KernelCmdlineArg(key=parameter))
- self.produce(KernelCmdline(parameters=parameters))
+ scankernelcmdline.parse_cmdline_input()
diff --git a/repos/system_upgrade/common/actors/scankernelcmdline/libraries/scankernelcmdline.py b/repos/system_upgrade/common/actors/scankernelcmdline/libraries/scankernelcmdline.py
new file mode 100644
index 00000000..9cffa70e
--- /dev/null
+++ b/repos/system_upgrade/common/actors/scankernelcmdline/libraries/scankernelcmdline.py
@@ -0,0 +1,23 @@
+from leapp.libraries.stdlib import api, CalledProcessError, run
+from leapp.models import KernelCmdline, KernelCmdlineArg
+
+
+def get_cmdline_input():
+ try:
+ cmdline_input = run(['cat', '/proc/cmdline'])['stdout'].strip()
+ return cmdline_input
+ except (OSError, CalledProcessError):
+ api.current_logger().debug('Executing `cat /proc/cmdline` failed', exc_info=True)
+ return ''
+
+
+def parse_cmdline_input():
+ cmdline = get_cmdline_input()
+ parameters = []
+ for parameter in cmdline.split(' '):
+ if '=' in parameter:
+ kv = parameter.split('=', 1)
+ parameters.append(KernelCmdlineArg(key=kv[0], value=kv[1]))
+ else:
+ parameters.append(KernelCmdlineArg(key=parameter))
+ api.produce(KernelCmdline(parameters=parameters))
diff --git a/repos/system_upgrade/common/actors/scankernelcmdline/tests/test_scankernelcmdline.py b/repos/system_upgrade/common/actors/scankernelcmdline/tests/test_scankernelcmdline.py
new file mode 100644
index 00000000..ff79054f
--- /dev/null
+++ b/repos/system_upgrade/common/actors/scankernelcmdline/tests/test_scankernelcmdline.py
@@ -0,0 +1,67 @@
+import pytest
+
+from leapp.libraries.actor import scankernelcmdline
+from leapp.libraries.common.testutils import CurrentActorMocked, produce_mocked
+from leapp.libraries.stdlib import api, CalledProcessError
+from leapp.models import KernelCmdline, KernelCmdlineArg
+
+
+def mock_cmd_output():
+ expected_cmd_output = (
+ 'BOOT_IMAGE=(hd0,msdos1)/vmlinuz-xxx root=UUID=some_uid ro console=tty0'
+ ' console=ttyS0,115200 rd_NO_PLYMOUTH biosdevname=0 net.ifnames=0 crashkernel=auto'
+ )
+ return expected_cmd_output
+
+
+def test_cmdline_output(monkeypatch):
+
+ monkeypatch.setattr(scankernelcmdline, 'get_cmdline_input', mock_cmd_output)
+ current_actor = CurrentActorMocked(src_ver='8.10', dst_ver='9.6')
+ monkeypatch.setattr(api, 'current_actor', current_actor)
+ monkeypatch.setattr(api, 'produce', produce_mocked())
+
+ scankernelcmdline.parse_cmdline_input()
+
+ expected_params = [KernelCmdlineArg(key=k, value=v) for k, v in [
+ ('BOOT_IMAGE', '(hd0,msdos1)/vmlinuz-xxx'),
+ ('root', 'UUID=some_uid'),
+ ('ro', None),
+ ('console', 'tty0'),
+ ('console', 'ttyS0,115200'),
+ ('rd_NO_PLYMOUTH', None),
+ ('biosdevname', '0'),
+ ('net.ifnames', '0'),
+ ('crashkernel', 'auto')]]
+
+ expected_output_msg = KernelCmdline(parameters=expected_params)
+ assert api.produce.model_instances
+ assert expected_output_msg == api.produce.model_instances[0]
+
+
+def test_cmdline_content(monkeypatch):
+
+ def run_mocked(cmd, **kwargs):
+ assert cmd == ['cat', '/proc/cmdline']
+ output = mock_cmd_output()
+ return {'stdout': output}
+
+ monkeypatch.setattr(scankernelcmdline, 'run', run_mocked)
+ cmd_output = scankernelcmdline.get_cmdline_input()
+ expected_cmd_output = mock_cmd_output()
+
+ assert cmd_output == expected_cmd_output
+
+
+@pytest.mark.parametrize('is_os_error', [True, False])
+def test_cmdline_run_failed(monkeypatch, is_os_error):
+
+ def run_mocked_error(cmd, **kwargs):
+ assert cmd == ['cat', '/proc/cmdline']
+ if is_os_error:
+ raise OSError('OSError raised')
+ raise CalledProcessError("CalledProcessError raised", cmd, "result")
+
+ monkeypatch.setattr(scankernelcmdline, 'run', run_mocked_error)
+ cmd_output = scankernelcmdline.get_cmdline_input()
+ assert cmd_output == ''
--
2.49.0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
From 6c205281850c28068edc7fc5ab453c65398b7054 Mon Sep 17 00:00:00 2001
From: Petr Stodulka <pstodulk@redhat.com>
Date: Fri, 30 May 2025 18:28:25 +0200
Subject: [PATCH 43/43] unit-tests: suppress deprecation warning for
is_rhel_alt()
The deprecation warning is not wanted in unit-tests. Supress it.
Signed-off-by: Petr Stodulka <pstodulk@redhat.com>
---
.../system_upgrade/common/libraries/config/tests/test_version.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/repos/system_upgrade/common/libraries/config/tests/test_version.py b/repos/system_upgrade/common/libraries/config/tests/test_version.py
index 420571c0..d51f8098 100644
--- a/repos/system_upgrade/common/libraries/config/tests/test_version.py
+++ b/repos/system_upgrade/common/libraries/config/tests/test_version.py
@@ -108,6 +108,7 @@ def test_matches_target_version(monkeypatch, result, version_list):
(False, '4.14.0-100.8.2.el8.x86_64', 'rhel', '8.1'),
(False, '4.14.0-100.8.2.el9.x86_64', 'rhel', '9.1'),
])
+@suppress_deprecation(version.is_rhel_alt)
def test_is_rhel_alt(monkeypatch, result, kernel, release_id, src_ver):
monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(src_ver=src_ver, kernel=kernel,
release_id=release_id))
--
2.49.0

View File

@ -52,7 +52,7 @@ py2_byte_compile "%1" "%2"}
Name: leapp-repository
Version: 0.22.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Repositories for leapp
License: ASL 2.0
@ -104,6 +104,13 @@ Patch0035: 0035-Add-official-Centos-Stream-9-and-10-RPM-GPG-keys.patch
Patch0036: 0036-Deprecate-is_rhel_alt-from-share-libraries.patch
Patch0037: 0037-data-update-data-files-stream-3.3-1380.patch
# CTC1 Candidate2
Patch0038: 0038-Makefile-Non-zero-exit-code-on-failed-tests-in-conta.patch
Patch0039: 0039-CI-Unit-tests-Rename-tasks-tests-executions.patch
Patch0040: 0040-Fix-parsing-of-the-kernel-cmdline.patch
Patch0041: 0041-repomap-Process-repositories-based-on-distro.patch
Patch0042: 0042-Update-the-upgrade-data-files-stream-4.0.patch
Patch0043: 0043-unit-tests-suppress-deprecation-warning-for-is_rhel_.patch
%description
%{summary}
@ -308,6 +315,12 @@ Requires: libdb-utils
%patch -P 0035 -p1
%patch -P 0036 -p1
%patch -P 0037 -p1
%patch -P 0038 -p1
%patch -P 0039 -p1
%patch -P 0040 -p1
%patch -P 0041 -p1
%patch -P 0042 -p1
%patch -P 0043 -p1
%build
@ -389,6 +402,12 @@ done;
# no files here
%changelog
* Thu Jun 05 2025 Karolina Kula <kkula@redhat.com> - 0.22.0-4
- Fix parsing of the kernel cmdline
- Require leapp data with provided_data_streams 4.0+
- Resolves: RHEL-67627
* Wed May 14 2025 Petr Stodulka <pstodulk@redhat.com> - 0.22.0-3
- Rebuild