From 8a0c9450a19892d4254e2b69d04f3b84007b700b Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Wed, 2 Aug 2017 15:17:41 -0700 Subject: Add warnings and options to run.sh Adds a warning to run.sh informing the user that the contents of their /opt folder will be deleted by the test. Also adds option parsing, -y for skipping the prompt, -s for test suite selection, -c for test case selection, as well as -h for displaying help for the program. Change-Id: I888350d31839bd6db91a497a04ae3308af5329e9 Issue-Id: INT-97 Signed-off-by: Nate Potter --- bootstrap/vagrant-onap/tools/run.sh | 91 +++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 9 deletions(-) (limited to 'bootstrap/vagrant-onap/tools') diff --git a/bootstrap/vagrant-onap/tools/run.sh b/bootstrap/vagrant-onap/tools/run.sh index b9a4a4311..aeb9d8c49 100755 --- a/bootstrap/vagrant-onap/tools/run.sh +++ b/bootstrap/vagrant-onap/tools/run.sh @@ -1,20 +1,93 @@ #!/bin/bash -case $1 in +usage () +{ +cat < + Test suite to use in testing mode. + -c + Test case to use in testing mode. +Commands: + all_in_one Deploy in all-in-one mode. + dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc Deploy chosen service. + testing Deploy in testing mode. +EOF +} + +run=false +test_suite="*" +test_case="*" + +COMMAND=${@: -1} + +while getopts "yhs:c:" OPTION; do + case "$OPTION" in + y) + run=true + ;; + s) + if [ "$COMMAND" != "testing" ] ; then + echo "Test suite should only be specified in testing mode." + echo "./run.sh -h for usage." + exit 0 + fi + test_suite=$OPTARG + ;; + c) + if [ "$COMMAND" != "testing" ] ; then + echo "Test case should only be specified in testing mode." + echo "./run.sh -h for usage." + exit 0 + fi + test_case=$OPTARG + ;; + h) + usage + exit 0 + ;; + esac +done + +case $COMMAND in "all_in_one" ) - export DEPLOY_MODE='all-in-one' ;; + export DEPLOY_MODE='all-in-one' + ;; "dns" | "mr" | "sdc" | "aai" | "mso" | "robot" | "vid" | "sdnc" | "portal" | "dcae" | "policy" | "appc" ) - export DEPLOY_MODE='individual' ;; + export DEPLOY_MODE='individual' + ;; "testing" ) export DEPLOY_MODE='testing' - export TEST_SUITE=${2:-*} - export TEST_CASE=${3:-*} + if [ "$run" == false ] ; then + while true ; do + echo "Warning: This test script will delete the contents of ../opt/ and ~/.m2." + read -p "Would you like to continue? [y]es/[n]o: " yn + case $yn in + [Yy]*) + break + ;; + [Nn]*) + echo "Exiting." + exit 0 + ;; + esac + done + fi + export TEST_SUITE=$test_suite + export TEST_CASE=$test_case rm -rf ../opt/ - rm -rf ~/.m2/;; + rm -rf ~/.m2/ + ;; * ) - echo $"Usage: $0 {all_in_one|dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|testing}" + usage exit 1 esac -vagrant destroy -f $1 -vagrant up $1 + +vagrant destroy -f $COMMAND +vagrant up $COMMAND -- cgit 1.2.3-korg