Skip to content
Snippets Groups Projects
Commit 18e0a906 authored by Luis Araujo's avatar Luis Araujo
Browse files

Add changes to render the new git-repos directive


The new install:git-repos directive in the test case YAML files
will allow to clone the tests scripts in order to integrate the
test cases into LAVA.

This commit adapts the renderer to properly generate test case pages
with this new directive.

Signed-off-by: default avatarLuis Araujo <luis.araujo@collabora.co.uk>
parent 45e3702c
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,10 @@ test_case_format = {
'post-conditions': (False, [])
}),
'install': (False, {
'deps': (True, [])
# git-repos should be mandatory.
# TODO: Set to True once all test cases use git-repos
'git-repos' : (False, []),
'deps': (False, [])
}),
'run': (True, {
'steps': (True, [])
......
......@@ -81,6 +81,15 @@ def priority_color(priority):
(priority == 'high' and 'warning') or \
(priority == 'critical' and 'danger') or 'light'
def get_git_repo_dir(git_repo=None):
# TODO: Remove this `if` once all test cases use git-repos.
if git_repo:
try:
return os.path.splitext(os.path.split(git_repo)[1])[0]
except IndexError:
print("Incorrect git-repos repository path:", git_repo)
exit(1)
def get_template_values(testcase_data):
template_values = {}
is_automated = False
......@@ -122,6 +131,27 @@ def get_template_values(testcase_data):
template_values.update({ 'run_steps' :
parse_list(steps, automated_run=is_automated) })
# If the test is automated, it should always have 'install:git-repos'
install = testcase_data.get('install')
if is_automated and install:
git_repos = install.get('git-repos', [])
git_repo_url = None
for gr in git_repos:
git_repo_url = gr.get('url')
if not git_repo_url:
print("Error: missing mandatory field install:git-repos:url for " \
"automated tests")
exit(1)
template_values.update({ 'git_repo_url' : git_repo_url })
template_values.update({ 'git_repo_dir' : get_git_repo_dir(git_repo_url) })
deps = install.get('deps')
if deps:
# A install.deps directive will always add a preconditions section
# to install the required packages using the macro to install packages.
template_values.update({ 'packages_list' : ' '.join(deps) })
# No mandatory fields
for nm in ['notes', 'format', 'maintainer', 'resources',
'pre-conditions', 'post-conditions']:
......@@ -132,17 +162,6 @@ def get_template_values(testcase_data):
'post-conditions']
else value })
install = testcase_data.get('install')
if install:
deps = install.get('deps')
if not deps:
print("Error: missing mandatory field deps for install")
exit(1)
template_values.update({ 'install_steps' : deps })
# A install.deps directive will always add a preconditions section
# to install the required packages using the macro to install packages.
template_values.update({ 'packages_list' : ' '.join(deps) })
# Macros variables
ostree_preconditions = metadata.get('macro_ostree_preconditions')
if ostree_preconditions:
......
{% macro git_repo(git_repo_url, git_repo_dir) %}
<li class="mb-sm-2">Clone the tests repository from another computer <i>(Note that the branch being tested may change depending on the release, please make sure to clone the correct branch for the release in question)</i>:</li>
<p><kbd>$ git clone {{ git_repo_url }}</kbd></p>
<li class="mb-sm-2">Copy the test directory {{ git_repo_dir }} to the device:</li>
<p><kbd>$ DUT_IP=&ltdevice-ip&gt</kbd></p>
<p><kbd>$ scp -r {{ git_repo_dir }} user@$DUT_IP:</kbd></p>
<li class="mb-sm-2">Log into the target:</li>
<p><kbd>$ ssh user@$DUT_IP</kbd></p>
{% endmacro %}
{% macro ostree_preconditions(pkgname) %}
<li class="mb-sm-2">From a PC, download and unpack the test data tarball from the gitlab test repository:</li>
<p><kbd>$ wget https://gitlab.apertis.org/tests/{{ pkgname }}/-/archive/master/{{ pkgname }}.tar.gz</kbd></p>
......
......@@ -36,12 +36,13 @@
</ul>
{% endif %}
{% if pre_conditions or pkgname or packages_list or libname %}
{% if pre_conditions or pkgname or packages_list or libname or git_repo_url %}
<hr />
<h4>Pre Conditions</h4>
<ol>
{% if pkgname %}{{ macros.ostree_preconditions(pkgname) }}{% endif %}
{% if packages_list %}{{ macros.install_packages(packages_list) }}{% endif %}
{% if git_repo_url and not pkgname %}{{ macros.git_repo(git_repo_url, git_repo_dir) }}{% endif %}
{% if libname %}{{ macros.modules_preconditions(libname) }}{% endif %}
{% for comment, command, output, _, link in pre_conditions %}
{% if comment %}<li class="mb-sm-2">{{ comment|e }}</li>{% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment