aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/tools/run.sh
blob: 6ba4a10204f09f138c889c1a7526b12789546f39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash

usage ()
{
cat <<EOF
Usage: run.sh [-y] [-?] Command
Optional arguments:
    -y
        Skips warning prompt.
    -?
        Shows help about this program.
    -s <suite>
        Test suite to use in testing mode.
    -c <case>
        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 "y?s: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 "./tools/run.sh -? for usage."
            exit 1
        fi
        test_suite=$OPTARG
        ;;
    c)
        if [ "$COMMAND" != "testing" ] ; then
            echo "Test case should only be specified in testing mode."
            echo "./tools/run.sh -? for usage."
            exit 1
        fi
        test_case=$OPTARG
        ;;
    ?)
        usage
        exit 0
        ;;
    esac
done

case $COMMAND in
    "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'
        ;;
    "testing" )
        export DEPLOY_MODE='testing'
        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/
        ;;
    * )
        usage
        exit 1
esac

vagrant destroy -f $COMMAND
vagrant up $COMMAND