Skip to content

Commit e2d9d73

Browse files
authored
Run heavy test cases on Saturdays only (#1142)
Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud>
1 parent d0892ae commit e2d9d73

7 files changed

Lines changed: 29 additions & 8 deletions

File tree

.zuul.d/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
preset: default
3434
iaas: true
3535
kaas: false
36+
section: ''
3637
do_provision: false
3738
do_cleanup: true
3839
sonobuoy_tar_gz_url: >
@@ -69,5 +70,6 @@
6970
preset: kaas
7071
iaas: false
7172
kaas: true
73+
section: '.auto' # only do 'heavy' tests on Saturdays
7274
do_provision: true
7375
do_cleanup: false

Standards/scs-0003-v1-sovereign-cloud-standards-yaml.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ The following fields are valid for every script descriptor:
197197

198198
| Key | Type | Description | Example |
199199
| ----------------- | ------ | ---------------------------------------------------------------------------------------------- | ---------- |
200-
| `section` | String | _Optional_ what section to associate this check with (sections can be checked in isolation) | `weekly` |
201200
| `testcases` | Array | List of all test cases; each entry being a test-case descriptor | (see below) |
202201

203202
Additional fields are valid depending on whether the check is automated or manual.
@@ -226,6 +225,7 @@ TBD
226225
| ----------------- | --------------- | ------------------------------------------------------------------------------------------------- | ----------------- |
227226
| `id` | String | Identifier for this test case (immutable and unique within this module) | `image-md-check` |
228227
| `lifetime` | String | One of: `day`, `week` (_default_), `month`, `quarter`, `year` | `day` |
228+
| `section` | String | _Optional_ what section to associate this testcase with (sections can be checked in isolation) | `weekly` |
229229
| `description` | String | Short description of the test case (markdown allowed, but keep it short for CLI users) | |
230230
| `url` | String | URL pointing to the relevant SCS documentation for the testcase | |
231231

Tests/scs-compatible-kaas.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,29 @@ scripts:
1717
testcases:
1818
- id: cncf-k8s-conformance
1919
lifetime: year
20+
section: heavy
2021
description: Must fulfill all requirements of _CNCF Kubernetes conformance_.
2122
url: https://github.com/cncf/k8s-conformance/tree/master
2223
- executable: ./kaas/k8s-version-policy/k8s_version_policy.py
2324
args: -k {kubeconfig}
2425
testcases:
2526
- id: version-policy-check
27+
section: light
2628
description: Must fulfill all requirements of scs-0210-v2.
2729
url: https://docs.scs.community/standards/scs-0210-v2-k8s-version-policy#decision
2830
- executable: ./kaas/k8s-node-distribution/k8s_node_distribution_check.py
2931
args: -k {kubeconfig}
3032
testcases:
3133
- id: node-distribution-check
34+
section: light
3235
description: Must fulfill all requirements of scs-0214-v2.
3336
url: https://docs.scs.community/standards/scs-0214-v2-k8s-node-distribution#decision
3437
- executable: ./kaas/sonobuoy_handler/run_sonobuoy.py
3538
args: run -k {kubeconfig} --scs-sonobuoy-config kaas/scs-sonobuoy-config.yaml -r {subject_root}/sono-results-0219 -c 'kaas-networking-check' -a '--e2e-focus "NetworkPolicy"' --execution-mode {execution_mode}
3639
testcases:
3740
- id: kaas-networking-check
41+
lifetime: month
42+
section: heavy
3843
description: Must fulfill all requirements of scs-0219-v1.
3944
url: https://docs.scs.community/standards/scs-0219-v1-kaas-networking#decision
4045
modules:

Tests/scs-compliance-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def main(argv):
339339
script = tc_script_lookup[tc_id]
340340
if 'executable' not in script:
341341
continue # manual check
342-
if config.sections and script.get('section') not in config.sections:
342+
if config.sections and testcase_lookup.get(tc_id, {}).get('section') not in config.sections:
343343
continue
344344
if config.tests and not config.tests.match(tc_id):
345345
continue

Tests/scs-test-runner.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#
66
# (c) Matthias Büchse <matthias.buechse@cloudandheat.com>
77
# SPDX-License-Identifier: Apache-2.0
8+
from datetime import date
89
import logging
910
import os
1011
import os.path
@@ -68,12 +69,14 @@ def get_subject_mapping(self, subject):
6869
def abspath(self, path):
6970
return os.path.join(self.cwd, path)
7071

71-
def build_check_command(self, scope, subject, output):
72+
def build_check_command(self, scope, subject, sections, output):
7273
# TODO figure out when to supply --debug here (but keep separated from our --debug)
7374
args = [
7475
sys.executable, self.scs_compliance_check, self.abspath(self.scopes[scope]['spec']),
7576
'--debug', '-C', '-o', output, '-s', subject,
7677
]
78+
if sections:
79+
args.extend(['--sections', sections])
7780
for key, value in self.get_subject_mapping(subject).items():
7881
args.extend(['-a', f'{key}={value}'])
7982
return {'args': args}
@@ -173,12 +176,13 @@ def _move_file(source_path, target_path):
173176
@cli.command()
174177
@click.option('--scope', 'scopes', type=str)
175178
@click.option('--subject', 'subjects', type=str)
179+
@click.option('--section', 'sections', type=str)
176180
@click.option('--preset', 'preset', type=str)
177181
@click.option('--num-workers', 'num_workers', type=int, default=5)
178182
@click.option('--monitor-url', 'monitor_url', type=str, default=MONITOR_URL)
179183
@click.option('-o', '--output', 'report_yaml', type=click.Path(exists=False), default=None)
180184
@click.pass_obj
181-
def run(cfg, scopes, subjects, preset, num_workers, monitor_url, report_yaml):
185+
def run(cfg, scopes, subjects, sections, preset, num_workers, monitor_url, report_yaml):
182186
"""
183187
run compliance tests and upload results to compliance monitor
184188
"""
@@ -196,13 +200,23 @@ def run(cfg, scopes, subjects, preset, num_workers, monitor_url, report_yaml):
196200
subjects = [subject.strip() for subject in subjects.split(',')] if subjects else []
197201
if not scopes or not subjects:
198202
raise click.UsageError('both scope(s) and subject(s) must be non-empty')
203+
if sections == '.auto':
204+
today = date.today()
205+
# https://docs.python.org/3/library/datetime.html#datetime.date.weekday
206+
# Return the day of the week as an integer, where Monday is 0 and Sunday is 6.
207+
weekday = today.weekday()
208+
if weekday == 5: # Saturday
209+
sections = 'light,medium,heavy'
210+
else:
211+
sections = 'light,medium'
212+
logger.info(f'auto-selected sections: {sections}')
199213
logger.debug(f'running tests for scope(s) {", ".join(scopes)} and subject(s) {", ".join(subjects)}')
200214
logger.debug(f'monitor url: {monitor_url}, num_workers: {num_workers}, output: {report_yaml}')
201215
with tempfile.TemporaryDirectory(dir=cfg.cwd) as tdirname:
202216
report_yaml_tmp = os.path.join(tdirname, 'report.yaml')
203217
jobs = [(scope, subject) for scope in scopes for subject in subjects]
204218
outputs = [os.path.join(tdirname, f'report-{idx}.yaml') for idx in range(len(jobs))]
205-
commands = [cfg.build_check_command(job[0], job[1], output) for job, output in zip(jobs, outputs)]
219+
commands = [cfg.build_check_command(job[0], job[1], sections, output) for job, output in zip(jobs, outputs)]
206220
_run_commands(commands, num_workers=num_workers)
207221
_concat_files(outputs, report_yaml_tmp)
208222
subprocess.run(**cfg.build_sign_command(report_yaml_tmp))

Tests/scs_cert_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
# valid keywords for various parts of the spec, to be checked using `check_keywords`
1717
KEYWORDS = {
1818
'spec': ('uuid', 'name', 'url', 'versions', 'prerequisite', 'variables', 'scripts', 'modules', 'timeline'),
19-
'scripts': ('executable', 'env', 'args', 'section', 'testcases'),
19+
'scripts': ('executable', 'env', 'args', 'testcases'),
2020
'versions': ('version', 'include', 'targets', 'stabilized_at'),
2121
'modules': ('id', 'targets', 'url', 'name', 'parameters'),
22-
'testcases': ('lifetime', 'id', 'description', 'url'),
22+
'testcases': ('lifetime', 'section', 'id', 'description', 'url'),
2323
'include': ('ref', 'parameters'),
2424
}
2525
# The canonical result values are -1, 0, and 1, for FAIL, ABORT, and PASS, respectively;

playbooks/compliance_check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
ansible.builtin.command:
99
cmd: >
1010
python3 Tests/scs-test-runner.py --config Tests/config.toml --debug
11-
run --preset {{ preset }}
11+
run --preset {{ preset }} --section '{{ section }}'
1212
--output "{{ ansible_user_dir }}/zuul-output/artifacts/report.yaml"
1313
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
1414
changed_when: true

0 commit comments

Comments
 (0)