diff options
Diffstat (limited to 'ci')
-rw-r--r-- | ci/Dockerfile | 17 | ||||
-rw-r--r-- | ci/apex.conf | 2 | ||||
-rwxr-xr-x | ci/apex_build.sh | 80 | ||||
-rwxr-xr-x | ci/build.sh | 49 | ||||
-rwxr-xr-x | ci/cyclicTestTrigger.sh | 58 | ||||
-rwxr-xr-x | ci/envs/disable_trace.sh | 17 | ||||
-rwxr-xr-x | ci/envs/enable-trace.sh | 60 | ||||
-rwxr-xr-x | ci/envs/host-config | 27 | ||||
-rw-r--r-- | ci/envs/packet_forwarding.sh | 174 | ||||
-rwxr-xr-x | ci/envs/utils.sh | 14 | ||||
-rwxr-xr-x | ci/test_kvmfornfv.sh | 72 |
11 files changed, 485 insertions, 85 deletions
diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 000000000..d39f15dd7 --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,17 @@ +#!/bin/bash + +FROM centos +RUN yum -y update && yum -y install \ + git \ + gcc \ + gcc-c++ \ + zlib-devel \ + gtk2-devel \ + glib2-devel \ + make \ + gettext \ + bc \ + bison\ + flex\ + rpm \ + rpm-build
\ No newline at end of file diff --git a/ci/apex.conf b/ci/apex.conf new file mode 100644 index 000000000..a5232e3ed --- /dev/null +++ b/ci/apex.conf @@ -0,0 +1,2 @@ +branch=master +commit_id=e1a58e17cf85b14c61c2389588ed7bf5da88fd53 diff --git a/ci/apex_build.sh b/ci/apex_build.sh new file mode 100755 index 000000000..8e57ac847 --- /dev/null +++ b/ci/apex_build.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +function checkout_commit() { +build_dir=/opt/kvmfornfv/ +mkdir -p /tmp/kvmfornfv +SRC=/tmp/kvmfornfv +source ${build_dir}/ci/apex.conf +cd $SRC +#Cloning into /tmp/kvmfornfv from local repository +git clone $build_dir $SRC +if [ "$branch" == "master" ] || [ "$branch" == "danube" ];then + echo "Checking out on $branch branch" + echo "Commit-id is ${commit_id}" + git checkout -f ${commit_id} + if [ $? -ne 0 ];then + echo "Please check the commit-id provided in apex.conf" + exit 1 + fi +fi +mkdir ${output_dir} +} + +output_dir="$1" +checkout_commit + +kernel_src_dir=$SRC/kernel +rpmbuild_dir=$SRC/kvmfornfv_rpmbuild.$$ +artifact_dir=${rpmbuild_dir}/RPMS/x86_64 +mkdir -p $artifact_dir +config_file="${kernel_src_dir}/arch/x86/configs/opnfv.config" + +usage () { + echo "usage: ${0} output_dir" + exit 1 +} + + +if [[ -z "$@" ]]; then + usage +fi + +if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then + echo "${0}: Output directory '${output_dir}' does not exist or cannot \ + be written" + exit 1 +fi + +if [ ! -d ${kernel_src_dir} ] ; then + echo "${0}: Directory '${kernel_src_dir}' does not exist, run this script \ + from the root of kvmfornfv source tree" + exit 1 +fi + +if [ ! -f ${config_file} ] ; then + echo "${0}: ${config_file} does not exist" + exit 1 +fi + +echo +echo "Build" +echo + +cp -f ${config_file} "${kernel_src_dir}/.config" + +# Make timestamp part of version string for automated kernel boot verification +date "+-%y%m%d%H%M" > "${kernel_src_dir}/localversion-zzz" + +(cd ${kernel_src_dir}; make RPMOPTS="--define '_topdir ${rpmbuild_dir}'" rpm-pkg) +if [ ${?} -ne 0 ] ; then + echo "${0}: Kernel build failed" + rm -rf ${rpmbuild_dir} + exit 1 +fi + +cp -f ${artifact_dir}/* ${output_dir} +mv ${output_dir}/* ${build_dir}/build_output/ + +rm -rf ${rpmbuild_dir} +#cleaning the /tmp +rm -rf ${SRC} diff --git a/ci/build.sh b/ci/build.sh index 918e3cab7..ef06a716c 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -3,6 +3,25 @@ # Common parameter parsing for kvmfornfv scripts # +function checking_apex_build() { + echo "" + commit=`git rev-parse HEAD` + echo "commit id: $commit" + echo "Checking for presence of apex.conf in the current patch" + git diff-tree --no-commit-id --name-only -r ${commit} | grep apex.conf +# result=`git show --name-only ${commit} | grep apex.conf` + result=`git diff-tree --no-commit-id --name-only -r ${commit} | grep apex.conf` + if [ -z "${result}" ]; then + echo "Does not include the file apex.conf" + apex_build_flag=0 + else + source $WORKSPACE/ci/apex.conf + echo "Includes apex.conf" + apex_build_flag=1 + fi +} + + function usage() { echo "" echo "Usage --> $0 [-p package_type] [-o output_dir] [-h]" @@ -18,10 +37,18 @@ type="" function run() { case $1 in centos) - cd $WORKSPACE/ci/build_rpm - sudo docker build -t kvm_rpm . - sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t kvm_rpm \ - /opt/kvmfornfv/ci/build_interface.sh $1 + if [ ${apex_build_flag} -eq 0 ];then + cd $WORKSPACE/ci/build_rpm + sudo docker build -t kvm_rpm . + sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t kvm_rpm \ + /opt/kvmfornfv/ci/build_interface.sh $1 + else + cd $WORKSPACE/ci/ + echo $output_dir + sudo docker build -t kvm_apex . + sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t kvm_apex \ + /opt/kvmfornfv/ci/apex_build.sh build_output + fi ;; ubuntu) cd $WORKSPACE/ci/build_deb @@ -96,5 +123,19 @@ echo "" echo "Building for $type package in $output_dir" echo "" +checking_apex_build mkdir -p $output_dir build_package $type + +# Renaming the rpms in the format kvmfornfv-xxxxxxxx-apex-kernel-4.4.6_rt14.el7.centos.x86_64.rpm +if [ ${apex_build_flag} -eq 1 ];then + cd ${output_dir} + echo "Renaming the rpms" + source $WORKSPACE/ci/apex.conf + echo "${commit_id}" + short_hash=`git rev-parse --short=8 ${commit_id}` + echo "$short_hash" + rename 's/^/kvmfornfv-'${short_hash}'-apex-/' kernel-* + variable=`ls kvmfornfv-* | grep "devel" | awk -F "_" '{print $3}' | awk -F "." '{print $1}'` + rename "s/${variable}/centos/" kvmfornfv-* +fi diff --git a/ci/cyclicTestTrigger.sh b/ci/cyclicTestTrigger.sh index 14aafbe98..640a0738a 100755 --- a/ci/cyclicTestTrigger.sh +++ b/ci/cyclicTestTrigger.sh @@ -14,6 +14,9 @@ testName=$4 source $WORKSPACE/ci/envs/utils.sh source $WORKSPACE/ci/envs/host-config + +checkRPMNames + KERNELRPM_VERSION=$( getKernelVersion ) QEMURPM_VERSION=$( getQemuVersion ) @@ -36,6 +39,15 @@ function verifyGuestImage { fi } +#disabling ftrace and collecting the logs to upload to artifact repository. +function ftrace_disable { + sudo ssh root@${HOST_IP} "sh /root/workspace/scripts/disable_trace.sh" + sudo ssh root@${HOST_IP} "cd /tmp ; mv trace.txt cyclictest_${env}.txt" + mkdir -p $WORKSPACE/build_output/log/kernel_trace + scp root@${HOST_IP}:/tmp/cyclictest_${env}.txt $WORKSPACE/build_output/log/kernel_trace/ + sudo ssh root@${HOST_IP} "cd /tmp ; rm -rf cyclictest_${env}.txt" +} + #Verifying the availability of the host after reboot function connect_host { n=0 @@ -65,8 +77,8 @@ function updateYaml { sed -ri "s/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/${HOST_IP}/" pod.yaml sed -ri "s/loops: [0-9]*/loops: ${testTime}/" kvmfornfv_cyclictest_hostenv_guestenv.yaml sed -ri "0,/interval: [0-9]*/s//interval: 1000/" kvmfornfv_cyclictest_hostenv_guestenv.yaml - sed -ri "s/tc: \"kvmfornfv_cyclictest-node-context\"/tc: \"kvmfornfv_cyclictest_${testName}\"/" kvmfornfv_cyclictest_hostenv_guestenv.yaml cp kvmfornfv_cyclictest_hostenv_guestenv.yaml kvmfornfv_cyclictest_${testName}.yaml + sed -ri "s/tc: \"kvmfornfv_cyclictest-node-context\"/tc: \"kvmfornfv_cyclictest_${testName}\"/" kvmfornfv_cyclictest_${testName}.yaml case $testName in idle_idle) @@ -87,7 +99,7 @@ function updateYaml { sed -i '/guest-setup1.sh/a\ \- \"stress_daily.sh memory\"' kvmfornfv_cyclictest_${testName}.yaml ;; idle_iostress) - sed -i '/guest-setup1.sh/a\ \- \"stress_daily.sh memory\"' kvmfornfv_cyclictest_${testName}.yaml + sed -i '/guest-setup1.sh/a\ \- \"stress_daily.sh io\"' kvmfornfv_cyclictest_${testName}.yaml ;; *) echo "Incorrect test environment: $testName" @@ -98,7 +110,7 @@ function updateYaml { #cleaning the environment after executing the test through yardstick. function env_clean { - container_id=`sudo docker ps -a | grep kvmfornfv_${testType}_${testName} |awk '{print \$1}'|sed -e 's/\r//g'` + container_id=`sudo docker ps -a | grep kvmfornfv_${testType} |awk '{print \$1}'|sed -e 's/\r//g'` sudo docker stop ${container_id} sudo docker rm ${container_id} sudo ssh root@${HOST_IP} "rm -rf /root/workspace/*" @@ -109,6 +121,7 @@ function env_clean { #Cleaning the latest kernel changes on host after executing the test. function host_clean { sudo ssh root@${HOST_IP} "rpm=\$(rpm -qa | grep 'kernel-${KERNELRPM_VERSION}' | awk '{print \$1}'); rpm -ev \$rpm" + sudo ssh root@${HOST_IP} "rpm=\$(rpm -qa | grep 'kernel-devel-${KERNELRPM_VERSION}' | awk '{print \$1}'); rpm -ev \$rpm" sudo ssh root@${HOST_IP} "rm -rf /boot/initramfs-${KERNELRPM_VERSION}*.img" sudo ssh root@${HOST_IP} "grub2-mkconfig -o /boot/grub2/grub.cfg" sudo ssh root@${HOST_IP} "rpm=\$(rpm -qa | grep 'qemu-${QEMURPM_VERSION}'| awk '{print \$1}'); rpm -ev \$rpm" @@ -127,19 +140,44 @@ function cleanup { fi } +#environment setup for executing packet forwarding test cases +function setUpPacketForwarding { + #copying required files to run packet forwarding test cases + ssh root@$HOST_IP "mkdir -p /root/workspace/image" + ssh root@$HOST_IP "mkdir -p /root/workspace/rpm" + ssh root@$HOST_IP "mkdir -p /root/workspace/scripts" + #Copying the host configuration scripts on to host + scp -r $WORKSPACE/ci/envs/* root@$HOST_IP:/root/workspace/scripts + scp -r $WORKSPACE/tests/vsperf.conf* root@$HOST_IP:/root/workspace/scripts + scp -r $WORKSPACE/build_output/kernel-${KERNELRPM_VERSION}*.rpm root@$HOST_IP:/root/workspace/rpm + scp -r $WORKSPACE/build_output/kernel-devel-${KERNELRPM_VERSION}*.rpm root@$HOST_IP:/root/workspace/rpm + scp -r $WORKSPACE/build_output/qemu-${QEMURPM_VERSION}*.rpm root@$HOST_IP:/root/workspace/rpm + #execute host configuration script for installing kvm built kernel. + ssh root@$HOST_IP "cd /root/workspace/scripts ; ./host-setup0.sh" + ssh root@$HOST_IP "cd /root/workspace/rpm ; rpm -ivh kernel-devel-${KERNELRPM_VERSION}*.rpm" + ssh root@$HOST_IP "reboot" + sleep 10 +} + +#executing packet forwarding test cases +function runPacketForwarding { + testType=$1 + ssh -t -t root@$HOST_IP "cd /root/workspace/scripts ; sudo scl enable python33 'sh packet_forwarding.sh $testType $QEMURPM_VERSION'" +} + #Creating a docker image with yardstick installed and Verify the results of cyclictest function runCyclicTest { + ftrace_enable=$1 docker_image_dir=$WORKSPACE/docker_image_build ( cd ${docker_image_dir}; sudo docker build -t kvmfornfv:latest --no-cache=true . ) if [ ${?} -ne 0 ] ; then echo "Docker image build failed" id=$(sudo docker ps -a | head -2 | tail -1 | awk '{print $1}'); sudo docker rm -f $id - err_exit 1 + exit 1 fi time_stamp=$(date +%Y%m%d%H%M%S) volume=/tmp/kvmtest-${testType}-${time_stamp} mkdir -p $volume/{image,rpm,scripts} - #copying required files to run yardstick cyclic testcase cp $WORKSPACE/build_output/kernel-${KERNELRPM_VERSION}*.rpm ${volume}/rpm cp $WORKSPACE/build_output/qemu-${QEMURPM_VERSION}*.rpm ${volume}/rpm @@ -149,18 +187,24 @@ function runCyclicTest { #Launching ubuntu docker container to run yardstick sudo docker run -i -v ${volume}:/opt --net=host --name kvmfornfv_${testType}_${testName} \ - kvmfornfv:latest /bin/bash -c "cd /opt/scripts && ls; ./cyclictest.sh $testType $testName" + kvmfornfv:latest /bin/bash -c "cd /opt/scripts && ls; ./cyclictest.sh $testType $testName" cyclictest_output=$? if [ "$testName" == "iostress_idle" ];then copyLogs fi + + #Disabling ftrace after completion of executing test cases. + if [ ${ftrace_enable} -eq '1' ]; then + ftrace_disable + fi + #Verifying the results of cyclictest if [ "$testType" == "verify" ];then result=`grep -o '"errors":[^,]*' ${volume}/yardstick.out | awk -F '"' '{print $4}'` if [ -z "${result}" ]; then echo "####################################################" - echo "" + echo " " echo `grep -o '"data":[^}]*' ${volume}/yardstick.out | awk -F '{' '{print $2}'` echo "" echo "####################################################" diff --git a/ci/envs/disable_trace.sh b/ci/envs/disable_trace.sh index 1b04e62bb..6e1ef15c6 100755 --- a/ci/envs/disable_trace.sh +++ b/ci/envs/disable_trace.sh @@ -2,16 +2,17 @@ set -o xtrace curpwd=`pwd` -TRACE_FILE=$1 -TRACEDIR=/sys/kernel/debug/tracing/ +TRACE_FILE=trace.txt +TRACEDIR=/sys/kernel/debug/tracing -sudo bash -c "echo 0 >$TRACEDIR/tracing_on" +bash -c "echo 0 > $TRACEDIR/tracing_on" sleep 1 -sudo bash -c "cat $TRACEDIR/trace > $TRACE_FILE" -sudo bash -c "echo > $TRACEDIR/set_event" -sudo bash -c "echo > $TRACEDIR/trace" -sudo sysctl kernel.ftrace_enabled=0 -sudo bash -c "echo nop > $TRACEDIR/current_tracer" +bash -c "cat $TRACEDIR/trace > /tmp/$TRACE_FILE" + +bash -c "echo > $TRACEDIR/set_event" +bash -c "echo > $TRACEDIR/trace" +sysctl kernel.ftrace_enabled=0 +bash -c "echo nop > $TRACEDIR/current_tracer" set +o xtrace cd $curpwd diff --git a/ci/envs/enable-trace.sh b/ci/envs/enable-trace.sh index 857f53e0d..e360de137 100755 --- a/ci/envs/enable-trace.sh +++ b/ci/envs/enable-trace.sh @@ -3,8 +3,7 @@ set -o xtrace EVENT=$1 curpwd=`pwd` -TRACEDIR=/sys/kernel/debug/tracing/ -mv /tmp/123.txt /tmp/123.back +TRACEDIR=/sys/kernel/debug/tracing function getcpumask { masks=`lscpu | grep "NUMA node1 CPU(s)"| awk -F ':' '{print \$2}' | sed 's/[[:space:]]//g'` @@ -12,7 +11,7 @@ function getcpumask { last=$(echo ${masks} | cut -f2 -d-) cpumask=0 while [ ${first} -lt ${last} ]; do - cputmp=`echo "ibase=10; obase=16; 2^(${c})" | bc` + cputmp=`echo "ibase=10; obase=16; 2^(${first})" | bc` cpumask=`echo "ibase=16; obase=10; ${cputmp}+${cpumask}" |bc` first=`expr $first + 1` done @@ -22,42 +21,41 @@ function getcpumask { } getcpumask -sudo bash -c "echo $CPUMASK > $TRACEDIR/tracing_cpumask" +bash -c "echo $CPUMASK > $TRACEDIR/tracing_cpumask" #sudo bash -c "echo function > $TRACEDIR/current_tracer" #echo :* > set_event #echo $EVENT:* > set_event -sudo bash -c "echo 1 > $TRACEDIR/events/irq/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/irq_vectors/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/task/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/syscalls/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/kmem/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/fence/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/context_tracking/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/exceptions/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/irq_vectors/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/nmi/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/kmem/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/migrate/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/sock/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/timer/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/sched/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/rcu/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/kvm/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/workqueue/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/power/enable" -sudo bash -c "echo 1 > $TRACEDIR/events/signal/enable" - -sudo bash -c "echo 1 > events/tlb/enable" +bash -c "echo 1 > $TRACEDIR/events/irq/enable" +bash -c "echo 1 > $TRACEDIR/events/irq_vectors/enable" +bash -c "echo 1 > $TRACEDIR/events/task/enable" +bash -c "echo 1 > $TRACEDIR/events/syscalls/enable" +bash -c "echo 1 > $TRACEDIR/events/kmem/enable" +bash -c "echo 1 > $TRACEDIR/events/fence/enable" +bash -c "echo 1 > $TRACEDIR/events/context_tracking/enable" +bash -c "echo 1 > $TRACEDIR/events/exceptions/enable" +bash -c "echo 1 > $TRACEDIR/events/irq_vectors/enable" +bash -c "echo 1 > $TRACEDIR/events/nmi/enable" +bash -c "echo 1 > $TRACEDIR/events/kmem/enable" +bash -c "echo 1 > $TRACEDIR/events/migrate/enable" +bash -c "echo 1 > $TRACEDIR/events/sock/enable" +bash -c "echo 1 > $TRACEDIR/events/timer/enable" +bash -c "echo 1 > $TRACEDIR/events/sched/enable" +bash -c "echo 1 > $TRACEDIR/events/rcu/enable" +bash -c "echo 1 > $TRACEDIR/events/kvm/enable" +bash -c "echo 1 > $TRACEDIR/events/workqueue/enable" +bash -c "echo 1 > $TRACEDIR/events/power/enable" +bash -c "echo 1 > $TRACEDIR/events/signal/enable" + +bash -c "echo 1 > events/tlb/enable" # Clean original log info -sudo bash -c "echo > $TRACEDIR/trace" -#sudo bash -c "echo function > $TRACEDIR/current_tracer" -sudo sysctl kernel.ftrace_enabled=1 +bash -c "echo > $TRACEDIR/trace" +bash -c "echo function > $TRACEDIR/current_tracer" +sysctl kernel.ftrace_enabled=1 #echo 0 >tracing_on; sleep 1; echo 1 >tracing_on; sleep 20; echo 0 >tracing_on;sleep 1; cat trace >/tmp/123.txt -sudo bash -c "echo 1 >$TRACEDIR/tracing_on" +bash -c "echo 1 >$TRACEDIR/tracing_on" cd $curpwd -#source /home/yjiang5/repo/hostbin/disable_trace.sh set +o xtrace diff --git a/ci/envs/host-config b/ci/envs/host-config index 99cbb3773..4a5d1b5a2 100755 --- a/ci/envs/host-config +++ b/ci/envs/host-config @@ -21,7 +21,7 @@ pcm_memory=/root/pcm/pcm-memory.x # Isolated cpus for nfv, must be given as a range '-' and Numa node1 CPU's should be considered host_isolcpus=`lscpu | grep "NUMA node1 CPU(s)"| awk -F ':' '{print \$2}' | sed 's/[[:space:]]//g'` first=$(echo ${host_isolcpus} | cut -f1 -d-) -last=$(echo ${host_isolcpus} | cut -f2 -d-) +last=$(echo ${host_isolcpus} | cut -f2 -d- | cut -d',' -f1 ) # Bind cpus from host_isolcpus range for QEMU processor threads i=0 @@ -35,8 +35,8 @@ done stress_isolcpus=${first}-${last} echo "Stress tool runs on $stress_isolcpus" -#Tar the log files generated during testcase execution. -function err_exit { +#Tar the log files generated during testcase execution and exit. +function test_exit { exitCode=$1 cd $WORKSPACE/build_output/ if [ -d log ];then @@ -55,3 +55,24 @@ function copyLogs { sudo ssh root@${HOST_IP} "cd /root;rm -rf MBWInfo MBWInfo.tar.gz" } +function packet_fwd_logs { + #Tar and copy logs for uploading to artifacts repository + echo "Copying Log files from Node to Jump Server" + mkdir -p $WORKSPACE/build_output/log/packet_fwd + scp -r root@${HOST_IP}:/tmp/packet_fwd_logs $WORKSPACE/build_output/log/packet_fwd + #removing collected logs on the node after copying. + sudo ssh root@${HOST_IP} "cd /tmp;rm -rf packet_fwd_logs" +} + +function packet_fwd_exit { + exitCode=$1 + TIMESTAMP=$(date -u +"%Y-%m-%d_%H-%M-%S") + cd $WORKSPACE/build_output/ + if [ -d log ];then + tar -czvf log-${TIMESTAMP}.tar.gz log + echo "Uploading packet forwarding logs and results" + gsutil cp -r log-*.tar.gz gs://artifacts.opnfv.org/kvmfornfv/packet_fwd_${TIMESTAMP} > $WORKSPACE/build_output/gsutil.log 2>&1 + echo "http://artifacts.opnfv.org/kvmfornfv/packet_fwd_${TIMESTAMP}" + fi + exit $exitCode +} diff --git a/ci/envs/packet_forwarding.sh b/ci/envs/packet_forwarding.sh new file mode 100644 index 000000000..ec399c6ab --- /dev/null +++ b/ci/envs/packet_forwarding.sh @@ -0,0 +1,174 @@ +#!/bin/bash +JOB_TYPE=$1 +QEMURPM_VERSION=$2 +HOME='/home/jenkins' +VSPERF="${HOME}/vswitchperf" +LOG_FILE_PREFIX="/tmp/vsperf_build" +VSPERF_BIN='./vsperf' +DATE=$(date -u +"%Y-%m-%d_%H-%M-%S") +VSPERFENV_DIR="$HOME/vsperfenv" +TEST_REPORT_LOG_DIR="/tmp/packet_fwd_logs" +EXIT=0 +EXIT_TC_FAILED=1 + +# DAILY - run selected TCs for defined packet sizes +TESTCASES_DAILY='phy2phy_tput phy2phy_tput_mod_vlan pvp_tput' +TESTPARAM_DAILY='--test-params TRAFFICGEN_PKT_SIZES=(64,128,512,1024,1518)' +TESTCASES_SRIOV='pvp_tput' +TESTPARAM_SRIOV='--test-params TRAFFICGEN_PKT_SIZES=(64,128,512,1024,1518)' + +#mounting shared directory for collecting ixia test results. +shared_dir=$(sudo mount | grep ixia_results) +if [ -z "$shared_dir" ]; then + echo "mounting shared directory for results" + sudo mount -t cifs //10.10.100.6/ixia_results/kvm4nfv_ci /mnt/ixia_results/kvm4nfv_ci -o password=kvm4nfv! -o username=kvm4nfv,file_mode=0777,dir_mode=0777,nounix +else + echo "shared directory is already mounted for results" +fi + +# check if user config file exists if not then we will use default settings +if [ -f $HOME/vsperf.conf ] ; then + CONF_FILE="--conf-file ${HOME}/vsperf.conf" + else + echo "configuration file not found on the test node" + echo "Using configuration file available in kvmfornfv repo" + CONF_FILE="--conf-file /root/workspace/scripts/vsperf.conf" +fi + +# check if sriov config file exists if not then we will use default settings +if [ -f $HOME/vsperf.conf.sriov ] ; then + CONF_FILE_SRIOV="--conf-file ${HOME}/vsperf.conf.sriov" + else + echo "SRIOV configuration file not found on the node" + echo "Using SRIOV configuration file available in kvmfornfv repo" + CONF_FILE="--conf-file /root/workspace/scripts/vsperf.conf.sriov" +fi + +function install_vsperf() { + echo "Installing vsperf....." + ( cd $VSPERF/systems ; ./build_base_machine.sh ) +} + +#Install kvmfornfv built qemu for launching guest vm. +function install_qemu() { + echo "removing existing qemu packages and installing kvmfornfv built qemu" + ( cd /root/workspace/scripts ; ./host-install-qemu.sh ) +} + +function print_results() { + for i in $TESTCASES ; do + RES_FILE=`ls -1 $1 | egrep "result_${i}_[0-9a-zA-Z\-]+.csv"` + + if [ "x$RES_FILE" != "x" -a -e "${1}/${RES_FILE}" ]; then + if grep ^FAILED "${1}/${RES_FILE}" &> /dev/null ; then + printf " %-70s %-6s\n" "result_${i}" "FAILED" + EXIT=$EXIT_TC_FAILED + else + echo "--------------------------------------------------------------" + printf " %-50s %-6s\n" "result_${i}" "OK" + echo "--------------------------------------------------------------" + fi + else + echo "------------------------------------------------------------------" + printf " %-50s %-6s\n" "result_${i}" "FAILED" + echo "------------------------------------------------------------------" + EXIT=$EXIT_TC_FAILED + fi + done +} + +function execute_vsperf() { + # figure out list of TCs and execution parameters + case $2 in + "daily") + TESTPARAM=$TESTPARAM_DAILY + TESTCASES=$TESTCASES_DAILY + ;; + *) + echo "No vsperf test cases implemented for this job type" + ;; + esac + + # execute testcases + echo -e "\nExecution of VSPERF for $1" + DATE_SUFFIX=$(date -u +"%Y-%m-%d_%H-%M-%S") + source "$VSPERFENV_DIR"/bin/activate + case $1 in + "SRIOV") + # use SRIOV specific TCs and configuration + TESTPARAM=$TESTPARAM_SRIOV + TESTCASES=$TESTCASES_SRIOV + # figure out log file name + LOG_SUBDIR="SRIOV" + LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log" + echo " $VSPERF_BIN --vswitch none --vnf QemuPciPassthrough $CONF_FILE_SRIOV $TESTPARAM $TESTCASES &> $LOG_FILE" + $VSPERF_BIN --vswitch none --vnf QemuPciPassthrough $CONF_FILE_SRIOV $TESTPARAM $TESTCASES &> $LOG_FILE + ;; + *) + # figure out log file name + LOG_SUBDIR="OvsDpdkVhost" + LOG_FILE="${LOG_FILE_PREFIX}_${LOG_SUBDIR}_${DATE_SUFFIX}.log" + echo " $VSPERF_BIN $OPNFVPOD --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES > $LOG_FILE" + echo "daily test cases started" + cd $HOME/vswitchperf + $VSPERF_BIN --list + $VSPERF_BIN --vswitch OvsDpdkVhost --vnf QemuDpdkVhostUser $CONF_FILE $TESTPARAM $TESTCASES &>> $LOG_FILE + ;; + esac + # evaluation of results + echo -e "\nResults for $1" + RES_DIR="/$(grep "Creating result directory" $LOG_FILE | cut -d'/' -f2-)" + if [[ "/" == "${RES_DIR}" ]] ; then + echo "FAILURE: Results are not available." + echo "-------------------------------------------------------------------" + cat $LOG_FILE + echo "-------------------------------------------------------------------" + exit $EXIT_NO_RESULTS + else + print_results "${RES_DIR}" + if [ $(($EXIT & $EXIT_TC_FAILED)) -gt 0 ] ; then + echo "-------------------------------------------------------------------" + cat $LOG_FILE + echo "-------------------------------------------------------------------" + fi + fi + # show detailed result figures + for md_file in $(grep '\.md"$' $LOG_FILE | cut -d'"' -f2); do + # TC resut file header + echo -e "\n-------------------------------------------------------------------" + echo -e " $md_file" + echo -e "-------------------------------------------------------------------\n" + # TC details + sed -n '/^- Test ID/,/Bidirectional/{/Packet size/b;p;/Bidirectional/q};/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file + # TC results + sed -n '/Results\/Metrics Collected/,/Statistics collected/{/^$/p;/^|/p}' $md_file | grep -v "Unknown" | cat -s + done + + # copy logs into dedicated directory + mkdir -p ${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR} + [ -f "$LOG_FILE" ] && cp -a "${LOG_FILE}" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null + [ -d "$RES_DIR" ] && cp -ar "$RES_DIR" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null +} + +#Install vsperf and set up the environment +install_vsperf + +#Install kvmfornfv built qemu rpm +install_qemu + +# execute job based on passed parameter +case $1 in + "daily") + echo "================" + echo "VSPERF daily job" + echo "================" + execute_vsperf OVS_with_DPDK_and_vHost_User $1 + execute_vsperf SRIOV $1 + exit $EXIT + ;; + *) + echo "test cases not implemented for this job type" +esac + +exit $EXIT + diff --git a/ci/envs/utils.sh b/ci/envs/utils.sh index 89df273ac..c2c0f85a6 100755 --- a/ci/envs/utils.sh +++ b/ci/envs/utils.sh @@ -39,4 +39,16 @@ function getQemuVersion { fi echo ${RPMVERSION} } - +#Check RPM names to continue the execution of testcases +function checkRPMNames { + rpm_dir="/root/workspace/rpm" + if [ -d "$WORKSPACE" ];then + cd $WORKSPACE/build_output 2>/dev/null;RPMCOUNT=`ls kvmfornfv-* 2>/dev/null | wc -l` + if [ $RPMCOUNT -ne 0 ];then + echo "Testcases are not executed for apex_build" + exit 0 + else + echo "Continue test execution" + fi + fi +} diff --git a/ci/test_kvmfornfv.sh b/ci/test_kvmfornfv.sh index 20bdaeefb..8199bf0e9 100755 --- a/ci/test_kvmfornfv.sh +++ b/ci/test_kvmfornfv.sh @@ -21,15 +21,28 @@ packetforward_result=0 #exit code of packet forward source $WORKSPACE/ci/envs/host-config function packetForward { -# source $WORKSPACE/ci/packet_forward_test.sh $HOST_IP - echo "Packetforwarding need to be implemented" - packetforward_result=$? - if [ ${packetforward_result} -ne 0 ];then - echo "Packet Forwarding test case execution FAILED" + #executing packet forwarding test cases based on the job type. + if [ ${test_type} == "verify" ];then + echo "packet forwarding test cases are not yet implemented for verify job" + packetforward_result=0 + elif [ ${test_type} == "daily" ];then + source $WORKSPACE/ci/cyclicTestTrigger.sh $HOST_IP + connect_host + #Waiting for ssh to be available for the host machine. + sleep 20 + # copy files and rpms and setup environment required for executing test cases + setUpPacketForwarding + sleep 1 + #Verifying whether the test node is up and running + connect_host + sleep 20 + #Install and Execute packet forwarding test cases + runPacketForwarding $test_type + packetforward_result=$? else - echo "Packet Forwarding test case executed SUCCESSFULLY" + echo "Incorrect test type ${test_type}" + exit 1 fi - host_clean } function cyclictest { @@ -38,19 +51,19 @@ function cyclictest { #Verifying whether the test node is up and running connect_host #Waiting for ssh to be available for the host machine. - sleep 10 + sleep 20 #calculating and verifying sha512sum of the guestimage. if ! verifyGuestImage;then exit 1 fi #Update kvmfornfv_cyclictest_${testName}.yaml with test_time and pod.yaml with IP updateYaml - #Cleaning up the test environment before running cyclictest through yardstick. - env_clean #Running PCM utility collect_MBWInfo $test_type + #Cleaning the environment before running cyclictest through yardstick + env_clean #Creating a docker image with yardstick installed and launching ubuntu docker to run yardstick cyclic testcase - if runCyclicTest;then + if runCyclicTest ${ftrace_enable};then cyclictest_result=`expr ${cyclictest_result} + 0` else echo "Test case execution FAILED for ${test_case} environment" @@ -92,13 +105,6 @@ function install_pcm { ' } -function ftrace_disable { - sudo ssh root@${HOST_IP} "sh /root/workspace/scripts/disbale-trace.sh" - sudo ssh root@${HOST_IP} "cd /tmp ; a=\$(ls -rt | tail -1) ; echo \$a ; mv \$a cyclictest_${env}.txt" - sudo mkdir -p $WORKSPACE/build_output/log/kernel_trace - sudo scp root@${HOST_IP}:/tmp/cyclictest_${env}.txt $WORKSPACE/build_output/log/kernel_trace/ -} - #Execution of testcases based on test type and test name from releng. if [ ${test_type} == "verify" ];then HOST_IP="10.10.100.21" @@ -108,11 +114,9 @@ if [ ${test_type} == "verify" ];then for env in ${cyclictest_env_verify[@]} do #Enabling ftrace for kernel debugging. - sed -i '/host-setup1.sh/a\ \- \"enable-trace.sh\"' kvmfornfv_cyclictest_hostenv_guestenv.yaml + sed -i '/host-setup1.sh/a\ \- \"enable-trace.sh\"' $WORKSPACE/tests/kvmfornfv_cyclictest_hostenv_guestenv.yaml #Executing cyclictest through yardstick. cyclictest ${env} - #disabling ftrace and collecting the logs to upload to artifact repository. - ftrace_disable sleep 10 done #Execution of packet forwarding test cases. @@ -127,22 +131,28 @@ if [ ${test_type} == "verify" ];then #Execution of packet forwarding test cases. packetForward fi - if [ ${cyclictest_result} -ne 0 ] || [ ${packetforward_result} -ne 0 ];then - echo "Test case FAILED" - err_exit 1 - else - err_exit 0 - fi + if [ ${cyclictest_result} -ne 0 ] || [ ${packetforward_result} -ne 0 ];then + echo "Test case FAILED" + test_exit 1 + else + test_exit 0 + fi elif [ ${test_type} == "daily" ];then HOST_IP="10.10.100.22" test_time=3600000 #1h install_pcm if [ ${test_name} == "packet_forward" ];then packetForward + packet_fwd_logs + #clean the test environment after the test case execution. + sudo ssh root@${HOST_IP} "rm -rf /root/workspace/*" + host_clean if [ ${packetforward_result} -ne 0 ] ; then - err_exit 1 + echo "Execution of packet forwarding test cases FAILED" + packet_fwd_exit 1 else - err_exit 0 + echo "Executed packet forwarding test cases SUCCESSFULLY" + packet_fwd_exit 0 fi elif [ ${test_name} == "cyclictest" ];then if [ ${ftrace_enable} -eq '1' ]; then @@ -166,10 +176,10 @@ elif [ ${test_type} == "daily" ];then fi if [ ${cyclictest_result} -ne 0 ] ; then echo "Cyclictest case execution FAILED" - err_exit 1 + test_exit 1 else echo "Cyclictest case executed SUCCESSFULLY" - err_exit 0 + test_exit 0 fi fi elif [ ${test_type} == "merge" ];then |