Skip to content

Commit 3aeaeb6

Browse files
committed
Exclude running some tests for specific packages
1 parent 7f8182f commit 3aeaeb6

File tree

2 files changed

+70
-20
lines changed

2 files changed

+70
-20
lines changed

alts/shared/utils/file_utils.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import hashlib
22

3+
import requests
4+
35

46
def get_hasher(checksum_type):
57
"""
@@ -56,3 +58,25 @@ def feed_hasher(_fd):
5658
file_path.seek(0)
5759
feed_hasher(file_path)
5860
return hasher.hexdigest()
61+
62+
63+
def file_url_exists(url):
64+
65+
"""
66+
Check if a file exists at the specified URL using a HEAD request.
67+
68+
Parameters
69+
----------
70+
url : str
71+
The URL to check.
72+
73+
Returns
74+
-------
75+
bool
76+
True if the file exists, False otherwise.
77+
"""
78+
try:
79+
response = requests.head(url)
80+
return response.status_code == 200
81+
except requests.RequestException as e:
82+
return False

alts/worker/tasks.py

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# created: 2021-04-13
44

55
"""AlmaLinux Test System package testing tasks running."""
6-
76
import logging
87
import traceback
98
import random
@@ -25,6 +24,7 @@
2524
from urllib3 import Retry
2625
from urllib3.exceptions import TimeoutError
2726

27+
from alts.shared.utils.file_utils import file_url_exists
2828
from alts.shared.constants import API_VERSION, DEFAULT_REQUEST_TIMEOUT
2929
from alts.shared.exceptions import (
3030
InstallPackageError,
@@ -120,6 +120,9 @@ def is_success(stage_data_: dict):
120120
return False
121121
return stage_data_['exit_code'] == 0
122122

123+
def should_skip_test(package, test_name, skipped_tests_map):
124+
return test_name in skipped_tests_map.get(package, []) if skipped_tests_map else False
125+
123126
def set_artifacts_when_stage_has_unexpected_exception(
124127
_artifacts: dict,
125128
error_message: str,
@@ -175,29 +178,52 @@ def set_artifacts_when_stage_has_unexpected_exception(
175178
module_name = task_params.get('module_name')
176179
module_stream = task_params.get('module_stream')
177180
module_version = task_params.get('module_version')
181+
182+
def get_excluded_packages():
183+
uri = 'https://git.almalinux.org/almalinux/alts-exclusions/raw/branch/main/skipped_tests.json'
184+
try:
185+
response = requests.get(uri)
186+
response.raise_for_status()
187+
return response.json()
188+
except requests.RequestException:
189+
return {}
190+
178191
try:
179192
# Wait a bit to not spawn all environments at once when
180193
# a lot of tasks are coming to the machine
181194
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)
195+
196+
test_steps = [
197+
("setup", runner.setup, [], {}),
198+
("run_system_info_commands", runner.run_system_info_commands, [], {}),
199+
("install_package", runner.install_package, [
200+
package_name
201+
], {
202+
"package_version": package_version,
203+
"package_epoch": package_epoch,
204+
"module_name": module_name,
205+
"module_stream": module_stream,
206+
"module_version": module_version,
207+
"semi_verbose": True,
208+
}),
209+
("run_package_integrity_tests", runner.run_package_integrity_tests, [
210+
package_name, package_version
211+
], {}),
212+
("run_third_party_tests", runner.run_third_party_tests, [
213+
package_name
214+
], {
215+
"package_version": package_version,
216+
"package_epoch": package_epoch,
217+
}),
218+
("uninstall_package", runner.uninstall_package, [package_name], {})
219+
]
220+
221+
for test_name, func, args, kwargs in test_steps:
222+
if test_name == "run_package_integrity_tests" and not CONFIG.enable_integrity_tests:
223+
continue
224+
if should_skip_test(package_name, test_name, get_excluded_packages()):
225+
continue
226+
func(*args, **kwargs)
201227
except VMImageNotFound as exc:
202228
logging.exception('Cannot find VM image: %s', exc)
203229
except WorkDirPreparationError:

0 commit comments

Comments
 (0)