X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=test%2Fbasictest.sh;h=43267c3ec5c8a2751e3ce1df38ddbf28c9827791;hb=6460dfae2ad09b62ba0078eacea293ebf7bd6742;hp=d7aa341b6d5f21bb058bb3df3298f48fc7609f18;hpb=96d9cd4e57f70a19414eac72595630212575afd7;p=osm%2FRO.git diff --git a/test/basictest.sh b/test/basictest.sh index d7aa341b..43267c3e 100755 --- a/test/basictest.sh +++ b/test/basictest.sh @@ -28,6 +28,7 @@ function usage(){ echo -e "usage: ${BASH_SOURCE[0]} [OPTIONS] \n test openmano using openvim as a VIM" echo -e " the OPENVIM_HOST, OPENVIM_PORT shell variables indicate openvim location" + echo -e " by default localhost:9080" echo -e " is a list of the following items (by default 'reset create delete')" echo -e " reset reset the openmano database content" echo -e " create creates items" @@ -37,8 +38,8 @@ function usage(){ echo -e " -h --help shows this help" echo -e " --insert-bashrc insert the created tenant,datacenter variables at" echo -e " ~/.bashrc to be available by openmano CLI" - echo -e " --init-openvim if openvim runs locally, an init is called to clean openvim database" - echo -e " and add fake hosts" + echo -e " --init-openvim if openvim runs locally, an init is called to clean openvim" + echo -e " database and add fake hosts" } function is_valid_uuid(){ @@ -47,48 +48,62 @@ function is_valid_uuid(){ } #detect if is called with a source to use the 'exit'/'return' command for exiting -[[ ${BASH_SOURCE[0]} != $0 ]] && _exit="return" || _exit="exit" +[[ ${BASH_SOURCE[0]} != $0 ]] && _exit="return" || _exit="exit" -#check openvim client variables are set -fail="" -[[ -z $OPENVIM_HOST ]] && echo "OPENVIM_HOST variable not defined" >&2 && fail=1 -[[ -z $OPENVIM_PORT ]] && echo "OPENVIM_PORT variable not defined" >&2 && fail=1 -[[ -n $fail ]] && $_exit 1 #check correct arguments force="" action_list="" insert_bashrc="" init_openvim="" -for param in $* + +while [[ $# -gt 0 ]] do - if [[ $param == reset ]] || [[ $param == create ]] || [[ $param == delete ]] - then - action_list="$action_list $param" - elif [[ $param == -h ]] || [[ $param == --help ]] + argument="$1" + shift + if [[ $argument == reset ]] || [[ $argument == create ]] || [[ $argument == delete ]] then - usage - $_exit 0 - elif [[ $param == -f ]] || [[ $param == --force ]] + action_list="$action_list $argument" + continue + #short options + elif [[ ${argument:0:1} == "-" ]] && [[ ${argument:1:1} != "-" ]] && [[ ${#argument} -ge 2 ]] then - force="-f" - elif [[ $param == --insert-bashrc ]] - then - insert_bashrc=y - elif [[ $param == --init-openvim ]] - then - init_openvim=y - else - echo "invalid argument '$param'? Type -h for help" >&2 && $_exit 1 + 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 + + #by default action should be reset and create [[ -z $action_list ]] && action_list="reset create delete" -[[ -z $init_openvim ]] || initopenvim $force || echo "WARNING openvim cannot be initialized. The rest of test can fail!" +[[ -z $init_openvim ]] || initopenvim $force $insert_bashrc || echo "WARNING openvim cannot be initialized. The rest of test can fail!" + +#check openvim client variables are set +#fail="" +#[[ -z $OPENVIM_HOST ]] && echo "OPENVIM_HOST variable not defined" >&2 && fail=1 +#[[ -z $OPENVIM_PORT ]] && echo "OPENVIM_PORT variable not defined" >&2 && fail=1 +#[[ -n $fail ]] && $_exit 1 + for action in $action_list do @@ -104,13 +119,14 @@ if [[ $action == "reset" ]] 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_ [[ $force_ != y ]] && [[ $force_ != yes ]] && echo "aborted!" && $_exit echo "Stopping openmano" $DIRscript/service-openmano.sh mano stop echo "Initializing openmano database" - $DIRmano/database_utils/init_mano_db.sh -u mano -p manopw + $DIRmano/database_utils/init_mano_db.sh -u mano -p manopw --createdb echo "Starting openmano" $DIRscript/service-openmano.sh mano start echo @@ -125,16 +141,22 @@ 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 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 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 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" ]] @@ -145,7 +167,7 @@ then #check a valid uuid is obtained ! is_valid_uuid $nfvotenant && echo "FAIL" && echo " $result" && $_exit 1 export OPENMANO_TENANT=$nfvotenant - [[ $insert_bashrc == y ]] && echo -e "\nexport OPENMANO_TENANT=$nfvotenant" >> ~/.bashrc + [[ -n "$insert_bashrc" ]] && echo -e "\nexport OPENMANO_TENANT=$nfvotenant" >> ~/.bashrc echo $nfvotenant printf "%-50s" "Creating datacenter 'TEST-dc' in openmano:" @@ -159,7 +181,7 @@ then ! is_valid_uuid $datacenter && echo "FAIL" && echo " $result" && $_exit 1 echo $datacenter export OPENMANO_DATACENTER=$datacenter - [[ $insert_bashrc == y ]] && echo -e "\nexport OPENMANO_DATACENTER=$datacenter" >> ~/.bashrc + [[ -n "$insert_bashrc" ]] && echo -e "\nexport OPENMANO_DATACENTER=$datacenter" >> ~/.bashrc printf "%-50s" "Attaching openmano tenant to the datacenter:" result=`${DIRmano}/openmano datacenter-attach TEST-dc` @@ -169,11 +191,11 @@ then printf "%-50s" "Updating external nets in openmano: " result=`${DIRmano}/openmano datacenter-netmap-delete -f --all` [[ $? != 0 ]] && echo "FAIL" && echo " $result" && $_exit 1 - result=`${DIRmano}/openmano datacenter-netmap-upload -f` + result=`${DIRmano}/openmano datacenter-netmap-import -f` [[ $? != 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 do printf "%-50s" "Creating VNF '${VNF}': " result=`$DIRmano/openmano vnf-create $DIRmano/vnfs/examples/${VNF}.yaml` @@ -182,7 +204,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 do printf "%-50s" "Creating scenario '${NS}':" result=`$DIRmano/openmano scenario-create $DIRmano/scenarios/examples/${NS}.yaml` @@ -191,7 +213,7 @@ then echo $scenario done - for IS in simple complex complex2 + for IS in simple complex complex2 complex3 do printf "%-50s" "Creating instance-scenario '${IS}':" result=`$DIRmano/openmano instance-scenario-create --scenario ${IS} --name ${IS}-instance` @@ -200,6 +222,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`