Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 1 | <# |
| 2 | .SYNOPSIS |
| 3 | This script helps to configure its environment variables based on the component selected. |
| 4 | |
| 5 | .EXAMPLE |
| 6 | .\tools\Run.ps1 testing -s functions -c install_maven -y |
| 7 | |
| 8 | .EXAMPLE |
| 9 | .\tools\Run.ps1 all_in_one |
| 10 | |
| 11 | .EXAMPLE |
| 12 | .\tools\Run.ps1 aai |
| 13 | |
| 14 | .PARAMETER s |
| 15 | Test suite to use in testing mode. |
| 16 | |
| 17 | .PARAMETER c |
| 18 | Test case to use in testing mode. |
| 19 | |
| 20 | .PARAMETER y |
| 21 | Skips warning prompt. |
| 22 | |
| 23 | .LINK |
| 24 | https://wiki.onap.org/display/DW/ONAP+on+Vagrant |
| 25 | #> |
| 26 | |
| 27 | Param( |
Victor Morales | 000de53 | 2017-08-31 17:28:10 -0500 | [diff] [blame^] | 28 | [ValidateSet("all_in_one","dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc", "vfc", "multicloud", "testing")] |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 29 | [Parameter(Mandatory=$True,Position=0)] |
| 30 | [ValidateNotNullOrEmpty()] |
| 31 | [String] |
| 32 | $Command |
| 33 | , |
| 34 | [Parameter(Mandatory=$False,HelpMessage="Test suite to use in testing mode.")] |
| 35 | [Alias("suite")] |
| 36 | [String] |
| 37 | $s = "*" |
| 38 | , |
| 39 | [Parameter(Mandatory=$False,HelpMessage="Test case to sue in testing mode.")] |
| 40 | [Alias("case")] |
| 41 | [String] |
| 42 | $c = "*" |
| 43 | , |
| 44 | [Parameter(Mandatory=$False,HelpMessage="Skips warning prompt.")] |
| 45 | [AllowNull()] |
| 46 | [Switch] |
| 47 | $y = $false |
| 48 | ) |
| 49 | |
| 50 | if ( -Not "testing".Equals($Command) ) |
| 51 | { |
| 52 | if($PsBoundParameters.ContainsKey('s')) |
| 53 | { |
| 54 | Write-Host "Test suite should only be specified in testing mode." |
| 55 | Write-Host ".\tools\Run.ps1 -?" |
| 56 | exit 1 |
| 57 | } |
| 58 | if($PsBoundParameters.ContainsKey('c')) |
| 59 | { |
| 60 | Write-Host "Test case should only be specified in testing mode." |
| 61 | Write-Host ".\tools\Run.ps1 -?" |
| 62 | exit 1 |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | switch ($Command) |
Victor Morales | 134f97a | 2017-08-08 16:08:19 -0500 | [diff] [blame] | 67 | { |
| 68 | "all_in_one" { $env:DEPLOY_MODE="all-in-one" } |
| 69 | { @("dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc") -contains $_ } { $env:DEPLOY_MODE="individual" } |
| 70 | "testing" |
| 71 | { |
| 72 | $env:DEPLOY_MODE="testing" |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 73 | If(-Not $y) |
| 74 | { |
| 75 | Write-Host "Warning: This test script will delete the contents of ../opt/ and ~/.m2." |
| 76 | $yn = Read-Host "Would you like to continue? [y]es/[n]o: " |
| 77 | switch ($yn) |
| 78 | { |
| 79 | { @("n", "N") -contains $_ } |
| 80 | { |
| 81 | Write-Host "Exiting." |
| 82 | exit 0 |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | $env:TEST_SUITE=$s |
| 87 | $env:TEST_CASE=$c |
Victor Morales | 134f97a | 2017-08-08 16:08:19 -0500 | [diff] [blame] | 88 | |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 89 | &cmd.exe /c rd /s /q .\opt\ |
| 90 | &cmd.exe /c rd /s /q $HOME\.m2\ |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 91 | } |
| 92 | default |
| 93 | { |
| 94 | Write-Output $"Usage: $0 {all_in_one|dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|testing}" |
| 95 | exit 1 |
Victor Morales | 134f97a | 2017-08-08 16:08:19 -0500 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 99 | vagrant destroy -f $Command |
| 100 | vagrant up $Command |