Commit 44fe00d0 authored by Raphael Defosseux's avatar Raphael Defosseux

CI: unified VM scripting for option management

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent bf85f180
This diff is collapsed.
This diff is collapsed.
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
# * contact@openairinterface.org # * contact@openairinterface.org
# */ # */
function usage { function create_usage {
echo "OAI VM Creation script" echo "OAI CI VM script"
echo " Original Author: Raphael Defosseux" echo " Original Author: Raphael Defosseux"
echo " Requirements:" echo " Requirements:"
echo " -- uvtool uvtool-libvirt apt-cacher" echo " -- uvtool uvtool-libvirt apt-cacher"
...@@ -31,9 +31,9 @@ function usage { ...@@ -31,9 +31,9 @@ function usage {
echo "" echo ""
echo "Usage:" echo "Usage:"
echo "------" echo "------"
echo " createVM.sh [OPTIONS]" echo " oai-ci-vm-tool create [OPTIONS]"
echo "" echo ""
echo "Options:" echo "Mandatory Options:"
echo "--------" echo "--------"
echo " --job-name #### OR -jn ####" echo " --job-name #### OR -jn ####"
echo " Specify the name of the Jenkins job." echo " Specify the name of the Jenkins job."
...@@ -41,14 +41,7 @@ function usage { ...@@ -41,14 +41,7 @@ function usage {
echo " --build-id #### OR -id ####" echo " --build-id #### OR -id ####"
echo " Specify the build ID of the Jenkins job." echo " Specify the build ID of the Jenkins job."
echo "" echo ""
echo " --variant enb-usrp OR -v1" variant_usage
echo " --variant basic-sim OR -v2"
echo " --variant phy-sim OR -v3"
echo " --variant cppcheck OR -v4"
echo " --variant gnb-usrp OR -v5"
echo " --variant nu-ue-usrp OR -v6"
echo " --variant enb-ethernet OR -v7"
echo " --variant ue-ethernet OR -v8"
echo " Specify the variant to build." echo " Specify the variant to build."
echo "" echo ""
echo " --help OR -h" echo " --help OR -h"
...@@ -56,158 +49,21 @@ function usage { ...@@ -56,158 +49,21 @@ function usage {
echo "" echo ""
} }
function variant_usage { function create_vm {
echo "OAI VM Build Check script" echo "############################################################"
echo " Original Author: Raphael Defosseux" echo "OAI CI VM script"
echo "" echo "############################################################"
echo " --variant enb-usrp OR -v1" echo "VM_NAME = $VM_NAME"
echo " --variant basic-sim OR -v2" echo "VM_MEMORY = $VM_MEMORY MBytes"
echo " --variant phy-sim OR -v3" echo "VM_CPU = $VM_CPU"
echo " --variant cppcheck OR -v4"
echo " --variant gnb-usrp OR -v5"
echo " --variant nu-ue-usrp OR -v6"
echo " --variant enb-ethernet OR -v7"
echo " --variant ue-ethernet OR -v8"
echo ""
}
if [ $# -lt 1 ] || [ $# -gt 6 ]
then
echo "Syntax Error: not the correct number of arguments"
echo ""
usage
exit 1
fi
VM_TEMPLATE=ci-
JOB_NAME=XX
BUILD_ID=XX
VM_NAME=ci-enb-usrp
VM_MEMORY=2048
VM_CPU=4
while [[ $# -gt 0 ]]
do
key="$1"
case $key in echo "############################################################"
-h|--help) echo "Creating VM ($VM_NAME) on Ubuntu Cloud Image base"
shift echo "############################################################"
usage uvt-kvm create $VM_NAME release=xenial --memory $VM_MEMORY --cpu $VM_CPU --unsafe-caching --template ci-scripts/template-host.xml
exit 0 echo "Waiting for VM to be started"
;; uvt-kvm wait $VM_NAME --insecure
-jn|--job-name)
JOB_NAME="$2"
shift
shift
;;
-id|--build-id)
BUILD_ID="$2"
shift
shift
;;
-v1)
VM_NAME=ci-enb-usrp
shift
;;
-v2)
VM_NAME=ci-basic-sim
VM_MEMORY=8192
shift
;;
-v3)
VM_NAME=ci-phy-sim
shift
;;
-v4)
VM_NAME=ci-cppcheck
VM_MEMORY=8192
shift
;;
-v5)
VM_NAME=ci-gnb-usrp
shift
;;
-v6)
VM_NAME=ci-ue-nr-usrp
shift
;;
-v7)
VM_NAME=ci-enb-ethernet
shift
;;
-v8)
VM_NAME=ci-ue-ethernet
shift
;;
--variant)
variant="$2"
case $variant in
enb-usrp)
VM_NAME=ci-enb-usrp
;;
basic-sim)
VM_NAME=ci-basic-sim
VM_MEMORY=8192
;;
phy-sim)
VM_NAME=ci-phy-sim
;;
cppcheck)
VM_NAME=ci-cppcheck
VM_MEMORY=8192
;;
gnb-usrp)
VM_NAME=ci-gnb-usrp
;;
nu-ue-usrp)
VM_NAME=ci-ue-nr-usrp
;;
enb-ethernet)
VM_NAME=ci-enb-ethernet
;;
ue-ethernet)
VM_NAME=ci-ue-ethernet
;;
*)
echo ""
echo "Syntax Error: Invalid Variant option -> $variant"
echo ""
variant_usage
exit 1
esac
shift
shift
;;
*)
echo "Syntax Error: unknown option: $key"
echo ""
usage
exit 1
esac
done
if [ "$JOB_NAME" == "XX" ] || [ "$BUILD_ID" == "XX" ]
then
VM_TEMPLATE=ci-
else
VM_TEMPLATE=${JOB_NAME}-b${BUILD_ID}-
fi
VM_NAME=`echo $VM_NAME | sed -e "s#ci-#$VM_TEMPLATE#"` VM_IP_ADDR=`uvt-kvm ip $VM_NAME`
VM_CMDS=${VM_NAME}_cmds.txt echo "$VM_NAME has for IP addr = $VM_IP_ADDR"
}
echo "VM_NAME = $VM_NAME"
echo "VM_MEMORY = $VM_MEMORY MBytes"
echo "VM_CPU = $VM_CPU"
echo "############################################################"
echo "Creating VM ($VM_NAME) on Ubuntu Cloud Image base"
echo "############################################################"
uvt-kvm create $VM_NAME release=xenial --memory $VM_MEMORY --cpu $VM_CPU --unsafe-caching --template ci-scripts/template-host.xml
echo "Waiting for VM to be started"
uvt-kvm wait $VM_NAME --insecure
VM_IP_ADDR=`uvt-kvm ip $VM_NAME`
echo "$VM_NAME has for IP addr = $VM_IP_ADDR"
exit 0
...@@ -20,15 +20,17 @@ ...@@ -20,15 +20,17 @@
# * contact@openairinterface.org # * contact@openairinterface.org
# */ # */
function usage { function destroy_usage {
echo "OAI VM Destroy script" echo "OAI CI VM script"
echo " Original Author: Raphael Defosseux" echo " Original Author: Raphael Defosseux"
echo " Requirements:"
echo " -- uvtool uvtool-libvirt apt-cacher"
echo "" echo ""
echo "Usage:" echo "Usage:"
echo "------" echo "------"
echo " destroyAllRunningVM.sh [OPTIONS]" echo " oai-ci-vm-tool destroy [OPTIONS]"
echo "" echo ""
echo "Options:" echo "Mandatory Options:"
echo "--------" echo "--------"
echo " --job-name #### OR -jn ####" echo " --job-name #### OR -jn ####"
echo " Specify the name of the Jenkins job." echo " Specify the name of the Jenkins job."
...@@ -36,66 +38,26 @@ function usage { ...@@ -36,66 +38,26 @@ function usage {
echo " --build-id #### OR -id ####" echo " --build-id #### OR -id ####"
echo " Specify the build ID of the Jenkins job." echo " Specify the build ID of the Jenkins job."
echo "" echo ""
echo "Options:"
echo "--------"
echo " --help OR -h" echo " --help OR -h"
echo " Print this help message." echo " Print this help message."
echo "" echo ""
} }
if [ $# -gt 4 ] function destroy_vm {
then echo "############################################################"
echo "Syntax Error: not the correct number of arguments" echo "OAI CI VM script"
echo "" echo "############################################################"
usage echo "VM_TEMPLATE = $VM_TEMPLATE"
exit 1
fi
VM_TEMPLATE=ci-
JOB_NAME=XX
BUILD_ID=XX
while [[ $# -gt 0 ]] LIST_CI_VM=`uvt-kvm list | grep $VM_TEMPLATE`
do
key="$1"
case $key in
-h|--help)
shift
usage
exit 0
;;
-jn|--job-name)
JOB_NAME="$2"
shift
shift
;;
-id|--build-id)
BUILD_ID="$2"
shift
shift
;;
*)
echo "Syntax Error: unknown option: $key"
echo ""
usage
exit 1
esac
done
if [ "$JOB_NAME" == "XX" ] || [ "$BUILD_ID" == "XX" ] for CI_VM in $LIST_CI_VM
then do
VM_TEMPLATE=ci-
else
VM_TEMPLATE=${JOB_NAME}-b${BUILD_ID}-
fi
LIST_CI_VM=`uvt-kvm list | grep $VM_TEMPLATE`
for CI_VM in $LIST_CI_VM
do
VM_IP_ADDR=`uvt-kvm ip $CI_VM` VM_IP_ADDR=`uvt-kvm ip $CI_VM`
echo "VM to destroy: $CI_VM -- IP $VM_IP_ADDR" echo "VM to destroy: $CI_VM -- IP $VM_IP_ADDR"
uvt-kvm destroy $CI_VM uvt-kvm destroy $CI_VM
ssh-keygen -R $VM_IP_ADDR ssh-keygen -R $VM_IP_ADDR
done done
}
exit 0
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -20,15 +20,18 @@ ...@@ -20,15 +20,18 @@
# * contact@openairinterface.org # * contact@openairinterface.org
# */ # */
function usage { function run_test_usage {
echo "OAI VM Test Run script" echo "OAI CI VM script"
echo " Original Author: Raphael Defosseux" echo " Original Author: Raphael Defosseux"
echo " Requirements:"
echo " -- uvtool uvtool-libvirt apt-cacher"
echo " -- xenial image already synced"
echo " Default:" echo " Default:"
echo " -- eNB with USRP" echo " -- eNB with USRP"
echo "" echo ""
echo "Usage:" echo "Usage:"
echo "------" echo "------"
echo " runTestOnVM.sh [OPTIONS]" echo " oai-ci-vm-tool test [OPTIONS]"
echo "" echo ""
echo "Options:" echo "Options:"
echo "--------" echo "--------"
...@@ -41,12 +44,7 @@ function usage { ...@@ -41,12 +44,7 @@ function usage {
echo " --workspace #### OR -ws ####" echo " --workspace #### OR -ws ####"
echo " Specify the workspace." echo " Specify the workspace."
echo "" echo ""
echo " --variant enb-usrp OR -v1" variant_usage
echo " --variant basic-sim OR -v2"
echo " --variant phy-sim OR -v3"
echo " --variant cppcheck OR -v4"
echo " --variant enb-ethernet OR -v7"
echo " --variant ue-ethernet OR -v8"
echo " Specify the variant to build." echo " Specify the variant to build."
echo "" echo ""
echo " --keep-vm-alive OR -k" echo " --keep-vm-alive OR -k"
...@@ -57,19 +55,6 @@ function usage { ...@@ -57,19 +55,6 @@ function usage {
echo "" echo ""
} }
function variant_usage {
echo "OAI VM Test Run script"
echo " Original Author: Raphael Defosseux"
echo ""
echo " --variant enb-usrp OR -v1"
echo " --variant basic-sim OR -v2"
echo " --variant phy-sim OR -v3"
echo " --variant cppcheck OR -v4"
echo " --variant enb-ethernet OR -v7"
echo " --variant ue-ethernet OR -v8"
echo ""
}
function start_basic_sim_enb { function start_basic_sim_enb {
local LOC_VM_IP_ADDR=$2 local LOC_VM_IP_ADDR=$2
local LOC_EPC_IP_ADDR=$3 local LOC_EPC_IP_ADDR=$3
...@@ -95,6 +80,7 @@ function start_basic_sim_enb { ...@@ -95,6 +80,7 @@ function start_basic_sim_enb {
echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE\" > ./my-lte-softmodem-run.sh " >> $1 echo "echo \"ulimit -c unlimited && ./lte-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE\" > ./my-lte-softmodem-run.sh " >> $1
echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1 echo "chmod 775 ./my-lte-softmodem-run.sh" >> $1
echo "cat ./my-lte-softmodem-run.sh" >> $1 echo "cat ./my-lte-softmodem-run.sh" >> $1
echo "if [ -e /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE ]; then sudo sudo rm -f /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE; fi" >> $1
echo "sudo -E daemon --inherit --unsafe --name=enb_daemon --chdir=/home/ubuntu/tmp/cmake_targets/basic_simulator/enb -o /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE ./my-lte-softmodem-run.sh" >> $1 echo "sudo -E daemon --inherit --unsafe --name=enb_daemon --chdir=/home/ubuntu/tmp/cmake_targets/basic_simulator/enb -o /home/ubuntu/tmp/cmake_targets/log/$LOC_LOG_FILE ./my-lte-softmodem-run.sh" >> $1
ssh -o StrictHostKeyChecking=no ubuntu@$LOC_VM_IP_ADDR < $1 ssh -o StrictHostKeyChecking=no ubuntu@$LOC_VM_IP_ADDR < $1
...@@ -112,6 +98,7 @@ function start_basic_sim_ue { ...@@ -112,6 +98,7 @@ function start_basic_sim_ue {
echo "echo \"./lte-uesoftmodem -C ${LOC_FREQUENCY}000000 -r $LOC_NB_RBS --ue-rxgain 140\" > ./my-lte-uesoftmodem-run.sh" >> $1 echo "echo \"./lte-uesoftmodem -C ${LOC_FREQUENCY}000000 -r $LOC_NB_RBS --ue-rxgain 140\" > ./my-lte-uesoftmodem-run.sh" >> $1
echo "chmod 775 ./my-lte-uesoftmodem-run.sh" >> $1 echo "chmod 775 ./my-lte-uesoftmodem-run.sh" >> $1
echo "cat ./my-lte-uesoftmodem-run.sh" >> $1 echo "cat ./my-lte-uesoftmodem-run.sh" >> $1
echo "if [ -e /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE ]; then sudo sudo rm -f /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE; fi" >> $1
echo "sudo -E daemon --inherit --unsafe --name=ue_daemon --chdir=/home/ubuntu/tmp/cmake_targets/basic_simulator/ue -o /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE ./my-lte-uesoftmodem-run.sh" >> $1 echo "sudo -E daemon --inherit --unsafe --name=ue_daemon --chdir=/home/ubuntu/tmp/cmake_targets/basic_simulator/ue -o /home/ubuntu/tmp/cmake_targets/log/$LOC_UE_LOG_FILE ./my-lte-uesoftmodem-run.sh" >> $1
ssh -o StrictHostKeyChecking=no ubuntu@$2 < $1 ssh -o StrictHostKeyChecking=no ubuntu@$2 < $1
...@@ -299,155 +286,31 @@ function terminate_ltebox_epc { ...@@ -299,155 +286,31 @@ function terminate_ltebox_epc {
rm $1 rm $1
} }
if [ $# -lt 1 ] || [ $# -gt 9 ] function run_test_on_vm {
then echo "############################################################"
echo "Syntax Error: not the correct number of arguments" echo "OAI CI VM script"
echo "" echo "############################################################"
usage echo "VM_NAME = $VM_NAME"
exit 1 echo "VM_CMD_FILE = $VM_CMDS"
fi echo "JENKINS_WKSP = $JENKINS_WKSP"
echo "ARCHIVES_LOC = $ARCHIVES_LOC"
VM_TEMPLATE=ci-
JOB_NAME=XX echo "############################################################"
BUILD_ID=XX echo "Waiting for VM to be started"
VM_NAME=ci-enb-usrp echo "############################################################"
ARCHIVES_LOC=enb_usrp/test uvt-kvm wait $VM_NAME --insecure
KEEP_VM_ALIVE=0
RUN_OPTIONS="none" VM_IP_ADDR=`uvt-kvm ip $VM_NAME`
STATUS=0 echo "$VM_NAME has for IP addr = $VM_IP_ADDR"
while [[ $# -gt 0 ]] if [ "$RUN_OPTIONS" == "none" ]
do then
key="$1"
case $key in
-h|--help)
shift
usage
exit 0
;;
-jn|--job-name)
JOB_NAME="$2"
shift
shift
;;
-id|--build-id)
BUILD_ID="$2"
shift
shift
;;
-ws|--workspace)
JENKINS_WKSP="$2"
shift
shift
;;
-k|--keep-vm-alive)
KEEP_VM_ALIVE=1
shift
;;
-v1)
VM_NAME=ci-enb-usrp
shift
;;
-v2)
VM_NAME=ci-basic-sim
RUN_OPTIONS="complex"
ARCHIVES_LOC=basic_sim/test
shift
;;
-v3)
VM_NAME=ci-phy-sim
RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b"
ARCHIVES_LOC=phy_sim/test
shift
;;
-v4)
VM_NAME=ci-cppcheck
shift
;;
-v7)
VM_NAME=ci-enb-ethernet
shift
;;
-v8)
VM_NAME=ci-ue-ethernet
shift
;;
--variant)
variant="$2"
case $variant in
enb-usrp)
VM_NAME=ci-enb-usrp
;;
basic-sim)
VM_NAME=ci-basic-sim
RUN_OPTIONS="complex"
ARCHIVES_LOC=basic_sim/test
;;
phy-sim)
VM_NAME=ci-phy-sim
RUN_OPTIONS="./run_exec_autotests.bash -g \"01510*\" -q -np -b"
ARCHIVES_LOC=phy_sim/test
;;
cppcheck)
VM_NAME=ci-cppcheck
;;
enb-ethernet)
VM_NAME=ci-enb-ethernet
;;
ue-ethernet)
VM_NAME=ci-ue-ethernet
;;
*)
echo ""
echo "Syntax Error: Invalid Variant option -> $variant"
echo ""
variant_usage
exit 1
esac
shift
shift
;;
*)
echo "Syntax Error: unknown option: $key"
echo ""
usage
exit 1
esac
done
if [ "$JOB_NAME" == "XX" ] || [ "$BUILD_ID" == "XX" ]
then
VM_TEMPLATE=ci-
else
VM_TEMPLATE=${JOB_NAME}-b${BUILD_ID}-
fi
VM_NAME=`echo $VM_NAME | sed -e "s#ci-#$VM_TEMPLATE#"`
VM_CMDS=${VM_NAME}_cmds.txt
ARCHIVES_LOC=${JENKINS_WKSP}/archives/${ARCHIVES_LOC}
echo "VM_NAME = $VM_NAME"
echo "VM_CMD_FILE = $VM_CMDS"
echo "JENKINS_WKSP = $JENKINS_WKSP"
echo "ARCHIVES_LOC = $ARCHIVES_LOC"
echo "############################################################"
echo "Waiting for VM to be started"
echo "############################################################"
uvt-kvm wait $VM_NAME --insecure
VM_IP_ADDR=`uvt-kvm ip $VM_NAME`
echo "$VM_NAME has for IP addr = $VM_IP_ADDR"
if [ "$RUN_OPTIONS" == "none" ]
then
echo "No run on VM testing for this variant currently" echo "No run on VM testing for this variant currently"
exit $STATUS exit $STATUS
fi fi
if [[ $RUN_OPTIONS =~ .*run_exec_autotests.* ]] if [[ $RUN_OPTIONS =~ .*run_exec_autotests.* ]]
then then
echo "############################################################" echo "############################################################"
echo "Running test script on VM ($VM_NAME)" echo "Running test script on VM ($VM_NAME)"
echo "############################################################" echo "############################################################"
...@@ -542,10 +405,10 @@ then ...@@ -542,10 +405,10 @@ then
if [ $NB_RUNS -eq 0 ]; then STATUS=-1; fi if [ $NB_RUNS -eq 0 ]; then STATUS=-1; fi
if [ $NB_FAILURES -ne 0 ]; then STATUS=-1; fi if [ $NB_FAILURES -ne 0 ]; then STATUS=-1; fi
fi fi
if [[ "$RUN_OPTIONS" == "complex" ]] && [[ $VM_NAME =~ .*-basic-sim.* ]] if [[ "$RUN_OPTIONS" == "complex" ]] && [[ $VM_NAME =~ .*-basic-sim.* ]]
then then
PING_STATUS=0 PING_STATUS=0
IPERF_STATUS=0 IPERF_STATUS=0
if [ -d $ARCHIVES_LOC ] if [ -d $ARCHIVES_LOC ]
...@@ -1019,6 +882,17 @@ then ...@@ -1019,6 +882,17 @@ then
terminate_ltebox_epc $EPC_VM_CMDS $EPC_VM_IP_ADDR terminate_ltebox_epc $EPC_VM_CMDS $EPC_VM_IP_ADDR
fi fi
if [ $KEEP_VM_ALIVE -eq 0 ]
then
echo "############################################################"
echo "Destroying VMs"
echo "############################################################"
uvt-kvm destroy $VM_NAME
ssh-keygen -R $VM_IP_ADDR
uvt-kvm destroy $EPC_VM_NAME
ssh-keygen -R $EPC_VM_IP_ADDR
fi
echo "############################################################" echo "############################################################"
echo "Checking run status" echo "Checking run status"
echo "############################################################" echo "############################################################"
...@@ -1026,13 +900,5 @@ then ...@@ -1026,13 +900,5 @@ then
if [ $PING_STATUS -ne 0 ]; then STATUS=-1; fi if [ $PING_STATUS -ne 0 ]; then STATUS=-1; fi
if [ $IPERF_STATUS -ne 0 ]; then STATUS=-1; fi if [ $IPERF_STATUS -ne 0 ]; then STATUS=-1; fi
fi fi
}
if [ $STATUS -eq 0 ]
then
echo "STATUS seems OK"
else
echo "STATUS failed?"
fi
exit $STATUS
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment