Commit c2856de1 authored by Xavier Thompson's avatar Xavier Thompson

slapos-sr-testing: Add instance parameters to filter what is tested

The two following instance parameters now exist:
- `only-sr`: a list of software releases names to test
- `unittest-args`: a list of arguments for unittest

By default:
- all software releases are tested
- the unittest arguments are ["discover", "-v"]

Single values are accepted even if they are not in a list.
parent 3e8439b3
......@@ -15,4 +15,4 @@
[template]
filename = instance.cfg
md5sum = 5d1320a9b1d2828f2870e3096f1c2bfb
md5sum = 733643122fb75dfd7374b973a95fa2ea
......@@ -4,7 +4,7 @@ parts +=
publish
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration
recipe = slapos.cookbook:slapconfiguration.serialised
computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url}
......@@ -40,15 +40,34 @@ template = inline:
recipe = slapos.recipe.template:jinja2
rendered = ${:workdir}/.nxdtest
workdir = ${directory:nxdtest-working-dir}
template = inline:
{% for test in tests.splitlines() %}
tests = {{ tests | indent(2) }}
template =
inline:{% raw %}
{%- set only_sr = slapparameter_dict.get('only-sr') %}
{%- if not isinstance(only_sr, list) %}
{%- set only_sr = [only_sr] %}
{%- endif %}
{%- set unittest_args = slapparameter_dict.get('unittest-args', ['discover', '-v']) %}
{%- if not isinstance(unittest_args, list) %}
{%- set unittest_args = [unittest_args] %}
{%- endif %}
command = {{ repr([interpreter, '-m', 'unittest'] + unittest_args) }}
{%- for test in tests.splitlines() %}
{%- set name, folder = test.split() %}
{%- if not only_sr or name in only_sr %}
TestCase(
{{ repr(test.split()[0]) }},
[ {{ repr(interpreter) }}, '-m', 'unittest', 'discover', '-v'],
cwd={{ repr(test.split()[1]) }},
{{ repr(name) }},
command,
cwd={{ repr(folder) }},
summaryf=UnitTest.summary,
)
{% endfor %}
{%- endif %}
{%- endfor %}
{%- endraw %}
context =
key slapparameter_dict slap-configuration:configuration
key tests :tests
raw interpreter {{ interpreter }}
[runTestSuite]
env.sh = ${slapos-test-runner-nxdtest-environment.sh:rendered}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment