From 2b281dfc70f2688e0a38eb79070b3e081a27139d Mon Sep 17 00:00:00 2001 From: Chase Qi Date: Fri, 24 Aug 2018 12:21:32 +0800 Subject: linux/dockerized-tests: add local run support and readme Change-Id: I351b336bb643b66b4a739915bd263ba66de59b0b Signed-off-by: Chase Qi --- automated/linux/dockerized-tests/README.MD | 63 +++++++++++++++++++++++++ automated/linux/dockerized-tests/local-run.sh | 45 ++++++++++++++++++ automated/linux/dockerized-tests/local-run.yaml | 48 +++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 automated/linux/dockerized-tests/README.MD create mode 100755 automated/linux/dockerized-tests/local-run.sh create mode 100644 automated/linux/dockerized-tests/local-run.yaml (limited to 'automated') diff --git a/automated/linux/dockerized-tests/README.MD b/automated/linux/dockerized-tests/README.MD new file mode 100644 index 0000000..4d3dab6 --- /dev/null +++ b/automated/linux/dockerized-tests/README.MD @@ -0,0 +1,63 @@ +# Usage of dockerized tests + +## Local execution +### Issue commands manually + Without customized test parameters: + ``` + # docker run --privileged --init linaro/testdef-arm64-debian-stretch:2018.08 test-runner -d automated/linux/smoke/smoke.yaml + ``` + + With customized test parameters: + ``` + # docker run --privileged --init linaro/testdef-arm64-debian-stretch:2018.08 test-runner -d automated/linux/ltp/ltp.yaml -r TST_CMDFILES=syscalls SKIPFILE=skipfile-lkft.yaml BOARD=hi6220-hikey BRANCH=4.16 ENVIRONMENT=production + ``` + +### Using local-run.sh + ``` + # ./local-run.sh -d linaro/testdef-arm64-debian-stretch:2018.08 -t automated/linux/dd-wr-speed/dd-wr-speed.yaml -r ITERATION=3 + ``` +## Test run in LAVA + Test action example: + ``` + - test: + namespace: hikey + timeout: + minutes: 120 + definitions: + - repository: https://git.linaro.org/qa/test-definitions.git + from: git + path: automated/linux/dockerized-tests/local-run.yaml + name: smoke + parameters: + DOCKER_IMG: "linaro/testdef-arm64-debian-stretch:2018.08" + TEST: automated/linux/smoke/smoke.yaml + timeout: + # The first test needs time to pull and extract docker image. + minutes: 30 + - repository: https://git.linaro.org/qa/test-definitions.git + from: git + path: automated/linux/dockerized-tests/local-run.yaml + name: ltp-syscalls + parameters: + DOCKER_IMG: "linaro/testdef-arm64-debian-stretch:2018.08" + TEST: automated/linux/ltp/ltp.yaml + TESTDEF_PARAMS: "TST_CMDFILES='syscalls' SKIPFILE='skipfile-lkft.yaml' BOARD='hi6220-hikey' BRANCH='4.16' ENVIRONMENT='production'" + timeout: + minutes: 90 + ``` +## Drive test run via SSH + The same as local-run, but use over-ssh.yaml and over-ssh.sh instead and provide required additional parameters. + ``` + TARGET_IP: "" + SSH_USER: "" + SSH_PASSWD: "" + ``` + +## Dockerfiles + + [stretch-arm64-testdef](https://git.linaro.org/ci/dockerfiles.git/tree/stretch-arm64-testdef) + + [stretch-armhf-testdef](https://git.linaro.org/ci/dockerfiles.git/tree/stretch-armhf-testdef) + +## Jenkins build job for new tag on qa/test-definitions + [testdef-docker-image](https://ci.linaro.org/job/testdef-docker-image/) diff --git a/automated/linux/dockerized-tests/local-run.sh b/automated/linux/dockerized-tests/local-run.sh new file mode 100755 index 0000000..3a13853 --- /dev/null +++ b/automated/linux/dockerized-tests/local-run.sh @@ -0,0 +1,45 @@ +#!/bin/sh -ex + +TEST_DIR=$(dirname "$(realpath "$0")") +OUTPUT="${TEST_DIR}/output" +LOGFILE="${OUTPUT}/stdout.txt" +RESULT_FILE="${OUTPUT}/result.txt" + +TEST="automated/linux/smoke/smoke.yaml" +TESTDEF_PARAMS="" +DOCKER_IMG="linaro/testdef-arm64-debian-stretch:922033e" + +usage() { + echo "Usage: $0 [-t ] [-r ] [-d ]" 1>&2 + exit 1 +} + +while getopts "t:r:d:h" opt; do + case "$opt" in + t) TEST="${OPTARG}" ;; + r) TESTDEF_PARAMS="${OPTARG}" ;; + d) DOCKER_IMG="${OPTARG}" ;; + *) usage ;; + esac +done + +# SC1090: Can't follow non-constant source. Use a directive to specify location. +# shellcheck disable=SC1090 +. "${TEST_DIR}/../../lib/sh-test-lib" +create_out_dir "${OUTPUT}" + +# Assume docker pre-installed on test target. +command -v docker || error_msg "docker not found on test target!" + +# Trigger test run. +cmd1="docker run --privileged --init ${DOCKER_IMG} test-runner -d ${TEST}" +[ -n "${TESTDEF_PARAMS}" ] && cmd1="${cmd1} -r ${TESTDEF_PARAMS}" +if ! pipe0_status "${cmd1}" "tee -a ${LOGFILE}"; then + echo "docker-run fail" | tee -a "${RESULT_FILE}" + info_msg "Usage: check automated/linux/dockerized-tests/README.md" + error_msg "Test run with docker failed!" +fi + +# Parse test log. +awk '/^|=|TEST_CASE_ID|RESULT|UNITS|MEASUREMENT)/,""); print}' "${LOGFILE}" \ + | tee -a "${RESULT_FILE}" diff --git a/automated/linux/dockerized-tests/local-run.yaml b/automated/linux/dockerized-tests/local-run.yaml new file mode 100644 index 0000000..37153b9 --- /dev/null +++ b/automated/linux/dockerized-tests/local-run.yaml @@ -0,0 +1,48 @@ +metadata: + name: local-run + format: "Lava-Test-Shell Test Definition 1.0" + description: "Run tests from https://git.linaro.org/qa/test-definitions.git with + docker. Test runs on test target." + maintainer: + - chase.qi@linaro.org + os: + - ubuntu + - debian + - centos + - fedora + - openembedded + devices: + - d03 + - d05 + - juno + - beaglebone-black + - hi6220-hikey + - apq8016-sbc + - mustang + - moonshot + - thunderX + - x15 + + scope: + - functional + - performance + +params: + # Relative path to test definition file + # Example: automated/linux/linpack/linpack.yaml + TEST: "automated/linux/smoke/smoke.yaml" + # Usage: KEY1=VALUE1 KEY2=VALUE2 + # Example for smoke test: 'TESTS="pwd, lsb_release -a, uname -a, ip a, lscpu, vmstat, lsblk"' + TESTDEF_PARAMS: "" + # Dockerfile example: https://git.linaro.org/ci/dockerfiles.git/tree/stretch-arm64-testdef + DOCKER_IMG: "linaro/testdef-arm64-debian-stretch:922033e" + +run: + steps: + - cd automated/linux/dockerized-tests + - if [ -z "${TESTDEF_PARAMS}" ]; then + - ./local-run.sh -t "${TEST}" -d "${DOCKER_IMG}" + - else + - ./local-run.sh -t "${TEST}" -d "${DOCKER_IMG}" -r "${TESTDEF_PARAMS}" + - fi + - ../../utils/send-to-lava.sh ./output/result.txt -- cgit v1.2.3