blob: aeb9d8c49543a30ab05e505fff6d519f2f55c104 [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
Nate Potter8a0c9452017-08-02 15:17:41 -07003usage ()
4{
5cat <<EOF
6Usage: run.sh [-y] [-h] Command
7Optional arguments:
8 -y
9 Skips warning prompt.
10 -h
11 Shows help about this program.
12 -s <suite>
13 Test suite to use in testing mode.
14 -c <case>
15 Test case to use in testing mode.
16Commands:
17 all_in_one Deploy in all-in-one mode.
18 dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc Deploy chosen service.
19 testing Deploy in testing mode.
20EOF
21}
22
23run=false
24test_suite="*"
25test_case="*"
26
27COMMAND=${@: -1}
28
29while getopts "yhs:c:" OPTION; do
30 case "$OPTION" in
31 y)
32 run=true
33 ;;
34 s)
35 if [ "$COMMAND" != "testing" ] ; then
36 echo "Test suite should only be specified in testing mode."
37 echo "./run.sh -h for usage."
38 exit 0
39 fi
40 test_suite=$OPTARG
41 ;;
42 c)
43 if [ "$COMMAND" != "testing" ] ; then
44 echo "Test case should only be specified in testing mode."
45 echo "./run.sh -h for usage."
46 exit 0
47 fi
48 test_case=$OPTARG
49 ;;
50 h)
51 usage
52 exit 0
53 ;;
54 esac
55done
56
57case $COMMAND in
Victor Moralesdd074802017-07-26 16:06:35 -050058 "all_in_one" )
Nate Potter8a0c9452017-08-02 15:17:41 -070059 export DEPLOY_MODE='all-in-one'
60 ;;
Victor Moralesdd074802017-07-26 16:06:35 -050061 "dns" | "mr" | "sdc" | "aai" | "mso" | "robot" | "vid" | "sdnc" | "portal" | "dcae" | "policy" | "appc" )
Nate Potter8a0c9452017-08-02 15:17:41 -070062 export DEPLOY_MODE='individual'
63 ;;
Victor Moralesdd074802017-07-26 16:06:35 -050064 "testing" )
65 export DEPLOY_MODE='testing'
Nate Potter8a0c9452017-08-02 15:17:41 -070066 if [ "$run" == false ] ; then
67 while true ; do
68 echo "Warning: This test script will delete the contents of ../opt/ and ~/.m2."
69 read -p "Would you like to continue? [y]es/[n]o: " yn
70 case $yn in
71 [Yy]*)
72 break
73 ;;
74 [Nn]*)
75 echo "Exiting."
76 exit 0
77 ;;
78 esac
79 done
80 fi
Victor Moralesdd074802017-07-26 16:06:35 -050081
Nate Potter8a0c9452017-08-02 15:17:41 -070082 export TEST_SUITE=$test_suite
83 export TEST_CASE=$test_case
Victor Moralesdd074802017-07-26 16:06:35 -050084 rm -rf ../opt/
Nate Potter8a0c9452017-08-02 15:17:41 -070085 rm -rf ~/.m2/
86 ;;
Victor Morales20163062017-08-09 10:50:44 -050087 * )
Nate Potter8a0c9452017-08-02 15:17:41 -070088 usage
Victor Morales20163062017-08-09 10:50:44 -050089 exit 1
Victor Moralesdd074802017-07-26 16:06:35 -050090esac
Nate Potter8a0c9452017-08-02 15:17:41 -070091
92vagrant destroy -f $COMMAND
93vagrant up $COMMAND