aboutsummaryrefslogtreecommitdiffstats
path: root/tools/Run.ps1
blob: 9e996075312d9eb6f6c3c032933d36663df9975a (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<#
.SYNOPSIS
This script helps to configure its environment variables based on the component selected.

.EXAMPLE
.\tools\Run.ps1 testing -s functions -c install_maven -y

.EXAMPLE
.\tools\Run.ps1 all_in_one

.EXAMPLE
.\tools\Run.ps1 aai

.PARAMETER s
Test suite to use in testing mode.

.PARAMETER c
Test case to use in testing mode.

.PARAMETER y
Skips warning prompt.

.PARAMETER g
Skips creation or retrieve image process.

.PARAMETER i
Skips installation service process.

.LINK
https://wiki.onap.org/display/DW/ONAP+on+Vagrant
#>

Param(
    [ValidateSet("all-in-one","dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc", "vfc", "multicloud", "ccsdk", "vnfsdk", "vvp", "openstack", "msb", "oom", "dmaap", "testing")]

    [Parameter(Mandatory=$True,Position=0)]
    [ValidateNotNullOrEmpty()]
    [String]
    $Command
,
    [Parameter(Mandatory=$False,HelpMessage="Test suite to use in testing mode.")]
    [Alias("suite")]
    [String]
    $s = "*"
,
    [Parameter(Mandatory=$False,HelpMessage="Test case to sue in testing mode.")]
    [Alias("case")]
    [String]
    $c = "*"
,
    [Parameter(Mandatory=$False,HelpMessage="Skips warning prompt.")]
    [AllowNull()]
    [Switch]
    $y = $True
,
    [Parameter(Mandatory=$False,HelpMessage="Skips creation or retrieve image process.")]
    [AllowNull()]
    [Switch]
    $skip_get_images = $True
,
    [Parameter(Mandatory=$False,HelpMessage="Skips warning prompt.")]
    [AllowNull()]
    [Switch]
    $skip_install = $True
)

if ( -Not "testing".Equals($Command) )
    {
        if($PsBoundParameters.ContainsKey('s'))
            {
                Write-Host "Test suite should only be specified in testing mode."
                Write-Host ".\tools\Run.ps1 -?"
                exit 1
            }
        if($PsBoundParameters.ContainsKey('c'))
            {
                Write-Host "Test case should only be specified in testing mode."
                Write-Host ".\tools\Run.ps1 -?"
                exit 1
            }
    }

$env:SKIP_GET_IMAGES=$skip_get_images
$env:SKIP_INSTALL=$skip_install

switch ($Command)
    {
        "all-in-one" { $env:DEPLOY_MODE="all-in-one" }
        { @("dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc", "vfc", "multicloud", "ccsdk", "vnfsdk", "vvp", "openstack", "msb", "oom", "dmaap") -contains $_ } { $env:DEPLOY_MODE="individual" }
        "testing"
            {
                $env:DEPLOY_MODE="testing"
                If(-Not $y)
                    {
                        Write-Host "Warning: This test script will delete the contents of ../opt/ and ~/.m2."
                        $yn = Read-Host "Would you like to continue? [y]es/[n]o: "
                        switch ($yn)
                            {
                                { @("n", "N") -contains $_ }
                                    {
                                        Write-Host "Exiting."
                                        exit 0
                                    }
                            }
                    }
                $env:TEST_SUITE=$s
                $env:TEST_CASE=$c

                &cmd.exe /c rd /s /q .\opt\
                &cmd.exe /c rd /s /q $HOME\.m2\
             }
         default
             {
                Write-Output $"Usage: $0 {all-in-one|dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|vfc|multicloud|ccsdk|vnfsdk|vvp|dmaap|testing}"
                exit 1
             }
    }

vagrant destroy -f $Command
vagrant up $Command