X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=test%2Fbasictest.sh;h=2308377b081822cb6df5c8e15d852f312f7809e0;hb=ae6b3e6fe61e24460efa0f525803b398617892fa;hp=8b25448ddbdee3efc0db3e6ee0727f9b23d6821d;hpb=5acf7207caed77433a9ca3cb75c11128f417ae43;p=osm%2FRO.git diff --git a/test/basictest.sh b/test/basictest.sh index 8b25448d..2308377b 100755 --- a/test/basictest.sh +++ b/test/basictest.sh @@ -36,8 +36,10 @@ function usage(){ echo -e " OPTIONS:" echo -e " -f --force does not prompt for confirmation" echo -e " -h --help shows this help" + echo -e " --screen forces to run openmano (and openvim) service in a screen" echo -e " --insert-bashrc insert the created tenant,datacenter variables at" echo -e " ~/.bashrc to be available by openmano CLI" + echo -e " --install-openvim install openvim in test mode" echo -e " --init-openvim if openvim runs locally, an init is called to clean openvim" echo -e " database and add fake hosts" } @@ -48,55 +50,62 @@ function is_valid_uuid(){ } #detect if is called with a source to use the 'exit'/'return' command for exiting +DIRNAME=$(dirname $(readlink -f ${BASH_SOURCE[0]})) +DIRmano=$(dirname $DIRNAME) +DIRscript=${DIRmano}/scripts + [[ ${BASH_SOURCE[0]} != $0 ]] && _exit="return" || _exit="exit" +#process options +source ${DIRscript}/get-options.sh "force:f help:h insert-bashrc init-openvim install-openvim screen" $* || $_exit 1 + +#help +[ -n "$option_help" ] && usage && $_exit 0 + #check correct arguments -force="" +force_param="" && [[ -n "$option_force" ]] && force_param=" -f" +insert_bashrc_param="" && [[ -n "$option_insert_bashrc" ]] && insert_bashrc_param=" --insert-bashrc" +screen_mano_param="" && [[ -n "$option_screen" ]] && screen_mano_param=" --screen-name=mano" +screen_vim_param="" && [[ -n "$option_screen" ]] && screen_vim_param=" --screen-name=vim" + action_list="" -insert_bashrc="" -init_openvim="" -while [[ $# -gt 0 ]] +for argument in $params do - argument="$1" - shift - if [[ $argument == reset ]] || [[ $argument == create ]] || [[ $argument == delete ]] + if [[ $argument == reset ]] || [[ $argument == create ]] || [[ $argument == delete ]] || [[ -z "$argument" ]] then action_list="$action_list $argument" continue - #short options - elif [[ ${argument:0:1} == "-" ]] && [[ ${argument:1:1} != "-" ]] && [[ ${#argument} -ge 2 ]] - then - index=0 - while index=$((index+1)) && [[ $index -lt ${#argument} ]] - do - [[ ${argument:$index:1} == h ]] && usage && $_exit 0 - [[ ${argument:$index:1} == f ]] && force="-f" && continue - echo "invalid option '${argument:$index:1}'? Type -h for help" >&2 && $_exit 1 - done - continue fi - #long options - [[ $argument == --help ]] && usage && $_exit 0 - [[ $argument == --force ]] && force="-f" && continue - [[ $argument == --insert-bashrc ]] && insert_bashrc="--insert-bashrc" && continue - [[ $argument == --init-openvim ]] && init_openvim="y" && continue echo "invalid argument '$argument'? Type -h for help" >&2 && $_exit 1 done -DIRNAME=$(dirname $(readlink -f ${BASH_SOURCE[0]})) -DIRmano=$(dirname $DIRNAME) -DIRscript=${DIRmano}/scripts export OPENMANO_HOST=localhost export OPENMANO_PORT=9090 -[[ -n "$insert_bashrc" ]] && echo -e "\nexport OPENMANO_HOST=localhost" >> ~/.bashrc -[[ -n "$insert_bashrc" ]] && echo -e "\nexport OPENMANO_PORT=9090" >> ~/.bashrc +[[ -n "$option_insert_bashrc" ]] && echo -e "\nexport OPENMANO_HOST=localhost" >> ~/.bashrc +[[ -n "$option_insert_bashrc" ]] && echo -e "\nexport OPENMANO_PORT=9090" >> ~/.bashrc #by default action should be reset and create [[ -z $action_list ]] && action_list="reset create delete" -[[ -z $init_openvim ]] || initopenvim $force $insert_bashrc || echo "WARNING openvim cannot be initialized. The rest of test can fail!" + +if [[ -n "$option_install_openvim" ]] +then + mkdir -p ${DIRNAME}/local + pushd ${DIRNAME}/local + echo "installing openvim at ${DIRNAME}/openvim ... " + wget -O install-openvim.sh "https://osm.etsi.org/gitweb/?p=osm/openvim.git;a=blob_plain;f=scripts/install-openvim.sh" + chmod +x install-openvim.sh + sudo ./install-openvim.sh --no-install-packages --force --quiet --develop + export alias initopenvim="${PWD}/openvim/scripts/initopenvim.sh" + export alias openvim="${PWD}/openvim/scripts/openvim" + option_init_openvim="" + ${DIRNAME}/local/openvim/scripts/initopenvim.sh${force_param}${insert_bashrc_param}${screen_vim_param} || echo "WARNING openvim cannot be initialized. The rest of test can fail!" + + popd +fi +[[ -z "$option_init_openvim" ]] || initopenvim${force_param}${insert_bashrc_param}${screen_vim_param} || echo "WARNING openvim cannot be initialized. The rest of test can fail!" #check openvim client variables are set #fail="" @@ -120,15 +129,15 @@ then #ask for confirmation if argument is not -f --force force_=y - [[ -z $force ]] && read -e -p "WARNING: reset openmano database, content will be lost!!! Continue(y/N) " force_ + [[ -z "$option_force" ]] && read -e -p "WARNING: reset openmano database, content will be lost!!! Continue(y/N) " force_ [[ $force_ != y ]] && [[ $force_ != yes ]] && echo "aborted!" && $_exit echo "Stopping openmano" - $DIRscript/service-openmano.sh mano stop + $DIRscript/service-openmano mano stop${screen_mano_param} echo "Initializing openmano database" $DIRmano/database_utils/init_mano_db.sh -u mano -p manopw --createdb echo "Starting openmano" - $DIRscript/service-openmano.sh mano start + $DIRscript/service-openmano mano start${screen_mano_param} echo elif [[ $action == "delete" ]] @@ -141,16 +150,25 @@ then ${DIRmano}/openmano instance-scenario-delete -f simple-instance || echo "fail" ${DIRmano}/openmano instance-scenario-delete -f complex-instance || echo "fail" ${DIRmano}/openmano instance-scenario-delete -f complex2-instance || echo "fail" - ${DIRmano}/openmano scenario-delete -f simple || echo "fail" - ${DIRmano}/openmano scenario-delete -f complex || echo "fail" - ${DIRmano}/openmano scenario-delete -f complex2 || echo "fail" - ${DIRmano}/openmano vnf-delete -f linux || echo "fail" - ${DIRmano}/openmano vnf-delete -f dataplaneVNF_2VMs || echo "fail" - ${DIRmano}/openmano vnf-delete -f dataplaneVNF2 || echo "fail" - ${DIRmano}/openmano vnf-delete -f dataplaneVNF3 || echo "fail" - ${DIRmano}/openmano datacenter-detach TEST-dc || echo "fail" - ${DIRmano}/openmano datacenter-delete -f TEST-dc || echo "fail" - ${DIRmano}/openmano tenant-delete -f TEST-tenant || echo "fail" + ${DIRmano}/openmano instance-scenario-delete -f complex3-instance || echo "fail" + ${DIRmano}/openmano instance-scenario-delete -f complex4-instance || echo "fail" + ${DIRmano}/openmano instance-scenario-delete -f complex5-instance || echo "fail" + ${DIRmano}/openmano scenario-delete -f simple || echo "fail" + ${DIRmano}/openmano scenario-delete -f complex || echo "fail" + ${DIRmano}/openmano scenario-delete -f complex2 || echo "fail" + ${DIRmano}/openmano scenario-delete -f complex3 || echo "fail" + ${DIRmano}/openmano scenario-delete -f complex4 || echo "fail" + ${DIRmano}/openmano scenario-delete -f complex5 || echo "fail" + ${DIRmano}/openmano vnf-delete -f linux || echo "fail" + ${DIRmano}/openmano vnf-delete -f linux_2VMs_v02 || echo "fail" + ${DIRmano}/openmano vnf-delete -f dataplaneVNF_2VMs || echo "fail" + ${DIRmano}/openmano vnf-delete -f dataplaneVNF_2VMs_v02 || echo "fail" + ${DIRmano}/openmano vnf-delete -f dataplaneVNF4 || echo "fail" + ${DIRmano}/openmano vnf-delete -f dataplaneVNF2 || echo "fail" + ${DIRmano}/openmano vnf-delete -f dataplaneVNF3 || echo "fail" + ${DIRmano}/openmano datacenter-detach TEST-dc || echo "fail" + ${DIRmano}/openmano datacenter-delete -f TEST-dc || echo "fail" + ${DIRmano}/openmano tenant-delete -f TEST-tenant || echo "fail" echo elif [[ $action == "create" ]] @@ -161,24 +179,24 @@ then #check a valid uuid is obtained ! is_valid_uuid $nfvotenant && echo "FAIL" && echo " $result" && $_exit 1 export OPENMANO_TENANT=$nfvotenant - [[ -n "$insert_bashrc" ]] && echo -e "\nexport OPENMANO_TENANT=$nfvotenant" >> ~/.bashrc + [[ -n "$option_insert_bashrc" ]] && echo -e "\nexport OPENMANO_TENANT=$nfvotenant" >> ~/.bashrc echo $nfvotenant printf "%-50s" "Creating datacenter 'TEST-dc' in openmano:" [[ -z $OPENVIM_HOST ]] && OPENVIM_HOST=localhost [[ -z $OPENVIM_PORT ]] && OPENVIM_PORT=9080 URL_ADMIN_PARAM="" - [[ -n $OPENVIM_ADMIN_PORT ]] && URL_ADMIN_PARAM="--url_admin=http://${$OPENVIM_HOST}:${OPENVIM_ADMIN_PORT}/openvim" - result=`${DIRmano}/openmano datacenter-create TEST-dc "http://${OPENVIM_HOST}:${OPENVIM_PORT}/openvim" --type=openvim $URL_ADMIN_PARAM` + [[ -n $OPENVIM_ADMIN_PORT ]] && URL_ADMIN_PARAM=" --url_admin=http://${OPENVIM_HOST}:${OPENVIM_ADMIN_PORT}/openvim" + result=`${DIRmano}/openmano datacenter-create TEST-dc "http://${OPENVIM_HOST}:${OPENVIM_PORT}/openvim" --type=openvim${URL_ADMIN_PARAM} --config="{test: no use just for test}"` datacenter=`echo $result |gawk '{print $1}'` #check a valid uuid is obtained ! is_valid_uuid $datacenter && echo "FAIL" && echo " $result" && $_exit 1 echo $datacenter export OPENMANO_DATACENTER=$datacenter - [[ -n "$insert_bashrc" ]] && echo -e "\nexport OPENMANO_DATACENTER=$datacenter" >> ~/.bashrc + [[ -n "$option_insert_bashrc" ]] && echo -e "\nexport OPENMANO_DATACENTER=$datacenter" >> ~/.bashrc printf "%-50s" "Attaching openmano tenant to the datacenter:" - result=`${DIRmano}/openmano datacenter-attach TEST-dc` + result=`${DIRmano}/openmano datacenter-attach TEST-dc --config="{test: no use just for test}"` [[ $? != 0 ]] && echo "FAIL" && echo " $result" && $_exit 1 echo OK @@ -189,7 +207,7 @@ then [[ $? != 0 ]] && echo "FAIL" && echo " $result" && $_exit 1 echo OK - for VNF in linux dataplaneVNF1 dataplaneVNF2 dataplaneVNF_2VMs dataplaneVNF3 + for VNF in linux dataplaneVNF1 dataplaneVNF2 dataplaneVNF_2VMs dataplaneVNF_2VMs_v02 dataplaneVNF3 linux_2VMs_v02 dataplaneVNF4 do printf "%-50s" "Creating VNF '${VNF}': " result=`$DIRmano/openmano vnf-create $DIRmano/vnfs/examples/${VNF}.yaml` @@ -198,7 +216,7 @@ then ! is_valid_uuid $vnf && echo FAIL && echo " $result" && $_exit 1 echo $vnf done - for NS in simple complex complex2 + for NS in simple complex complex2 complex3 complex4 complex5 do printf "%-50s" "Creating scenario '${NS}':" result=`$DIRmano/openmano scenario-create $DIRmano/scenarios/examples/${NS}.yaml` @@ -207,7 +225,7 @@ then echo $scenario done - for IS in simple complex complex2 + for IS in simple complex complex2 complex3 complex5 do printf "%-50s" "Creating instance-scenario '${IS}':" result=`$DIRmano/openmano instance-scenario-create --scenario ${IS} --name ${IS}-instance` @@ -216,6 +234,12 @@ then echo $instance done + printf "%-50s" "Creating instance-scenario 'complex4':" + result=`$DIRmano/openmano instance-scenario-create $DIRmano/instance-scenarios/examples/instance-creation-complex4.yaml` + instance=`echo $result |gawk '{print $1}'` + ! is_valid_uuid $instance && echo FAIL && echo " $result" && $_exit 1 + echo $instance + echo #echo "Check virtual machines are deployed" #vms_error=`openvim vm-list | grep ERROR | wc -l`