From 36563cc03b49e3ee6a5ec8f247b2750f72cab4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stevan=20Radakovi=C4=87?= Date: Tue, 3 Dec 2024 13:00:16 +0100 Subject: [PATCH] Add prototype appliance test definition for integration testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stevan Radaković --- automated/linux/torizon/integration-tests.sh | 18 +++++++++ .../linux/torizon/integration-tests.yaml | 31 +++++++++++++++ automated/utils/parse-robot-framework.py | 38 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100755 automated/linux/torizon/integration-tests.sh create mode 100644 automated/linux/torizon/integration-tests.yaml create mode 100755 automated/utils/parse-robot-framework.py diff --git a/automated/linux/torizon/integration-tests.sh b/automated/linux/torizon/integration-tests.sh new file mode 100755 index 000000000..1626947e4 --- /dev/null +++ b/automated/linux/torizon/integration-tests.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +. ../../lib/sh-test-lib + +gitlab_token="" +# source the secrets file to get the gitlab_token env var +. ../../../../../../secrets > /dev/null 2>&1 +install_deps "git curl python3-pip" $SKIP_INSTALL + +get_test_program "https://gitlab-ci-token:${gitlab_token}@gitlab.com/LinaroLtd/lava/appliance/baklava-integration.git" "baklava-integration" "main" +pip3 install -r requirements.txt + +echo "----------" +echo $LAVA_TOKEN +echo "----------" + +robot --pythonpath . --variable remote:$IS_REMOTE --outputdir=.. test/ > /dev/null 2>&1 +exit 0 diff --git a/automated/linux/torizon/integration-tests.yaml b/automated/linux/torizon/integration-tests.yaml new file mode 100644 index 000000000..1e912dce0 --- /dev/null +++ b/automated/linux/torizon/integration-tests.yaml @@ -0,0 +1,31 @@ +metadata: + name: integration-tests + format: "Lava-Test Test Definition 1.0" + description: "Run appliance integration tests in LAVA." + maintainer: + - stevan.radakovic@linaro.org + os: + - debian + - ubuntu + devices: + - qemu + scope: + - functional + +params: + SKIP_INSTALL: "False" + IS_REMOTE: "False" + BAKFLEET_URL: "" + LAVA_URL: "" + LAVA_USERNAME: "" + LAVA_TOKEN: "" + LAVA_PASSWORD: "" + BAKLAWEB_URL: "" + SPIRE_USER_EMAIL: "" + SPIRE_PAT_TOKEN: "" + +run: + steps: + - cd ./automated/linux/torizon/ + - ./integration-tests.sh + - ../../utils/parse-robot-framework.py -r output.xml diff --git a/automated/utils/parse-robot-framework.py b/automated/utils/parse-robot-framework.py new file mode 100755 index 000000000..e9f78c01a --- /dev/null +++ b/automated/utils/parse-robot-framework.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +import argparse +import subprocess +from robot.api import ExecutionResult, ResultVisitor + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument( + "-r", + "--result-file", + dest="result_file", + default="./output.xml", + help="Specify robot framework XML test result file.", + ) + args = parser.parse_args() + return args + + +def main(): + result = ExecutionResult(args.result_file) + + def get_all_tests(suite): + for test in suite.tests: + yield test + for sub_suite in suite.suites: + yield from get_all_tests(sub_suite) + + for test in get_all_tests(result.suite): + print( + f"" + ) + + +if __name__ == "__main__": + args = parse_args() + main()