X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=test%2Fbasictest.sh;h=8b25448ddbdee3efc0db3e6ee0727f9b23d6821d;hb=be41e22d64055e9ee71e3f4d6d7ca99225a679fb;hp=91e87ec4f343fab30fca7ce826b263087c72ac0b;hpb=b6884bd2091740e7f5c3a2dee78333194fb29a92;p=osm%2FRO.git diff --git a/test/basictest.sh b/test/basictest.sh index 91e87ec4..8b25448d 100755 --- a/test/basictest.sh +++ b/test/basictest.sh @@ -56,27 +56,33 @@ 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 ]] - then - usage - $_exit 0 - elif [[ $param == -f ]] || [[ $param == --force ]] - then - force="-f" - elif [[ $param == --insert-bashrc ]] + argument="$1" + shift + if [[ $argument == reset ]] || [[ $argument == create ]] || [[ $argument == delete ]] then - insert_bashrc=y - elif [[ $param == --init-openvim ]] + action_list="$action_list $argument" + continue + #short options + elif [[ ${argument:0:1} == "-" ]] && [[ ${argument:1:1} != "-" ]] && [[ ${#argument} -ge 2 ]] 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]})) @@ -84,13 +90,13 @@ DIRmano=$(dirname $DIRNAME) DIRscript=${DIRmano}/scripts export OPENMANO_HOST=localhost export OPENMANO_PORT=9090 -[[ $insert_bashrc == y ]] && echo -e "\nexport OPENMANO_HOST=localhost" >> ~/.bashrc -[[ $insert_bashrc == y ]] && echo -e "\nexport OPENMANO_PORT=9090" >> ~/.bashrc +[[ -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="" @@ -120,7 +126,7 @@ then 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 @@ -155,7 +161,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:" @@ -169,7 +175,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` @@ -179,7 +185,7 @@ 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