summaryrefslogtreecommitdiffstats
path: root/ci/envs
diff options
context:
space:
mode:
authorDon Dugger <donald.d.dugger@intel.com>2016-01-06 19:26:04 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-01-06 19:26:04 +0000
commit3ccaf24392443b98215d647884bddd963ad86190 (patch)
treed0a174998c2d934fd8ce8381885748fa5902d358 /ci/envs
parent23161def4f80592dc537853759205a7b90f5c676 (diff)
parent0fcee09d0a19457df88a4cea607de08e52ee959e (diff)
Merge topic 'yardstick-integ-v2'
* changes: A script to launch real time guest Script to create the guest image Script to create the rt-tests rpm
Diffstat (limited to 'ci/envs')
-rw-r--r--ci/envs/create-rt-tests-rpm.sh30
-rwxr-xr-xci/envs/guest-cmd.sh10
-rwxr-xr-xci/envs/guest-modify.sh142
-rwxr-xr-xci/envs/host-run-qemu.sh45
-rw-r--r--ci/envs/rt-tests.patch26
5 files changed, 253 insertions, 0 deletions
diff --git a/ci/envs/create-rt-tests-rpm.sh b/ci/envs/create-rt-tests-rpm.sh
new file mode 100644
index 000000000..96fef2bcd
--- /dev/null
+++ b/ci/envs/create-rt-tests-rpm.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+usage ()
+{
+ echo "$0 rpmdir"
+ exit 1
+}
+
+rpmdir=$1
+rm -rf ${rpmdir}/rt-tests-0.96-1.el7.centos.x86_64.rpm
+gitdir=`mktemp -d`
+ROOTDIR=$(cd $(dirname "$0")/../.. && pwd)
+VERSION=v0.96
+cd $gitdir
+git clone https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
+cd rt-tests
+git checkout -b ${VERSION} ${VERSION}
+patch -p1 -i ${ROOTDIR}/ci/envs/rt-tests.patch
+make HAVE_PARSE_CPUSTRING_ALL=1 rpm
+cp ./RPMS/x86_64/rt-tests-0.96-1.el7.centos.x86_64.rpm $rpmdir
+rm -rf $gitdir
+
diff --git a/ci/envs/guest-cmd.sh b/ci/envs/guest-cmd.sh
new file mode 100755
index 000000000..abfa51a40
--- /dev/null
+++ b/ci/envs/guest-cmd.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
diff --git a/ci/envs/guest-modify.sh b/ci/envs/guest-modify.sh
new file mode 100755
index 000000000..1208dd37e
--- /dev/null
+++ b/ci/envs/guest-modify.sh
@@ -0,0 +1,142 @@
+#!/bin/bash
+
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# This is copy from yardstick-img-modify on yardstick project. Currently
+# yardstick script only ubuntu image, and this one is more for CentOS.
+# Example invocation:
+# yardstick-img-modify /home/yardstick/tools/ubuntu-server-cloudimg-modify.sh
+#
+# Warning: the script will create files by default in:
+# /tmp/workspace/yardstick
+# the files will be owned by root!
+#
+# TODO: image resize is needed if the base image is too small
+#
+
+set -e
+set -x
+
+die() {
+ echo "error: $1" >&2
+ exit 1
+}
+
+usage () {
+ echo "$0 cmd workspace"
+ exit 1
+}
+
+test $# -eq 2 || usage
+test $(id -u) -eq 0 || die "should invoke using sudo"
+
+ROOTDIR=$(cd $(dirname "$0")/../.. && pwd)
+cmd=$1
+test -x $cmd
+workspace=$2
+mountdir=`mktemp -d`
+
+image_url=${IMAGE_URL:-"http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1510.qcow2"}
+md5sums_url=${MD5SUMS_URL:-"http://cloud.centos.org/centos/7/images/sha256sum.txt"}
+
+imgfile="${workspace}/guest.img"
+raw_imgfile="${workspace}/guest.raw"
+filename=$(basename $image_url)
+md5filename=$(basename $md5sums_url)
+
+# download and checksum base image, conditionally if local copy is outdated
+download() {
+ test -d $workspace || mkdir -p $workspace
+ cd $workspace
+ rm -f $md5filename # always download the checksum file to a detect stale image
+ wget $md5sums_url
+ test -e $filename || wget -nc $image_url
+ grep "$filename\$" $md5filename |sha256sum -c
+ if [ $? -ne 0 ]; then
+ rm $filename
+ wget -nc $image_url
+ grep $filename $md5filename | md5sum -c
+ fi
+ rm -rf $raw_imgfile
+ qemu-img convert $filename $raw_imgfile
+ cd -
+}
+
+# mount image
+setup() {
+ mkdir -p $mountdir
+
+ loopdevice=$(kpartx -l $raw_imgfile | head -1 | cut -f1 -d ' ')
+
+ kpartx -a $raw_imgfile
+ # No idea why need this sleep
+ sleep 3
+ mount /dev/mapper/$loopdevice $mountdir
+
+ cp $cmd "$mountdir/"
+}
+
+# modify image running a script using in a chrooted environment
+modify() {
+ # Add the ssh key to the image
+ mkdir -p ${mountdir}/root/.ssh
+ cp ${ROOTDIR}/ci/envs/kvm4nfv_key.pub ${mountdir}/root/.ssh/authorized_keys
+ chmod 700 ${mountdir}/root/.ssh
+ chmod 600 ${mountdir}/root/.ssh/authorized_keys
+
+
+ umount $mountdir
+
+ qemu-img convert -O qcow2 $raw_imgfile $imgfile
+}
+
+# cleanup (umount) the image
+cleanup() {
+ # designed to be idempotent
+ mount | grep $mountdir && umount $mountdir
+ kpartx -d $raw_imgfile || true
+ rm -f $raw_imgfile
+ rm -rf $mountdir
+}
+
+exitcode=""
+error_trap()
+{
+ local rc=$?
+
+ set +e
+
+ if [ -z "$exitcode" ]; then
+ exitcode=$rc
+ fi
+
+ cleanup
+
+ echo "Image build failed with $exitcode"
+
+ exit $exitcode
+}
+
+main() {
+ cleanup
+
+ trap "error_trap" EXIT SIGTERM
+
+ download
+ setup
+ modify
+
+ trap - EXIT SIGTERM
+ cleanup
+
+ echo "the modified image is found here: $imgfile"
+}
+
+main
diff --git a/ci/envs/host-run-qemu.sh b/ci/envs/host-run-qemu.sh
new file mode 100755
index 000000000..c7a2fecc6
--- /dev/null
+++ b/ci/envs/host-run-qemu.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+source host-config
+
+cpumask () {
+ m=$((1<<${1}))
+ printf 0x%x ${m}
+}
+
+qmp_sock="/tmp/qmp-sock-$$"
+
+${qemu} -smp ${guest_cpus} -monitor unix:${qmp_sock},server,nowait -daemonize \
+ -cpu host,migratable=off,+invtsc,+tsc-deadline,pmu=off \
+ -realtime mlock=on -mem-prealloc -enable-kvm -m 1G \
+ -mem-path /mnt/hugetlbfs-1g \
+ -drive file=/root/workspace/image/guest.img,cache=none,aio=threads \
+ -netdev user,id=guest0,hostfwd=tcp::5555-:22 \
+ -device virtio-net-pci,netdev=guest0 \
+ -nographic -serial /dev/null -parallel /dev/null
+
+i=0
+for c in `echo ${host_isolcpus} | sed 's/,/ /g'` ; do
+ cpu[$i]=${c}
+ i=`expr $i + 1`
+done
+
+threads=`echo "info cpus" | nc -U ${qmp_sock} | grep thread_id | cut -d= -f3`
+
+# Bind QEMU processor threads to RT CPUs
+i=0
+for tid in ${threads} ; do
+ tid=`printf %d ${tid}` # this is required to get rid of cr at end
+ mask=`cpumask ${cpu[$i]}`
+ taskset -p ${mask} ${tid}
+ i=`expr $i + 1`
+done
diff --git a/ci/envs/rt-tests.patch b/ci/envs/rt-tests.patch
new file mode 100644
index 000000000..b938e0768
--- /dev/null
+++ b/ci/envs/rt-tests.patch
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * * Copyright (c) 2015 Intel Corp.
+ * *
+ * * All rights reserved. This program and the accompanying materials
+ * * are made available under the terms of the Apache License, Version 2.0
+ * * which accompanies this distribution, and is available at
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *******************************************************************************/
+
+diff --git a/Makefile b/Makefile
+index 1e4b7d1b0d3a..98968b94a57f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -198,10 +198,10 @@ release: distclean changelog
+ cp -r Makefile COPYING ChangeLog MAINTAINERS doc README.markdown src tmp/rt-tests
+ rm -f rt-tests-$(VERSION).tar rt-tests-$(VERSION).tar.asc
+ tar -C tmp -cf rt-tests-$(VERSION).tar rt-tests
+- gpg2 --default-key clrkwllms@kernel.org --detach-sign --armor rt-tests-$(VERSION).tar
++ #gpg2 --default-key clrkwllms@kernel.org --detach-sign --armor rt-tests-$(VERSION).tar
+ gzip rt-tests-$(VERSION).tar
+ rm -f ChangeLog
+- cp rt-tests-$(VERSION).tar.gz rt-tests-$(VERSION).tar.asc releases
++ cp rt-tests-$(VERSION).tar.gz releases
+
+ .PHONY: tarball
+ tarball: