The tool scs-compliance-check.py parses a
certificate scope specification
and executes the test executables referenced in there.
Please ensure you have installed the testsuite dependencies from requirements.txt
on your machine. We recommended using Python >= 3.10 and to install the
requirements into a virtualenv as follows:
cd Tests
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txtAt the moment, there are two cloud layers that can be checked: IaaS and KaaS.
For both types of checks, the exit code indicates success (0) or failure (!= 0).
You can also request a YAML report using the option -o OUTPUT.yaml
Some tests can be adjusted to the environment by using variables. These variables
can be specified in $HOME/.config/scs/env.yaml. Use the subject as a key for a
dictionary for the variables. For instance, with a subject openstack and two
variables dns_nameservers and external_gateway_net_id, you could declare:
openstack:
dns_nameservers: ['1.2.3.4']
external_gateway_net_id: abcdef12-3456-7890-abcd-ef1234567890Similarly, for KaaS environments requiring specific test execution permissions
(such as mounting an administrative kubeconfig into the Sonobuoy e2e test pod
for subjects requiring system:masters group membership in Kubernetes 1.36),
you can declare sonobuoy_fix:
syself-1.36:
sonobuoy_fix: inject-kubeconfigInstall IaaS-specific requirements:
pip install -r iaas/requirements.txtMake sure that you have Sonobuoy (diagnostic tool that makes it easier to understand the state of a K8s cluster) installed. You can find install instructions here.
With a cloud environment configured in your ~/.config/openstack/clouds.yaml
and secure.yaml, then run
./scs-compliance-check.py -s CLOUDNAME scs-compatible-iaas.yamlReplace CLOUDNAME with the name of your cloud environment as
specified in clouds.yaml.
Install KaaS-specific requirements:
pip install -r kaas/requirements.txtAdditionally, Sonobuoy must be installed and in your PATH environment variable.
Given a kubeconfig file path/to/kubeconfig.yaml, run
./scs-compliance-check.py -v -a kubeconfig=path/to/kubeconfig.yaml -s SUBJECT -o report.yaml scs-compatible-kaas.yamlReplace SUBJECT with an arbitrary, but meaningful subject name. Also, please note that the check
will always use the current-context of the kubeconfig and will fail if it isn't set.
Note: Sonobuoy checks (such as CNCF k8s conformance) are known to run for multiple hours (during which
you won't see feedback). In order to save wall-time, the sonobuoy checks will be run in parallel. You
disable that by simply adding -a execution_mode=serial to the command-line.
A report in YAML format will be created.
Additionally, the directory sono-results will be generated. It contains a JUnit XML file:
plugins/e2e/results/global/junit_01.xml. You can render it to HTML with a tool like junit2html.
This might give you hints as to why a test failed.
For environments requiring specific test execution workarounds (such as mounting
the admin kubeconfig into the e2e test pod for subjects requiring system:masters
group membership in Kubernetes 1.36), refer to the
Environment configuration (env.yaml)
section above to configure sonobuoy_fix in $HOME/.config/scs/env.yaml.
Usage: scs-compliance-check.py [options] SPEC_YAML
Arguments:
SPEC_YAML: yaml file specifying the certificate scope
Options:
-v/--verbose: More verbose output
-q/--quiet: Don't output anything but errors
--debug: enables DEBUG logging channel
-d/--date YYYY-MM-DD: Check standards valid on specified date instead of today
-V/--version VERS: Force version VERS of the standard (instead of deriving from date)
-s/--subject SUBJECT: Name of the subject (cloud) under test, for the report
-S/--sections SECTION_LIST: comma-separated list of sections to test (default: all sections)
-t/--tests REGEX: regular expression to select individual testcases based on their ids
-o/--output REPORT_PATH: Generate yaml report of compliance check under given path
-C/--critical-only: Only return critical errors in return code
-a/--assign KEY=VALUE: assign variable to be used for the run (as required by yaml file)
With -C, the return code will be nonzero precisely when the tests couldn't be run to completion.
docker build --tag scs-compliance-check .You'll have to bind mount your respective config(s), pass required parameters and the specification file.
For IaaS:
docker run -v ~/.config/openstack:/root/.config/openstack:ro scs-compliance-check -a os_cloud=CLOUDNAME -s CLOUDNAME scs-compatible-iaas.yamlFor KaaS:
docker run -v /path/to/kubeconfig.yaml:/root/kubeconfig.yaml:ro scs-compliance-check -a kubeconfig=/root/kubeconfig.yaml -a subject_root=. -s SUBJECT scs-compatible-kaas.yamlIf you want to test against a cluster running on localhost (e.g., kind cluster), replace
docker run with docker run --net=host in the above invocation.
docker run -it -v ~/.config/openstack:/root/.config/openstack:ro --entrypoint /bin/bash scs-compliance-checkSome of the conformance tests scripts are themselves tested with unit tests.
To run them, first ensure that you have installed the unit test dependencies in addition to the main dependencies (inside your virtualenv as described above):
pip install -r test-requirements.txtNow you can run the unit tests with pytest:
# Option A: let pytest discover and run all unit tests (**/*_test.py)
pytest
# Option B: run only a subset of the tests
pytest kaas/k8s-version-policy/k8s_version_policy_test.py
# Option C: produce a HTML code coverage report and open it
pytest --cov --cov-report=html
xdg-open htmldoc/index.htmlYou are encouraged to cover new conformance tests with unit tests! We run the tests on a regular basis in our GitHub workflows.
We use pip-compile to pin and upgrade our dependencies in a controlled manner.
With pip-compile, you list your dependencies with as few version constraints as
possible in a dedicated file, and then you have pip-compile generate the conventional
requirements.txt with fully pinned dependencies.
The tool pip-compile can be installed via pip install pip-tools.
It needs to be run in two cases:
-
You modified an
*.infile: runpip-compile <INFILE>. For example:pip-compile test-requirements.in
-
You want to bump the pinned dependencies: add the
--upgradeflag to thepip-compileinvocation. For example:pip-compile --upgrade requirements.in
We use a layered approach to allow for selective installation:
- the most basic layer is
requirements.in, - above that we have
iaas/requirements.inandkaas/requirements.in, and - at the very top we have
test-requirements.in.
Whenever you change or recompile one of these layers, all layers above that layer have to be recompiled as well.
Note: The Python version used for running pip-compile should be consistent. The currently
used version is documented in the header of the requirements.txt. It should match the
version used in the Docker image (see Dockerfile) and in our GitHub
workflows (lint-python.yml and test-python.yml in .github/workflows).