Add Jenkins and job results parsing scripts
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 10 Nov 2016 17:17:26 +0000 (12:17 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 16 Nov 2016 22:36:54 +0000 (17:36 -0500)
scripts/lttng-baremetal-tests/build-kernel.sh [new file with mode: 0644]
scripts/lttng-baremetal-tests/build-modules.sh [new file with mode: 0644]
scripts/lttng-baremetal-tests/check-build-needs.sh [new file with mode: 0644]
scripts/lttng-baremetal-tests/generate-properties-master.sh [new file with mode: 0644]
scripts/lttng-baremetal-tests/generate-properties-slave.sh [new file with mode: 0644]
scripts/lttng-baremetal-tests/lava-submit.py [new file with mode: 0644]
scripts/lttng-baremetal-tests/parse-results.py [new file with mode: 0755]
scripts/lttng-baremetal-tests/run-benchmarks.sh [new file with mode: 0644]
scripts/lttng-baremetal-tests/run-tests.sh [new file with mode: 0644]

diff --git a/scripts/lttng-baremetal-tests/build-kernel.sh b/scripts/lttng-baremetal-tests/build-kernel.sh
new file mode 100644 (file)
index 0000000..eb32c9c
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash -xeu
+# Copyright (C) 2016 - Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+echo 'kernel-built.txt does not exist'
+echo 'So we build it'
+
+make --directory="$LINUX_PATH" "-j$NPROC" bzImage modules
+make --directory="$LINUX_PATH" INSTALL_MOD_PATH="$MODULES_INSTALL_FOLDER" modules_install
+
+cp "$LINUX_PATH"/arch/x86/boot/bzImage "$DEPLOYDIR"/"$KERNEL_COMMIT_ID".bzImage
+cp "$LINUX_PATH"/.config "$DEPLOYDIR"/"$KERNEL_COMMIT_ID".config
+
+tar -czf "$DEPLOYDIR/$BUILD_NAME.linux.modules.tar.gz" -C "$MODULES_INSTALL_FOLDER/" ./
+
+$SCP_COMMAND "$DEPLOYDIR/$KERNEL_COMMIT_ID.bzImage" "$STORAGE_USER@$STORAGE_HOST:$STORAGE_KERNEL_IMAGE"
+$SCP_COMMAND "$DEPLOYDIR/$KERNEL_COMMIT_ID.config" "$STORAGE_USER@$STORAGE_HOST:$STORAGE_KERNEL_CONFIG"
+$SCP_COMMAND "$DEPLOYDIR/$BUILD_NAME.linux.modules.tar.gz" "$STORAGE_USER@$STORAGE_HOST:$STORAGE_LINUX_MODULES"
+$SCP_COMMAND "$LINUX_PATH/Module.symvers" "$STORAGE_USER@$STORAGE_HOST:$STORAGE_KERNEL_MODULE_SYMVERS"
diff --git a/scripts/lttng-baremetal-tests/build-modules.sh b/scripts/lttng-baremetal-tests/build-modules.sh
new file mode 100644 (file)
index 0000000..1d658f5
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash -xeu
+# Copyright (C) 2016 - Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+echo 'modules-built.txt does not exist'
+echo 'So we built them against the kernel'
+
+$SCP_COMMAND "$STORAGE_USER@$STORAGE_HOST:$STORAGE_KERNEL_MODULE_SYMVERS" "$LINUX_PATH/Module.symvers"
+
+KERNELDIR="$LINUX_PATH" make -j"$NPROC" --directory="$LTTNG_MODULES_PATH"
+
+KERNELDIR="$LINUX_PATH" make -j"$NPROC" --directory="$LTTNG_MODULES_PATH" modules_install INSTALL_MOD_PATH="$MODULES_INSTALL_FOLDER"
+
+tar -czf "$DEPLOYDIR/$BUILD_NAME.lttng.modules.tar.gz" -C "$MODULES_INSTALL_FOLDER/" ./
+
+$SCP_COMMAND "$DEPLOYDIR/$BUILD_NAME.lttng.modules.tar.gz" "$STORAGE_USER@$STORAGE_HOST:$STORAGE_LTTNG_MODULES"
diff --git a/scripts/lttng-baremetal-tests/check-build-needs.sh b/scripts/lttng-baremetal-tests/check-build-needs.sh
new file mode 100644 (file)
index 0000000..52aea76
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/bash -xeu
+# Copyright (C) 2016 - Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+mkdir -p "$DEPLOYDIR"
+
+NEED_MODULES_BUILD=0
+NEED_KERNEL_BUILD=0
+
+set +e
+$SSH_COMMAND "$STORAGE_USER@$STORAGE_HOST" ls "$STORAGE_KERNEL_IMAGE"
+if [ $? -ne 0 ]; then
+  NEED_KERNEL_BUILD=1
+  # We need to build the lttng modules if the kernel has changed.
+  NEED_MODULES_BUILD=1
+fi
+
+$SSH_COMMAND "$STORAGE_USER@$STORAGE_HOST" ls "$STORAGE_LTTNG_MODULES"
+if [ $? -ne 0 ]; then
+  NEED_MODULES_BUILD=1
+fi
+set -e
+
+# We need to fetch the kernel source and lttng-modules to build either the
+# kernel or modules
+if [ $NEED_MODULES_BUILD -eq 1 ] || [ $NEED_KERNEL_BUILD -eq 1 ] ; then
+
+  git clone "$KGITREPO" "$LINUX_PATH"
+  pushd "$LINUX_PATH"
+  git checkout "$KERNEL_COMMIT_ID"
+  popd
+  git clone "$LTTNG_MODULES_GIT" "$LTTNG_MODULES_PATH"
+  pushd "$LTTNG_MODULES_PATH"
+  git checkout "$LTTNG_MODULES_COMMIT_ID"
+  popd
+
+  git clone https://github.com/lttng/lttng-ci "$LTTNG_CI_PATH"
+  cp "$LTTNG_CI_PATH"/lava/kernel/vanilla/x86_64_server.config "$LINUX_PATH"/.config
+
+  make --directory="$LINUX_PATH" olddefconfig
+  make --directory="$LINUX_PATH" modules_prepare
+fi
+
+#We create files to specify what needs to be built for the subsequent build steps
+if [ $NEED_MODULES_BUILD -eq 0 ] ; then
+  touch modules-built.txt
+fi
+if [ $NEED_KERNEL_BUILD -eq 0 ] ; then
+  touch kernel-built.txt
+fi
diff --git a/scripts/lttng-baremetal-tests/generate-properties-master.sh b/scripts/lttng-baremetal-tests/generate-properties-master.sh
new file mode 100644 (file)
index 0000000..74ce818
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/bash -xeu
+# Copyright (C) 2016 - Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+touch properties.txt
+if [ -n "${UST_BRANCH+x}" ]; then
+  LTTNG_UST_PATH="$WORKSPACE/src/lttng-ust"
+  git clone https://github.com/lttng/lttng-ust "$LTTNG_UST_PATH"
+
+  pushd "$LTTNG_UST_PATH"
+  git checkout "$UST_BRANCH"
+  popd
+
+  LTTNG_UST_COMMIT_ID="$(git --git-dir="$LTTNG_UST_PATH"/.git/ --work-tree="$LTTNG_UST_PATH" rev-parse HEAD)"
+  echo "LTTNG_UST_PATH=$LTTNG_UST_PATH" >> properties.txt
+  echo "LTTNG_UST_COMMIT_ID=$LTTNG_UST_COMMIT_ID" >> properties.txt
+fi
+
+LTTNG_CI_PATH="$WORKSPACE/src/lttng-ci"
+LINUX_PATH="$WORKSPACE/src/linux"
+LTTNG_MODULES_PATH="$WORKSPACE/src/lttng-modules"
+LTTNG_TOOLS_PATH="$WORKSPACE/src/lttng-tools"
+
+echo "LTTNG_CI_PATH=$LTTNG_CI_PATH" >> properties.txt
+echo "LINUX_PATH=$LINUX_PATH" >> properties.txt
+echo "LTTNG_MODULES_PATH=$LTTNG_MODULES_PATH" >> properties.txt
+echo "LTTNG_TOOLS_PATH=$LTTNG_TOOLS_PATH" >> properties.txt
+
+KERNEL_COMMIT_ID="$(git --git-dir="$LINUX_PATH"/.git/ --work-tree="$LINUX_PATH" rev-parse HEAD)"
+LTTNG_MODULES_COMMIT_ID="$(git --git-dir="$LTTNG_MODULES_PATH"/.git/ --work-tree="$LTTNG_MODULES_PATH" rev-parse HEAD)"
+LTTNG_TOOLS_COMMIT_ID="$(git --git-dir="$LTTNG_TOOLS_PATH"/.git/ --work-tree="$LTTNG_TOOLS_PATH" rev-parse HEAD)"
+
+echo "KERNEL_COMMIT_ID=$KERNEL_COMMIT_ID" >> properties.txt
+echo "LTTNG_MODULES_COMMIT_ID=$LTTNG_MODULES_COMMIT_ID" >> properties.txt
+echo "LTTNG_TOOLS_COMMIT_ID=$LTTNG_TOOLS_COMMIT_ID" >> properties.txt
+
+BASE_STORAGE_FOLDER="/storage/jenkins-lava/baremetal-tests"
+
+echo "KGITREPO=git://git-mirror.internal.efficios.com/git/linux-stable.git" >> properties.txt
+echo "STORAGE_KERNEL_FOLDER=$BASE_STORAGE_FOLDER/kernel" >> properties.txt
+echo "STORAGE_KERNEL_IMAGE=$BASE_STORAGE_FOLDER/kernel/$KERNEL_COMMIT_ID.bzImage" >> properties.txt
+echo "STORAGE_LINUX_MODULES=$BASE_STORAGE_FOLDER/modules/linux/$KERNEL_COMMIT_ID.linux.modules.tar.gz" >> properties.txt
+echo "STORAGE_LTTNG_MODULES=$BASE_STORAGE_FOLDER/modules/lttng/$KERNEL_COMMIT_ID-$LTTNG_MODULES_COMMIT_ID.lttng.modules.tar.gz" >> properties.txt
diff --git a/scripts/lttng-baremetal-tests/generate-properties-slave.sh b/scripts/lttng-baremetal-tests/generate-properties-slave.sh
new file mode 100644 (file)
index 0000000..449a9da
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash -xeu
+# Copyright (C) 2016 - Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+touch properties.txt
+
+# Use all CPU cores
+NPROC=$(nproc)
+echo "NPROC=$NPROC" >> properties.txt
+
+LTTNG_CI_PATH="$WORKSPACE/src/lttng-ci"
+LINUX_PATH="$WORKSPACE/src/linux"
+LTTNG_MODULES_PATH="$WORKSPACE/src/lttng-modules"
+
+echo "LTTNG_MODULES_GIT=git://git-mirror.internal.efficios.com/lttng/lttng-modules.git" >> properties.txt
+echo "LTTNG_CI_PATH=$LTTNG_CI_PATH" >> properties.txt
+echo "LINUX_PATH=$LINUX_PATH" >> properties.txt
+echo "LTTNG_MODULES_PATH=$LTTNG_MODULES_PATH" >> properties.txt
+
+DEPLOYDIR="$WORKSPACE/deploy"
+MODULES_INSTALL_FOLDER="$DEPLOYDIR/modules"
+
+echo "DEPLOYDIR=$DEPLOYDIR" >> properties.txt
+echo "MODULES_INSTALL_FOLDER=$MODULES_INSTALL_FOLDER" >> properties.txt
+
+BUILD_NAME="$KERNEL_COMMIT_ID-$LTTNG_MODULES_COMMIT_ID"
+
+echo "KERNEL_COMMIT_ID=$KERNEL_COMMIT_ID" >> properties.txt
+echo "LTTNG_MODULES_COMMIT_ID=$LTTNG_MODULES_COMMIT_ID" >> properties.txt
+echo "BUILD_NAME=$BUILD_NAME" >> properties.txt
+
+echo "STORAGE_KERNEL_MODULE_SYMVERS=$STORAGE_KERNEL_FOLDER/$KERNEL_COMMIT_ID.symvers" >>properties.txt
+echo "STORAGE_KERNEL_CONFIG=$STORAGE_KERNEL_FOLDER/$KERNEL_COMMIT_ID.config" >> properties.txt
+
+echo "STORAGE_HOST=storage01.internal.efficios.com" >> properties.txt
+echo "STORAGE_USER=jenkins-lava" >> properties.txt
+
+echo SSH_COMMAND="ssh -oStrictHostKeyChecking=no -i $identity_file" >> properties.txt
+echo SCP_COMMAND="scp -oStrictHostKeyChecking=no -i $identity_file" >> properties.txt
diff --git a/scripts/lttng-baremetal-tests/lava-submit.py b/scripts/lttng-baremetal-tests/lava-submit.py
new file mode 100644 (file)
index 0000000..a0e3407
--- /dev/null
@@ -0,0 +1,304 @@
+#!/usr/bin/python
+# Copyright (C) 2016 - Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+import argparse
+import base64
+import json
+import os
+import sys
+import time
+import xmlrpclib
+from collections import OrderedDict
+from enum import Enum
+
+USERNAME = 'frdeso'
+HOSTNAME = 'lava-master.internal.efficios.com'
+SCP_PATH = 'scp://jenkins-lava@storage.internal.efficios.com'
+
+class TestType(Enum):
+    benchmarks=1
+    tests=2
+
+def get_job_bundle_content(server, job):
+    bundle_sha = server.scheduler.job_status(str(job))['bundle_sha1']
+    bundle = server.dashboard.get(bundle_sha)
+
+    return json.loads(bundle['content'])
+
+# Parse the results bundle to see the run-tests testcase
+# of the lttng-kernel-tests passed successfully
+def check_job_all_test_cases_state_count(server, job):
+    content = get_job_bundle_content(server, job)
+
+    passed_tests=0
+    failed_tests=0
+    for run in content['test_runs']:
+        for result in run['test_results']:
+            if 'test_case_id' in result:
+                if result['result'] in 'pass':
+                    passed_tests+=1
+                else:
+                    failed_tests+=1
+    return (passed_tests, failed_tests)
+
+# Parse the attachment of the testcase to fetch the stdout of the test suite
+def print_test_output(server, job):
+    content = get_job_bundle_content(server, job)
+    found = False
+
+    for run in content['test_runs']:
+        if run['test_id'] in 'lttng-kernel-test':
+            for attachment in run['attachments']:
+                if attachment['pathname'] in 'stdout.log':
+
+                    # Decode the base64 file and split on newlines to iterate
+                    # on list
+                    testoutput = base64.b64decode(attachment['content']).split('\n')
+
+                    # Create a generator to iterate on the lines and keeping
+                    # the state of the iterator across the two loops.
+                    testoutput_iter = iter(testoutput)
+                    for line in testoutput_iter:
+
+                        # Find the header of the test case and start printing
+                        # from there
+                        if 'LAVA_SIGNAL_STARTTC run-tests' in line:
+                            found = True
+                            print('---- TEST SUITE OUTPUT BEGIN ----')
+                            for line in testoutput_iter:
+                                if 'LAVA_SIGNAL_ENDTC run-tests' not in line:
+                                    print(line)
+                                else:
+                                    # Print until we reach the end of the
+                                    # section
+                                    break
+
+                        if found is True:
+                            print('----- TEST SUITE OUTPUT END -----')
+                            break
+
+def create_new_job(name):
+    job = OrderedDict({
+        'health_check': False,
+        'job_name': name,
+        'device_type': 'x86',
+        'tags': [ 'dev-sda1' ],
+        'timeout': 18000,
+        'actions': []
+    })
+    return job
+
+def get_boot_cmd():
+    command = OrderedDict({
+        'command': 'boot_image'
+        })
+    return command
+
+def get_config_cmd():
+    packages=['bsdtar', 'psmisc', 'wget', 'python3', 'python3-pip', \
+            'libglib2.0-dev', 'libffi-dev', 'elfutils', 'libdw-dev', \
+            'libelf-dev', 'libmount-dev', 'libxml2', 'python3-pandas', \
+            'python3-numpy']
+    command = OrderedDict({
+        'command': 'lava_command_run',
+        'parameters': {
+            'commands': [
+                'ifup eth0',
+                'route -n',
+                'cat /etc/resolv.conf',
+                'echo nameserver 172.18.0.12 > /etc/resolv.conf',
+                'mount /dev/sda1 /tmp',
+                'rm -rf /tmp/*',
+                'depmod -a',
+                'locale-gen en_US.UTF-8',
+                'apt-get update',
+                'apt-get install -y {}'.format(' '.join(packages)),
+                ]
+            }
+        })
+    return command
+
+def get_benchmarks_cmd():
+    command = OrderedDict({
+        'command': 'lava_test_shell',
+        'parameters': {
+            'testdef_repos': [
+                {
+                    'git-repo': 'https://github.com/lttng/lttng-ci.git',
+                    'revision': 'master',
+                    'testdef': 'lava/baremetal-tests/failing-close.yml'
+                },
+                {
+                    'git-repo': 'https://github.com/lttng/lttng-ci.git',
+                    'revision': 'master',
+                    'testdef': 'lava/baremetal-tests/failing-open-efault.yml'
+                },
+                {
+                    'git-repo': 'https://github.com/lttng/lttng-ci.git',
+                    'revision': 'master',
+                    'testdef': 'lava/baremetal-tests/failing-open-enoent.yml'
+                }
+                ],
+            'timeout': 18000
+            }
+        })
+    return command
+
+def get_tests_cmd():
+    command = OrderedDict({
+        'command': 'lava_test_shell',
+        'parameters': {
+            'testdef_repos': [
+                {
+                    'git-repo': 'https://github.com/lttng/lttng-ci.git',
+                    'revision': 'master',
+                    'testdef': 'lava/baremetal-tests/kernel-tests.yml'
+                }
+                ],
+            'timeout': 18000
+            }
+        })
+    return command
+
+def get_results_cmd(stream_name):
+    command = OrderedDict({
+            'command': 'submit_results',
+            'parameters': {
+                'server': 'http://lava-master.internal.efficios.com/RPC2/'
+            }
+        })
+    command['parameters']['stream']='/anonymous/'+stream_name+'/'
+    return command
+
+def get_deploy_cmd(jenkins_job, kernel_path, linux_modules_path, lttng_modules_path, nb_iter=None):
+    command = OrderedDict({
+            'command': 'deploy_kernel',
+            'metadata': {},
+            'parameters': {
+                'overlays': [],
+                'kernel': None,
+                'nfsrootfs': str(SCP_PATH+'/storage/jenkins-lava/rootfs/rootfs_amd64_trusty_2016-02-23-1134.tar.gz'),
+                'target_type': 'ubuntu'
+                }
+            })
+
+    command['parameters']['overlays'].append( str(SCP_PATH+linux_modules_path))
+    command['parameters']['overlays'].append( str(SCP_PATH+lttng_modules_path))
+    command['parameters']['kernel'] = str(SCP_PATH+kernel_path)
+    command['metadata']['jenkins_jobname'] = jenkins_job    
+    if nb_iter is not None:
+        command['metadata']['nb_iterations'] = nb_iter
+
+    return command
+
+
+def get_env_setup_cmd(lttng_tools_commit, lttng_ust_commit=None):
+    command = OrderedDict({
+        'command': 'lava_command_run',
+        'parameters': {
+            'commands': [
+                'git clone https://github.com/frdeso/syscall-bench-it.git bm',
+                'pip3 install vlttng',
+                        ],
+            'timeout': 18000
+            }
+        })
+
+    vlttng_cmd = 'vlttng --jobs=16 --profile urcu-master' \
+                    ' --profile babeltrace-stable-1.4 ' \
+                    ' --profile lttng-tools-master' \
+                    ' --override projects.lttng-tools.checkout='+lttng_tools_commit + \
+                    ' --profile lttng-tools-no-man-pages'
+
+    if lttng_ust_commit is not None:
+        vlttng_cmd += ' --profile lttng-ust-master ' \
+                    ' --override projects.lttng-ust.checkout='+lttng_ust_commit+ \
+                    ' --profile lttng-ust-no-man-pages'
+
+    vlttng_cmd += " /tmp/virtenv"
+
+    command['parameters']['commands'].append(vlttng_cmd)
+    return command
+
+def main():
+    test_type = None
+    parser = argparse.ArgumentParser(description='Launch baremetal test using Lava')
+    parser.add_argument('-t', '--type', required=True)
+    parser.add_argument('-j', '--jobname', required=True)
+    parser.add_argument('-k', '--kernel', required=True)
+    parser.add_argument('-km', '--kmodule', required=True)
+    parser.add_argument('-lm', '--lmodule', required=True)
+    parser.add_argument('-l', '--lava-key', required=True)
+    parser.add_argument('-tc', '--tools-commit', required=True)
+    parser.add_argument('-uc', '--ust-commit', required=False)
+    args = parser.parse_args()
+
+
+    j = create_new_job(args.jobname)
+    j['actions'].append(get_deploy_cmd(args.jobname, args.kernel, args.kmodule, args.lmodule))
+    j['actions'].append(get_boot_cmd())
+    j['actions'].append(get_config_cmd())
+
+    if args.type in 'benchmarks':
+        test_type = TestType.benchmarks
+    elif args.type in 'tests':
+        test_type = TestType.tests
+    else:
+        print('argument -t/--type {} unrecognized. Exiting...'.format(args.type))
+        return -1
+
+    if test_type is TestType.benchmarks:
+        j['actions'].append(get_env_setup_cmd(args.tools_commit))
+        j['actions'].append(get_benchmarks_cmd())
+        j['actions'].append(get_results_cmd(stream_name='benchmark-kernel'))
+    elif test_type  is TestType.tests:
+        if args.ust_commit is None:
+            print('Tests runs need -uc/--ust-commit options. Exiting...')
+            return -1
+        j['actions'].append(get_env_setup_cmd(args.tools_commit, args.ust_commit))
+        j['actions'].append(get_tests_cmd())
+        j['actions'].append(get_results_cmd(stream_name='tests-kernel'))
+    else:
+        assert False, 'Unknown test type'
+
+    server = xmlrpclib.ServerProxy('http://%s:%s@%s/RPC2' % (USERNAME, args.lava_key, HOSTNAME))
+
+    jobid = server.scheduler.submit_job(json.dumps(j))
+
+    #Check the status of the job every 30 seconds
+    jobstatus = server.scheduler.job_status(jobid)['job_status']
+    while jobstatus in 'Submitted' or jobstatus in 'Running':
+        time.sleep(30)
+        jobstatus = server.scheduler.job_status(jobid)['job_status']
+
+    print('Job ended with {} status.'.format(jobstatus))
+    if jobstatus not in 'Complete':
+        return -1
+
+    passed, failed=check_job_all_test_cases_state_count(server, jobid)
+
+    print('With {} passed tests and {} failed tests.'.format(passed, failed))
+
+    if test_type is TestType.tests:
+        print_test_output(server, jobid)
+
+    if  failed == 0:
+        return 0
+    else:
+        return -1
+
+if __name__ == "__main__":
+    sys.exit(main())
diff --git a/scripts/lttng-baremetal-tests/parse-results.py b/scripts/lttng-baremetal-tests/parse-results.py
new file mode 100755 (executable)
index 0000000..ee058f3
--- /dev/null
@@ -0,0 +1,53 @@
+#! /usr/bin/python3
+from subprocess import call
+import sys
+import numpy as np
+import pandas as pd
+
+def test_case(df):
+    df['nsecperiter']=(df['duration']*1000)/(df['nbiter'])
+    stdev = pd.DataFrame({'perevent_stdev' : 
+                          df.groupby(['nbthreads', 'tracer', 'testcase','sleeptime'])['nsecperiter'].std()}).reset_index()
+    mean = pd.DataFrame({'perevent_mean' :
+                         df.groupby(['nbthreads', 'tracer', 'testcase','sleeptime'])['nsecperiter'].mean()}).reset_index()
+    mem_mean = pd.DataFrame({'mem_mean' :
+                             df.groupby(['nbthreads','tracer','testcase','sleeptime'])['maxmem'].mean()}).reset_index()
+    mem_stdev = pd.DataFrame({'mem_stdev' :
+                              df.groupby(['nbthreads','tracer','testcase','sleeptime'])['maxmem'].std()}).reset_index()
+    tmp = mean.merge(stdev)
+    tmp = tmp.merge(mem_mean)
+    tmp = tmp.merge(mem_stdev)
+
+
+    for i, row in tmp.iterrows():
+        testcase_name='_'.join([row['tracer'],str(row['nbthreads'])+'thr', 'pereventmean'])
+        yield( {"name": testcase_name, "result": "pass", "units": "nsec/event",
+            "measurement": str(row['perevent_mean'])})
+
+        testcase_name='_'.join([row['tracer'],str(row['nbthreads'])+'thr', 'pereventstdev'])
+        yield( {"name": testcase_name, "result": "pass", "units": "nsec/event",
+            "measurement": str(row['perevent_stdev'])})
+
+        testcase_name='_'.join([row['tracer'],str(row['nbthreads'])+'thr', 'memmean'])
+        yield( {"name": testcase_name, "result": "pass", "units": "kB",
+            "measurement": str(row['mem_mean'])})
+
+        testcase_name='_'.join([row['tracer'],str(row['nbthreads'])+'thr', 'memstdev'])
+        yield( {"name": testcase_name, "result": "pass", "units": "kB",
+            "measurement": str(row['mem_stdev'])})
+
+
+def main():
+    results_file=sys.argv[1]
+    df = pd.read_csv(results_file)
+    data = test_case(df)
+    for res in data:
+        call(
+            ['lava-test-case',
+            res['name'],
+            '--result', res['result'],
+            '--measurement', res['measurement'],
+            '--units', res['units']])
+
+if __name__ == '__main__':
+    main()
diff --git a/scripts/lttng-baremetal-tests/run-benchmarks.sh b/scripts/lttng-baremetal-tests/run-benchmarks.sh
new file mode 100644 (file)
index 0000000..7029812
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash -xeu
+# Copyright (C) 2016 - Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+echo 'At this point, we built the modules and kernel if we needed to.'
+echo 'We can now launch the lava job using those artefacts'
+git clone https://github.com/lttng/lttng-ci
+
+set +x
+python lttng-ci/scripts/lttng-baremetal-tests/lava-submit.py \
+                          -t benchmarks \
+                          -j "$JOB_NAME" \
+                          -l "$LAVA_FRDESO_TOKEN" \
+                          -k "$STORAGE_KERNEL_IMAGE" \
+                          -km "$STORAGE_LINUX_MODULES" \
+                          -lm "$STORAGE_LTTNG_MODULES" \
+                          -tc "$LTTNG_TOOLS_COMMIT_ID"
diff --git a/scripts/lttng-baremetal-tests/run-tests.sh b/scripts/lttng-baremetal-tests/run-tests.sh
new file mode 100644 (file)
index 0000000..6219ad1
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/bash -xeu
+# Copyright (C) 2016 - Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+echo 'At this point, we built the modules and kernel if we needed to.'
+echo 'We can now launch the lava job using those artefacts'
+git clone https://github.com/lttng/lttng-ci
+
+set +x
+python lttng-ci/scripts/lttng-baremetal-tests/lava-submit.py \
+                          -t tests \
+                          -j "$JOB_NAME" \
+                          -l "$LAVA_FRDESO_TOKEN" \
+                          -k "$STORAGE_KERNEL_IMAGE" \
+                          -km "$STORAGE_LINUX_MODULES" \
+                          -lm "$STORAGE_LTTNG_MODULES" \
+                          -tc "$LTTNG_TOOLS_COMMIT_ID" \
+                          -uc "$LTTNG_UST_COMMIT_ID"
This page took 0.036314 seconds and 4 git commands to generate.