From 864e1fcdbbe05d21662ffab3b99d40ca0bcdb09b Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Oct 06 2020 15:03:44 +0000 Subject: Separate RPM installability test from rpm_tests tests/rpm_tests mostly inspects the built rpms, which neither requires any privileges nor apply any changes to the system. `InstallRPMTestCase` stands out, as it assumes that the installation happens in mock (which is not true any more when testing in containers or a local build environment). It also requires a lot of code/mechanics. Move the installability test into the `make test-rpm` top-level rule (which is the one called by Jenkins), and drop `InstallRPMTestCase`. Cherry-picked from master commit 0bf0c04e. Related: rhbz#1885635 --- diff --git a/Makefile.am b/Makefile.am index 703f714..9b4b998 100644 --- a/Makefile.am +++ b/Makefile.am @@ -309,12 +309,14 @@ test-gui: @mv .coverage.* tests/ $(MAKE) coverage-report +# this is the top-level rule called by Jenkins "Anaconda Rawhide test RPM files" job +# test RPM installability in addition to build and rpm_tests test-rpm: mock-rpms run-rpm-tests-only + mock -r $(MOCKCHROOT) $(MOCK_EXTRA_ARGS) --install $(RPM_BUILD_DIR)/*[0-9].rpm $(MAKE) grab-logs run-rpm-tests-only: - $(MAKE) TEST_SUITE_LOG=test-suite.log MOCKCHROOT=$(MOCKCHROOT) \ - MOCK_EXTRA_ARGS=$(MOCK_EXTRA_ARGS) RPM_PATH=$(RPM_BUILD_DIR) \ + $(MAKE) TEST_SUITE_LOG=test-suite.log RPM_PATH=$(RPM_BUILD_DIR) \ ROOT_ANACONDA_PATH=$(abs_srcdir) TESTS=rpm_tests.sh check coverage-report: diff --git a/tests/rpm_tests/__init__.py b/tests/rpm_tests/__init__.py index 7b0e083..65df229 100644 --- a/tests/rpm_tests/__init__.py +++ b/tests/rpm_tests/__init__.py @@ -6,8 +6,6 @@ import glob from unittest import TestCase -MOCK_NAME_ENV = "MOCKCHROOT" -MOCK_EXTRA_ARGS_ENV = "MOCK_EXTRA_ARGS" RPM_BUILD_DIR_ENV = "RPM_PATH" ROOT_DIR_ENV = "ROOT_ANACONDA_PATH" @@ -38,16 +36,6 @@ class RPMTestCase(TestCase): return subprocess.run(cmd, stdout=subprocess.PIPE, cwd=cwd) @property - def mock_name(self): - """Name of the mock from Makefile""" - return os.environ[MOCK_NAME_ENV] - - @property - def mock_extra_args(self): - """Extra arguments for mock from Makefile""" - return os.environ[MOCK_EXTRA_ARGS_ENV] - - @property def anaconda_root_path(self): """Root directory of tested anaconda from Makefile""" return os.environ[ROOT_DIR_ENV] @@ -60,24 +48,3 @@ class RPMTestCase(TestCase): """ rpm_path = os.environ[RPM_BUILD_DIR_ENV] return glob.glob(rpm_path + os.path.sep + "*[0-9].rpm") - - def run_mock(self, cmd): - """Run commands in mock - - Mock name and extra arguments are passed here from Makefile. - """ - mock_command = self._create_mock_command() - mock_command.extend(cmd) - self.check_subprocess(mock_command) - - def _create_mock_command(self): - output_cmd = ["mock", "-r", self.mock_name] - - if self.mock_extra_args: - output_cmd.append(self.mock_extra_args) - - return output_cmd - - def init_mock(self): - """Init mock before using it for tests.""" - self.run_mock(["--init"]) diff --git a/tests/rpm_tests/create_rpm_test.py b/tests/rpm_tests/create_rpm_test.py index e909a4f..6ee33fb 100644 --- a/tests/rpm_tests/create_rpm_test.py +++ b/tests/rpm_tests/create_rpm_test.py @@ -27,17 +27,6 @@ from tests.rpm_tests import RPMTestCase IGNORED_SOURCE_FILES = ["pyanaconda/ui/gui/spokes/blivet_gui.py"] -class InstallRPMTestCase(RPMTestCase): - """Test if Anaconda rpm files can be installed to the system.""" - - def test_install(self): - self.init_mock() - - mock_command = ["--install"] - mock_command.extend(self.rpm_paths) - self.run_mock(mock_command) - - class InstalledFilesTestCase(RPMTestCase): """Test if files in anaconda directory are correctly placed in the rpm files."""