@@ -95,12 +95,20 @@ param (
9595 [Parameter (ParameterSetName = " default" , Mandatory = $false )]
9696 [Parameter (ParameterSetName = " tenant" , Mandatory = $false )]
9797 [ValidateNotNullOrEmpty ()]
98- [string ]$CanaryLogFileName = " Canary-Basic-$ ( (Get-Date ).Ticks) .log"
98+ [string ]$CanaryLogFileName = " Canary-Basic-$ ( (Get-Date ).Ticks) .log" ,
99+ [parameter (HelpMessage = " List of usecases to be excluded from execution" )]
100+ [Parameter (ParameterSetName = " default" , Mandatory = $false )]
101+ [Parameter (ParameterSetName = " tenant" , Mandatory = $false )]
102+ [string []]$ExclusionList = (" GetAzureStackInfraRoleInstance" , " GetAzureStackScaleUnitNode" ),
103+ [parameter (HelpMessage = " Lists the available usecases in Canary" )]
104+ [Parameter (ParameterSetName = " listavl" , Mandatory = $true )]
105+ [ValidateNotNullOrEmpty ()]
106+ [switch ]$ListAvailable
99107)
100108
101- # Requires -Modules AzureRM
109+ # requires -Modules AzureRM . Profile , AzureRM . AzureStackAdmin
102110# Requires -RunAsAdministrator
103- Import-Module - Name $PSScriptRoot \Canary.Utilities.psm1 - Force
111+ Import-Module - Name $PSScriptRoot \Canary.Utilities.psm1 - Force - DisableNameChecking
104112Import-Module - Name $PSScriptRoot \..\Connect\AzureStack.Connect.psm1 - Force
105113Import-Module - Name $PSScriptRoot \..\Infrastructure\AzureStack.Infra.psm1 - Force
106114Import-Module - Name $PSScriptRoot \..\ComputeAdmin\AzureStack.ComputeAdmin.psm1 - Force
@@ -134,15 +142,15 @@ while ($runCount -le $NumberOfIterations)
134142 #
135143 # Start Canary
136144 #
145+ if ($ListAvailable ){$listAvl = $true } else {$listAvl = $false }
137146 $CanaryLogFileName = [IO.Path ]::GetFileNameWithoutExtension($tmpLogname ) + " -$runCount " + [IO.Path ]::GetExtension($tmpLogname )
138147 $CanaryLogFile = Join-Path - Path $CanaryLogPath - ChildPath $CanaryLogFileName
139-
140- Start-Scenario - Name ' Canary' - Type ' Basic' - LogFilename $CanaryLogFile - ContinueOnFailure $ContinueOnFailure
148+ Start-Scenario - Name ' Canary' - Type ' Basic' - LogFilename $CanaryLogFile - ContinueOnFailure $ContinueOnFailure - ListAvailable $listAvl - ExclusionList $ExclusionList
141149
142150 $SvcAdminEnvironmentName = $EnvironmentName + " -SVCAdmin"
143151 $TntAdminEnvironmentName = $EnvironmentName + " -Tenant"
144152
145- if (-not $EnvironmentDomainFQDN )
153+ if (( -not $EnvironmentDomainFQDN ) -and ( -not $listAvl ) )
146154 {
147155 $endptres = Invoke-RestMethod " ${AdminArmEndpoint} /metadata/endpoints?api-version=1.0" - ErrorAction Stop
148156 $EnvironmentDomainFQDN = $endptres.portalEndpoint
@@ -251,12 +259,12 @@ while ($runCount -le $NumberOfIterations)
251259
252260 Invoke-Usecase - Name ' ListUpdatesResourceProviderInfo' - Description " List URP information like summary of updates available, update to be applied, last update applied etc." - UsecaseBlock `
253261 {
254- Invoke-Usecase - Name ' GetAzureStackUpdateSummary' - Description " List summary of updates status" - UsecaseBlock `
262+ Invoke-Usecase - Name ' GetAzureStackUpdateSummary' - Description " List summary of updates status" - UsecaseBlock `
255263 {
256264 Get-AzSUpdateSummary - TenantID $TenantID - AzureStackCredentials $ServiceAdminCredentials - EnvironmentName $SvcAdminEnvironmentName - region $ResourceLocation
257265 }
258266
259- Invoke-Usecase - Name ' GetAzureStackUpdateToApply' - Description " List all updates that can be applied" - UsecaseBlock `
267+ Invoke-Usecase - Name ' GetAzureStackUpdateToApply' - Description " List all updates that can be applied" - UsecaseBlock `
260268 {
261269 Get-AzSUpdate - TenantID $TenantID - AzureStackCredentials $ServiceAdminCredentials - EnvironmentName $SvcAdminEnvironmentName - region $ResourceLocation
262270 }
@@ -268,7 +276,7 @@ while ($runCount -le $NumberOfIterations)
268276 {
269277 if (-not (Get-AzureRmVMImage - Location $ResourceLocation - PublisherName " MicrosoftWindowsServer" - Offer " WindowsServer" - Sku " 2016-Datacenter-Core" - ErrorAction SilentlyContinue))
270278 {
271- New-Server2016VMImage - ISOPath $WindowsISOPath - TenantId $TenantID - EnvironmentName $SvcAdminEnvironmentName - Version Core - AzureStackCredentials $ServiceAdminCredentials - CreateGalleryItem $false
279+ New-Server2016VMImage - ISOPath $WindowsISOPath - TenantId $TenantID - EnvironmentName $SvcAdminEnvironmentName - Location $ResourceLocation - Version Core - AzureStackCredentials $ServiceAdminCredentials - CreateGalleryItem $false
272280 }
273281 }
274282 }
@@ -288,7 +296,7 @@ while ($runCount -le $NumberOfIterations)
288296 }
289297 New-Item - Path $CanaryCustomImageFolder - ItemType Directory
290298 $CustomVHDPath = CopyImage - ImagePath $LinuxImagePath - OutputFolder $CanaryCustomImageFolder
291- Add-VMImage - publisher $linuxImagePublisher - offer $linuxImageOffer - sku $LinuxOSSku - version $linuxImageVersion - osDiskLocalPath $CustomVHDPath - osType Linux - tenantID $TenantID - azureStackCredentials $ServiceAdminCredentials - CreateGalleryItem $false - EnvironmentName $SvcAdminEnvironmentName
299+ Add-VMImage - publisher $linuxImagePublisher - offer $linuxImageOffer - sku $LinuxOSSku - version $linuxImageVersion - osDiskLocalPath $CustomVHDPath - osType Linux - tenantID $TenantID - azureStackCredentials $ServiceAdminCredentials - Location $ResourceLocation - CreateGalleryItem $false - EnvironmentName $SvcAdminEnvironmentName
292300 Remove-Item $CanaryCustomImageFolder - Force - Recurse
293301 }
294302 }
@@ -647,18 +655,24 @@ while ($runCount -le $NumberOfIterations)
647655 if (($pubVMObject = Get-AzureRmVM - ResourceGroupName $CanaryVMRG - Name $publicVMName - ErrorAction Stop) -and ($pvtVMObject = Get-AzureRmVM - ResourceGroupName $CanaryVMRG - Name $privateVMName - ErrorAction Stop))
648656 {
649657 Set-item wsman:\localhost\Client\TrustedHosts - Value $publicVMIP - Force - Confirm:$false
650- if ($publicVMSession = New-PSSession - ComputerName $publicVMIP - Credential $vmCreds - ErrorAction Stop)
658+ $sw = [system.diagnostics.stopwatch ]::startNew()
659+ while (-not ($publicVMSession = New-PSSession - ComputerName $publicVMIP - Credential $vmCreds - ErrorAction SilentlyContinue)){if (($sw.ElapsedMilliseconds -gt 240000 ) -and (-not ($publicVMSession ))){$sw.Stop (); throw [System.Exception ]" Unable to establish a remote session to the tenant VM using public IP: $publicVMIP " }; Start-Sleep - Seconds 15 }
660+ if ($publicVMSession )
651661 {
652662 Invoke-Command - Session $publicVMSession - Script{param ($privateIP ) Set-item wsman:\localhost\Client\TrustedHosts - Value $privateIP - Force - Confirm:$false } - ArgumentList $privateVMIP | Out-Null
653- $privateVMResponseFromRemoteSession = Invoke-Command - Session $publicVMSession - Script{param ($privateIP , $vmCreds , $scriptToRun ) $privateSess = New-PSSession - ComputerName $privateIP - Credential $vmCreds ; Invoke-Command - Session $privateSess - Script{param ($script ) Invoke-Expression $script } - ArgumentList $scriptToRun } - ArgumentList $privateVMIP , $vmCreds , $vmCommsScriptBlock
663+ $privateVMResponseFromRemoteSession = Invoke-Command - Session $publicVMSession - Script{param ($privateIP , $vmCreds , $scriptToRun ) $sw = [system.diagnostics.stopwatch ]::startNew(); while (-not ($privateSess = New-PSSession - ComputerName $privateIP - Credential $vmCreds - ErrorAction SilentlyContinue)){if (($sw.ElapsedMilliseconds -gt 240000 ) -and (-not ($privateSess ))){$sw.Stop (); throw [System.Exception ]" Unable to establish a remote session to the tenant VM using private IP: $privateIP " }; Start-Sleep - Seconds 15 }; Invoke-Command - Session $privateSess - Script{param ($script ) Invoke-Expression $script } - ArgumentList $scriptToRun } - ArgumentList $privateVMIP , $vmCreds , $vmCommsScriptBlock - ErrorVariable remoteExecError 2> $null
664+ $publicVMSession | Remove-PSSession - Confirm:$false
665+ if ($remoteExecError )
666+ {
667+ throw [System.Exception ]" $remoteExecError "
668+ }
654669 if ($privateVMResponseFromRemoteSession )
655670 {
656- $publicVMSession | Remove-PSSession - Confirm:$false
657671 $privateVMResponseFromRemoteSession
658672 }
659673 else
660674 {
661- throw [System.Exception ]" Public VM was not able to talk to the Private VM via the private IP"
675+ throw [System.Exception ]" The expected certificate from KV was not found on the tenant VM with private IP: $privateVMIP "
662676 }
663677 }
664678 }
@@ -795,18 +809,24 @@ while ($runCount -le $NumberOfIterations)
795809 if (($pubVMObject = Get-AzureRmVM - ResourceGroupName $CanaryVMRG - Name $publicVMName - ErrorAction Stop) -and ($pvtVMObject = Get-AzureRmVM - ResourceGroupName $CanaryVMRG - Name $privateVMName - ErrorAction Stop))
796810 {
797811 Set-item wsman:\localhost\Client\TrustedHosts - Value $publicVMIP - Force - Confirm:$false
798- if ($publicVMSession = New-PSSession - ComputerName $publicVMIP - Credential $vmCreds - ErrorAction Stop)
812+ $sw = [system.diagnostics.stopwatch ]::startNew()
813+ while (-not ($publicVMSession = New-PSSession - ComputerName $publicVMIP - Credential $vmCreds - ErrorAction SilentlyContinue)){if (($sw.ElapsedMilliseconds -gt 240000 ) -and (-not ($publicVMSession ))){$sw.Stop (); throw [System.Exception ]" Unable to establish a remote session to the tenant VM using public IP: $publicVMIP " }; Start-Sleep - Seconds 15 }
814+ if ($publicVMSession )
799815 {
800816 Invoke-Command - Session $publicVMSession - Script{param ($privateIP ) Set-item wsman:\localhost\Client\TrustedHosts - Value $privateIP - Force - Confirm:$false } - ArgumentList $privateVMIP | Out-Null
801- $privateVMResponseFromRemoteSession = Invoke-Command - Session $publicVMSession - Script{param ($privateIP , $vmCreds , $scriptToRun ) $privateSess = New-PSSession - ComputerName $privateIP - Credential $vmCreds ; Invoke-Command - Session $privateSess - Script{param ($script ) Invoke-Expression $script } - ArgumentList $scriptToRun } - ArgumentList $privateVMIP , $vmCreds , $vmCommsScriptBlock
817+ $privateVMResponseFromRemoteSession = Invoke-Command - Session $publicVMSession - Script{param ($privateIP , $vmCreds , $scriptToRun ) $sw = [system.diagnostics.stopwatch ]::startNew(); while (-not ($privateSess = New-PSSession - ComputerName $privateIP - Credential $vmCreds - ErrorAction SilentlyContinue)){if (($sw.ElapsedMilliseconds -gt 240000 ) -and (-not ($privateSess ))){$sw.Stop (); throw [System.Exception ]" Unable to establish a remote session to the tenant VM using private IP: $privateIP " }; Start-Sleep - Seconds 15 }; Invoke-Command - Session $privateSess - Script{param ($script ) Invoke-Expression $script } - ArgumentList $scriptToRun } - ArgumentList $privateVMIP , $vmCreds , $vmCommsScriptBlock - ErrorVariable remoteExecError 2> $null
818+ $publicVMSession | Remove-PSSession - Confirm:$false
819+ if ($remoteExecError )
820+ {
821+ throw [System.Exception ]" $remoteExecError "
822+ }
802823 if ($privateVMResponseFromRemoteSession )
803824 {
804- $publicVMSession | Remove-PSSession - Confirm:$false
805825 $privateVMResponseFromRemoteSession
806826 }
807827 else
808828 {
809- throw [System.Exception ]" Public VM was not able to talk to the Private VM via the private IP"
829+ throw [System.Exception ]" Host name could not be retrieved from the tenant VM with private IP: $privateVMIP "
810830 }
811831 }
812832 }
@@ -859,7 +879,7 @@ while ($runCount -le $NumberOfIterations)
859879 }
860880 }
861881
862- if ($TenantAdminCredentials )
882+ if (( $TenantAdminCredentials ) -or ( $listAvl ) )
863883 {
864884 Invoke-Usecase - Name ' TenantRelatedcleanup' - Description " Remove all the tenant related stuff" - UsecaseBlock `
865885 {
@@ -893,7 +913,10 @@ while ($runCount -le $NumberOfIterations)
893913
894914 End - Scenario
895915 $runCount += 1
896- Get-CanaryResult
916+ if (-not $ListAvailable )
917+ {
918+ Get-CanaryResult
919+ }
897920}
898921
899922if ($NumberOfIterations -gt 1 )
0 commit comments