Skip to content

Commit 3469ccc

Browse files
Update Canary.Tests.ps1
1 parent 40ea363 commit 3469ccc

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

CanaryValidator/Canary.Tests.ps1

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ param (
4343
[Parameter(ParameterSetName="default", Mandatory=$false)]
4444
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
4545
[ValidateNotNullOrEmpty()]
46-
[string]$ResourceLocation = "local"
46+
[string]$ResourceLocation = "local",
47+
[parameter(HelpMessage="Flag to cleanup resources after exception")]
48+
[Parameter(ParameterSetName="default", Mandatory=$false)]
49+
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
50+
[bool] $ContinueOnFailure = $false
4751
)
4852

4953
#Requires -Modules AzureRM
@@ -69,7 +73,7 @@ New-Item -Path $canaryUtilPath -ItemType Directory
6973
# Start Canary
7074
#
7175
$CanaryLogFile = $CanaryLogPath + "\Canary-Basic$((Get-Date).ToString("-yyMMdd-hhmmss")).log"
72-
Start-Scenario -Name 'Canary' -Type 'Basic' -LogFilename $CanaryLogFile
76+
Start-Scenario -Name 'Canary' -Type 'Basic' -LogFilename $CanaryLogFile -ContinueOnFailure $ContinueOnFailure
7377

7478
Invoke-Usecase -Name 'CreateAzureStackEnv' -Description "Create Azure Stack environment $EnvironmentName" -UsecaseBlock `
7579
{
@@ -161,7 +165,29 @@ if ($TenantAdminCredentials)
161165
}
162166
}
163167

164-
RegisterResourceProviders
168+
Invoke-Usecase -Name 'RegisterResourceProviders' -Description "Register resource providers" -UsecaseBlock `
169+
{
170+
Get-AzureRmResourceProvider -ListAvailable | Register-AzureRmResourceProvider -Force
171+
$sleepTime = 0
172+
while($true)
173+
{
174+
$sleepTime += 10
175+
Start-Sleep 10
176+
$requiredRPs = Get-AzureRmResourceProvider -ListAvailable | ? {$_.ProviderNamespace -in ("Microsoft.Storage", "Microsoft.Compute", "Microsoft.Network", "Microsoft.KeyVault")}
177+
$notRegistered = $requiredRPs | ? {$_.RegistrationState -ne "Registered"}
178+
$registered = $requiredRPs | ? {$_.RegistrationState -eq "Registered"}
179+
if (($sleepTime -ge 120) -and $notRegistered)
180+
{
181+
Get-AzureRmResourceProvider | Format-Table
182+
throw [System.Exception] "Resource providers did not get registered in time."
183+
}
184+
elseif ($registered.Count -eq $requiredRPs.Count)
185+
{
186+
break
187+
}
188+
}
189+
Get-AzureRmResourceProvider | Format-Table
190+
}
165191
}
166192

167193
Invoke-Usecase -Name 'CreateResourceGroupForUtilities' -Description "Create a resource group $CanaryUtilitiesRG for the placing the utility files" -UsecaseBlock `

0 commit comments

Comments
 (0)