|
3 | 3 | # created: 2021-04-13 |
4 | 4 |
|
5 | 5 | """AlmaLinux Test System package testing tasks running.""" |
6 | | - |
7 | 6 | import logging |
8 | 7 | import traceback |
9 | 8 | import random |
|
25 | 24 | from urllib3 import Retry |
26 | 25 | from urllib3.exceptions import TimeoutError |
27 | 26 |
|
| 27 | +from alts.shared.utils.file_utils import file_url_exists |
28 | 28 | from alts.shared.constants import API_VERSION, DEFAULT_REQUEST_TIMEOUT |
29 | 29 | from alts.shared.exceptions import ( |
30 | 30 | InstallPackageError, |
@@ -120,6 +120,12 @@ def is_success(stage_data_: dict): |
120 | 120 | return False |
121 | 121 | return stage_data_['exit_code'] == 0 |
122 | 122 |
|
| 123 | + def should_skip_test(package, test_name, skipped_tests_map): |
| 124 | + for pkg_pattern, tests in skipped_tests_map.items(): |
| 125 | + if package.startswith(pkg_pattern) and test_name in tests: |
| 126 | + return True |
| 127 | + return False |
| 128 | + |
123 | 129 | def set_artifacts_when_stage_has_unexpected_exception( |
124 | 130 | _artifacts: dict, |
125 | 131 | error_message: str, |
@@ -175,29 +181,52 @@ def set_artifacts_when_stage_has_unexpected_exception( |
175 | 181 | module_name = task_params.get('module_name') |
176 | 182 | module_stream = task_params.get('module_stream') |
177 | 183 | module_version = task_params.get('module_version') |
| 184 | + |
| 185 | + def get_excluded_packages(): |
| 186 | + uri = 'https://git.almalinux.org/almalinux/alts-exclusions/raw/branch/main/skipped_tests.json' |
| 187 | + try: |
| 188 | + response = requests.get(uri) |
| 189 | + response.raise_for_status() |
| 190 | + return response.json() |
| 191 | + except requests.RequestException: |
| 192 | + return {} |
| 193 | + |
178 | 194 | try: |
179 | 195 | # Wait a bit to not spawn all environments at once when |
180 | 196 | # a lot of tasks are coming to the machine |
181 | 197 | time.sleep(random.randint(5, 10)) |
182 | | - runner.setup() |
183 | | - runner.run_system_info_commands() |
184 | | - runner.install_package( |
185 | | - package_name, |
186 | | - package_version=package_version, |
187 | | - package_epoch=package_epoch, |
188 | | - module_name=module_name, |
189 | | - module_stream=module_stream, |
190 | | - module_version=module_version, |
191 | | - semi_verbose=True, |
192 | | - ) |
193 | | - if CONFIG.enable_integrity_tests: |
194 | | - runner.run_package_integrity_tests(package_name, package_version) |
195 | | - runner.run_third_party_tests( |
196 | | - package_name, |
197 | | - package_version=package_version, |
198 | | - package_epoch=package_epoch, |
199 | | - ) |
200 | | - runner.uninstall_package(package_name) |
| 198 | + |
| 199 | + test_steps = [ |
| 200 | + ("setup", runner.setup, [], {}), |
| 201 | + ("run_system_info_commands", runner.run_system_info_commands, [], {}), |
| 202 | + ("install_package", runner.install_package, [ |
| 203 | + package_name |
| 204 | + ], { |
| 205 | + "package_version": package_version, |
| 206 | + "package_epoch": package_epoch, |
| 207 | + "module_name": module_name, |
| 208 | + "module_stream": module_stream, |
| 209 | + "module_version": module_version, |
| 210 | + "semi_verbose": True, |
| 211 | + }), |
| 212 | + ("run_package_integrity_tests", runner.run_package_integrity_tests, [ |
| 213 | + package_name, package_version |
| 214 | + ], {}), |
| 215 | + ("run_third_party_tests", runner.run_third_party_tests, [ |
| 216 | + package_name |
| 217 | + ], { |
| 218 | + "package_version": package_version, |
| 219 | + "package_epoch": package_epoch, |
| 220 | + }), |
| 221 | + ("uninstall_package", runner.uninstall_package, [package_name], {}) |
| 222 | + ] |
| 223 | + packages_to_skip = get_excluded_packages() |
| 224 | + for test_name, func, args, kwargs in test_steps: |
| 225 | + if test_name == "run_package_integrity_tests" and not CONFIG.enable_integrity_tests: |
| 226 | + continue |
| 227 | + if should_skip_test(package_name, test_name, packages_to_skip): |
| 228 | + continue |
| 229 | + func(*args, **kwargs) |
201 | 230 | except VMImageNotFound as exc: |
202 | 231 | logging.exception('Cannot find VM image: %s', exc) |
203 | 232 | except WorkDirPreparationError: |
|
0 commit comments