From cf1271bb7a11cb708178043db11c0503f604a042 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 4 Mar 2021 20:59:07 -0500 Subject: [PATCH] system-tests: refactor to allow easier test suites management across lttng versions Signed-off-by: Jonathan Rajotte --- lava/system-tests/destructive-tests.yml | 1 + lava/system-tests/kernel-tests.yml | 5 +- lava/system-tests/perf-tests.yml | 1 + scripts/system-tests/lava2-submit.py | 33 ++++--- scripts/system-tests/run-test-suites.sh | 96 +++++++++++++++++++ scripts/system-tests/template_lava_job.jinja2 | 3 + 6 files changed, 125 insertions(+), 14 deletions(-) create mode 100755 scripts/system-tests/run-test-suites.sh diff --git a/lava/system-tests/destructive-tests.yml b/lava/system-tests/destructive-tests.yml index e43b0f2..f8a325a 100644 --- a/lava/system-tests/destructive-tests.yml +++ b/lava/system-tests/destructive-tests.yml @@ -4,6 +4,7 @@ metadata: description: "Run root destructive test suite" params: JENKINS_BUILD_ID: "invalid_jenkins_build_id" + LTTNG_VERSION_STRING: "invalid_version_string" run: steps: - apt install -y curl diff --git a/lava/system-tests/kernel-tests.yml b/lava/system-tests/kernel-tests.yml index a155e16..cee21bb 100644 --- a/lava/system-tests/kernel-tests.yml +++ b/lava/system-tests/kernel-tests.yml @@ -4,6 +4,7 @@ metadata: description: "Run kernel test suite" params: JENKINS_BUILD_ID: "invalid_jenkins_build_id" + LTTNG_VERSION_STRING: "invalid_version_string" run: steps: - apt install -y curl @@ -15,8 +16,6 @@ run: - source /root/lttngvenv/activate - pushd /root/lttngvenv/src/lttng-tools - lava-test-case build-test-suite --shell "make" - - cd tests - - lava-test-case run-tests --shell "prove --nocolor --verbose --merge --exec '' - < root_regression" - - popd + - lava-test-case run-tests --shell "./ci/scripts/system-tests/run-test-suites.sh ${LTTNG_VERSION_STRING}" - tar czf coredump.tar.gz coredump - ./ci/lava/upload_artifact.sh coredump.tar.gz coredump.tar.gz "results/${JENKINS_BUILD_ID}/${TESTRUN_ID}-coredump.tar.gz" diff --git a/lava/system-tests/perf-tests.yml b/lava/system-tests/perf-tests.yml index 6306be3..026ccaf 100644 --- a/lava/system-tests/perf-tests.yml +++ b/lava/system-tests/perf-tests.yml @@ -4,6 +4,7 @@ metadata: description: "Run perf regression test suite" params: JENKINS_BUILD_ID: "invalid_jenkins_build_id" + LTTNG_VERSION_STRING: "invalid_version_string" run: steps: - apt install -y libpfm4-dev curl diff --git a/scripts/system-tests/lava2-submit.py b/scripts/system-tests/lava2-submit.py index 536b4b1..c6c1319 100644 --- a/scripts/system-tests/lava2-submit.py +++ b/scripts/system-tests/lava2-submit.py @@ -31,6 +31,19 @@ USERNAME = 'lava-jenkins' HOSTNAME = 'lava-master-02.internal.efficios.com' OBJSTORE_URL = "https://obj.internal.efficios.com/lava/results/" +def parse_stable_version(stable_version_string): + # Get the major and minor version numbers from the lttng version string. + version_match = re.search('stable-(\d).(\d\d)', stable_version_string) + + if version_match is not None: + major_version = int(version_match.group(1)) + minor_version = int(version_match.group(2)) + else: + # Setting to zero to make the comparison below easier. + major_version = 0 + minor_version = 0 + return major_version, minor_version + class TestType: """ Enum like for test type """ @@ -139,17 +152,7 @@ def get_vlttng_cmd( + ' --profile lttng-ust-no-man-pages' ) - - # Get the major and minor version numbers from the lttng version string. - version_match = re.search('stable-(\d).(\d\d)', lttng_version) - - if version_match is not None: - major_version = int(version_match.group(1)) - minor_version = int(version_match.group(2)) - else: - # Setting to zero to make the comparison below easier. - major_version = 0 - minor_version = 0 + major_version, minor_version = parse_stable_version(lttng_version) if lttng_version == 'master' or (major_version >= 2 and minor_version >= 11): vlttng_cmd += ( @@ -215,6 +218,13 @@ def main(): args.lttng_version, args.tools_url, args.tools_commit, args.ust_url, args.ust_commit ) + if args.lttng_version == "master": + lttng_version_string = "master" + else: + major, minor = parse_stable_version(args.lttng_version) + lttng_version_string = str(major) + "." + str(minor) + + context = dict() context['DeviceType'] = DeviceType context['TestType'] = TestType @@ -226,6 +236,7 @@ def main(): context['vlttng_cmd'] = vlttng_cmd context['vlttng_path'] = vlttng_path + context['lttng_version_string'] = lttng_version_string context['kernel_url'] = args.kernel context['nfsrootfs_url'] = nfsrootfs diff --git a/scripts/system-tests/run-test-suites.sh b/scripts/system-tests/run-test-suites.sh new file mode 100755 index 0000000..44b6a90 --- /dev/null +++ b/scripts/system-tests/run-test-suites.sh @@ -0,0 +1,96 @@ +#!/bin/bash -xeu +# +# Copyright (C) 2021 - Jonathan Rajotte +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Version compare functions +vercomp () { + set +u + if [[ "$1" == "$2" ]]; then + return 0 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)); do + if [[ -z ${ver2[i]} ]]; then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})); then + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})); then + return 2 + fi + done + set -u + return 0 +} + +verlte() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -eq "0" ] || [ "$res" -eq "2" ] +} + +verlt() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -eq "2" ] +} + +vergte() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -eq "0" ] || [ "$res" -eq "1" ] +} + +vergt() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -eq "1" ] +} + +verne() { + vercomp "$1" "$2"; local res="$?" + [ "$res" -ne "0" ] +} + +lttng_version="$1" +failed_tests=0 + +if [[ "$lttng_version" == "master" ]]; then + make --keep-going check || failed_tests=1 + # TODO: remove when root regression tests are merged with make check or + # in another make command. + if [ -f "./tests/long_regression" ]; then + cd "./tests" || exit 1 + prove --nocolor --verbose --merge --exec '' - < root_regression || failed_tests=1 + cd .. + fi +elif vergte "$lttng_version" "2.13"; then + # All root regression are now part of the make check + make --keep-going check || failed_tests=1 +else + make --keep-going check || failed_tests=1 + cd "./tests" || exit 1 + prove --nocolor --verbose --merge --exec '' - < root_regression || failed_tests=1 + cd .. +fi + +exit $failed_tests + + + diff --git a/scripts/system-tests/template_lava_job.jinja2 b/scripts/system-tests/template_lava_job.jinja2 index b3b9c1e..ded42e9 100644 --- a/scripts/system-tests/template_lava_job.jinja2 +++ b/scripts/system-tests/template_lava_job.jinja2 @@ -102,6 +102,7 @@ actions: path: lava/system-tests/perf-tests.yml name: perf-tests params: + LTTNG_VERSION_STRING: {{ lttng_version_string }} JENKINS_BUILD_ID: {{ jenkins_build_id }} {% elif test_type == TestType.kvm_tests %} - repository: https://github.com/lttng/lttng-ci.git @@ -109,11 +110,13 @@ actions: path: lava/system-tests/kernel-tests.yml name: kernel-tests params: + LTTNG_VERSION_STRING: {{ lttng_version_string }} JENKINS_BUILD_ID: {{ jenkins_build_id }} - repository: https://github.com/lttng/lttng-ci.git from: git path: lava/system-tests/destructive-tests.yml name: destructive-tests params: + LTTNG_VERSION_STRING: {{ lttng_version_string }} JENKINS_BUILD_ID: {{ jenkins_build_id }} {% endif %} -- 2.34.1