blob: 094577fb1b5ffa9a0c48f2b95cbfa66f596d11a9 [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
Victor Morales90e9c742017-08-15 18:12:12 -05003function usage {
4 cat <<EOF
5Usage: run.sh Command [-y] [-?]
Nate Potter8a0c9452017-08-02 15:17:41 -07006Optional arguments:
7 -y
8 Skips warning prompt.
Nate Potter8a0c9452017-08-02 15:17:41 -07009 -s <suite>
10 Test suite to use in testing mode.
11 -c <case>
12 Test case to use in testing mode.
13Commands:
14 all_in_one Deploy in all-in-one mode.
Victor Morales000de532017-08-31 17:28:10 -050015 dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|vfc|multicloud Deploy chosen service.
Nate Potter8a0c9452017-08-02 15:17:41 -070016 testing Deploy in testing mode.
17EOF
18}
19
20run=false
21test_suite="*"
22test_case="*"
23
Victor Morales90e9c742017-08-15 18:12:12 -050024COMMAND=$1
Nate Potter8a0c9452017-08-02 15:17:41 -070025
Victor Morales90e9c742017-08-15 18:12:12 -050026while getopts "ys:c:" OPTION "${@:2}"; do
Victor Morales5d5c5da2017-08-15 16:24:05 -050027 case "$OPTION" in
Nate Potter8a0c9452017-08-02 15:17:41 -070028 y)
Victor Morales5d5c5da2017-08-15 16:24:05 -050029 run=true
30 ;;
Nate Potter8a0c9452017-08-02 15:17:41 -070031 s)
Victor Morales5d5c5da2017-08-15 16:24:05 -050032 if [ "$COMMAND" != "testing" ] ; then
33 echo "Test suite should only be specified in testing mode."
34 echo "./tools/run.sh -? for usage."
35 exit 1
36 fi
37 test_suite=$OPTARG
38 ;;
Nate Potter8a0c9452017-08-02 15:17:41 -070039 c)
Victor Morales5d5c5da2017-08-15 16:24:05 -050040 if [ "$COMMAND" != "testing" ] ; then
41 echo "Test case should only be specified in testing mode."
42 echo "./tools/run.sh -? for usage."
43 exit 1
44 fi
45 test_case=$OPTARG
46 ;;
Victor Morales90e9c742017-08-15 18:12:12 -050047 \?)
Victor Morales5d5c5da2017-08-15 16:24:05 -050048 usage
Victor Morales90e9c742017-08-15 18:12:12 -050049 exit 1
Victor Morales5d5c5da2017-08-15 16:24:05 -050050 ;;
51 esac
Nate Potter8a0c9452017-08-02 15:17:41 -070052done
53
54case $COMMAND in
Victor Moralesdd074802017-07-26 16:06:35 -050055 "all_in_one" )
Nate Potter8a0c9452017-08-02 15:17:41 -070056 export DEPLOY_MODE='all-in-one'
57 ;;
Victor Morales000de532017-08-31 17:28:10 -050058 "dns" | "mr" | "sdc" | "aai" | "mso" | "robot" | "vid" | "sdnc" | "portal" | "dcae" | "policy" | "appc" | "vfc" | "multicloud" )
Nate Potter8a0c9452017-08-02 15:17:41 -070059 export DEPLOY_MODE='individual'
60 ;;
Victor Moralesdd074802017-07-26 16:06:35 -050061 "testing" )
62 export DEPLOY_MODE='testing'
Nate Potter8a0c9452017-08-02 15:17:41 -070063 if [ "$run" == false ] ; then
Victor Morales5d5c5da2017-08-15 16:24:05 -050064 while true ; do
65 echo "Warning: This test script will delete the contents of ../opt/ and ~/.m2."
66 read -p "Would you like to continue? [y]es/[n]o: " yn
67 case $yn in
68 [Yy]*)
69 break
70 ;;
71 [Nn]*)
72 echo "Exiting."
73 exit 0
74 ;;
75 esac
76 done
Nate Potter8a0c9452017-08-02 15:17:41 -070077 fi
Victor Moralesdd074802017-07-26 16:06:35 -050078
Nate Potter8a0c9452017-08-02 15:17:41 -070079 export TEST_SUITE=$test_suite
80 export TEST_CASE=$test_case
Victor Morales80ef0a42017-08-21 19:17:07 -050081 rm -rf ./opt/
Nate Potter8a0c9452017-08-02 15:17:41 -070082 rm -rf ~/.m2/
83 ;;
Victor Morales20163062017-08-09 10:50:44 -050084 * )
Nate Potter8a0c9452017-08-02 15:17:41 -070085 usage
Victor Morales20163062017-08-09 10:50:44 -050086 exit 1
Victor Moralesdd074802017-07-26 16:06:35 -050087esac
Nate Potter8a0c9452017-08-02 15:17:41 -070088
89vagrant destroy -f $COMMAND
90vagrant up $COMMAND