Skip to content

Commit f168634

Browse files
authored
Merge branch 'vnext' into renamestaging
2 parents 8a40a5c + e89fca8 commit f168634

5 files changed

Lines changed: 114 additions & 26 deletions

File tree

CanaryValidator/Canary.Tests.ps1

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ param (
3939
[parameter(HelpMessage="Path for Linux VHD")]
4040
[Parameter(ParameterSetName="default", Mandatory=$false)]
4141
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
42-
[string] $LinuxImagePath = "https://partner-images.canonical.com/azure/azure_stack/ubuntu-14.04-LTS-microsoft_azure_stack-20161208-9.vhd.zip",
42+
[string] $LinuxImagePath = "http://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.vhd.zip",
4343
[parameter(HelpMessage="Linux OS sku")]
4444
[Parameter(ParameterSetName="default", Mandatory=$false)]
4545
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
46-
[string] $LinuxOSSku = "14.04.3-LTS",
46+
[string] $LinuxOSSku = "16.04-LTS",
4747
[parameter(HelpMessage="Fully qualified domain name of the azure stack environment. Ex: contoso.com")]
4848
[Parameter(ParameterSetName="default", Mandatory=$false)]
4949
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
@@ -96,28 +96,35 @@ param (
9696
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
9797
[ValidateNotNullOrEmpty()]
9898
[string]$CanaryLogPath = $env:TMP + "\CanaryLogs$((Get-Date).Ticks)",
99-
[parameter(HelpMessage="Specifies the file name for canary log file")]
99+
[parameter(HelpMessage="Specifies the file name for canary log file")]
100100
[Parameter(ParameterSetName="default", Mandatory=$false)]
101101
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
102102
[ValidateNotNullOrEmpty()]
103103
[string]$CanaryLogFileName = "Canary-Basic-$((Get-Date).Ticks).log",
104104
[parameter(HelpMessage="List of usecases to be excluded from execution")]
105105
[Parameter(ParameterSetName="default", Mandatory=$false)]
106106
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
107-
[string[]]$ExclusionList = ("GetAzureStackInfraRoleInstance", "GetAzureStackScaleUnitNode"),
107+
[string[]]$ExclusionList = ("GetAzureStackInfraRoleInstance"),
108108
[parameter(HelpMessage="Lists the available usecases in Canary")]
109109
[Parameter(ParameterSetName="listavl", Mandatory=$true)]
110110
[ValidateNotNullOrEmpty()]
111111
[switch]$ListAvailable
112112
)
113113

114-
#requires -Modules AzureRM.Profile, AzureRM.AzureStackAdmin
115-
#Requires -RunAsAdministrator
116114
Import-Module -Name $PSScriptRoot\Canary.Utilities.psm1 -Force -DisableNameChecking
117-
Import-Module -Name $PSScriptRoot\..\Connect\AzureStack.Connect.psm1 -Force
118-
Import-Module -Name $PSScriptRoot\..\Infrastructure\AzureStack.Infra.psm1 -Force
119-
Import-Module -Name $PSScriptRoot\..\ComputeAdmin\AzureStack.ComputeAdmin.psm1 -Force
115+
if (-not $ListAvailable.IsPresent)
116+
{
117+
#requires -Modules AzureRM.Profile, AzureRM.AzureStackAdmin
118+
#Requires -RunAsAdministrator
120119

120+
Import-Module -Name $PSScriptRoot\..\Connect\AzureStack.Connect.psm1 -Force
121+
Import-Module -Name $PSScriptRoot\..\Infrastructure\AzureStack.Infra.psm1 -Force
122+
Import-Module -Name $PSScriptRoot\..\ComputeAdmin\AzureStack.ComputeAdmin.psm1 -Force
123+
}
124+
else
125+
{
126+
$ErrorActionPreference = "SilentlyContinue"
127+
}
121128
$runCount = 1
122129
$tmpLogname = $CanaryLogFileName
123130
while ($runCount -le $NumberOfIterations)
@@ -148,7 +155,7 @@ while ($runCount -le $NumberOfIterations)
148155
#
149156
# Start Canary
150157
#
151-
if($ListAvailable){$listAvl = $true} else{$listAvl = $false}
158+
if($ListAvailable){Write-Host "List of scenarios in Canary:" -ForegroundColor Green; $listAvl = $true} else{$listAvl = $false}
152159
$CanaryLogFileName = [IO.Path]::GetFileNameWithoutExtension($tmpLogname) + "-$runCount" + [IO.Path]::GetExtension($tmpLogname)
153160
$CanaryLogFile = Join-Path -Path $CanaryLogPath -ChildPath $CanaryLogFileName
154161
Start-Scenario -Name 'Canary' -Type 'Basic' -LogFilename $CanaryLogFile -ContinueOnFailure $ContinueOnFailure -ListAvailable $listAvl -ExclusionList $ExclusionList
@@ -276,7 +283,7 @@ while ($runCount -le $NumberOfIterations)
276283
Get-AzsUpdate -Location $ResourceLocation
277284
}
278285
}
279-
286+
280287
if ($WindowsISOPath)
281288
{
282289
Invoke-Usecase -Name 'UploadWindows2016ImageToPIR' -Description "Uploads a windows server 2016 image to the PIR" -UsecaseBlock `
@@ -322,15 +329,15 @@ while ($runCount -le $NumberOfIterations)
322329
}
323330
}
324331

325-
if ($TenantAdminCredentials)
332+
if (($TenantAdminCredentials) -or ($ListAvailable))
326333
{
327334
$subscriptionRGName = $CanaryUtilitiesRG + "subscrrg" + [Random]::new().Next(1,999)
328335
$tenantPlanName = $CanaryUtilitiesRG + "tenantplan" + [Random]::new().Next(1,999)
329336
$tenantOfferName = $CanaryUtilitiesRG + "tenantoffer" + [Random]::new().Next(1,999)
330337
$tenantSubscriptionName = $CanaryUtilitiesRG + "tenantsubscription" + [Random]::new().Next(1,999)
331338
$canaryDefaultTenantSubscription = $CanaryUtilitiesRG + "tenantdefaultsubscription" + [Random]::new().Next(1,999)
332339

333-
if ((-not $TenantArmEndpoint) -and (-not $listAvl))
340+
if ((-not $TenantArmEndpoint) -and (-not $ListAvailable.IsPresent))
334341
{
335342
throw [System.Exception] "Tenant ARM endpoint is required."
336343
}
@@ -350,6 +357,7 @@ while ($runCount -le $NumberOfIterations)
350357
-EnableAdfsAuthentication:$asEndpoints.ActiveDirectoryEndpoint.TrimEnd("/").EndsWith("/adfs", [System.StringComparison]::OrdinalIgnoreCase) `
351358
-ErrorAction Stop
352359
}
360+
353361
Invoke-Usecase -Name 'CreateResourceGroupForTenantSubscription' -Description "Create a resource group $subscriptionRGName for the tenant subscription" -UsecaseBlock `
354362
{
355363
if (Get-AzureRmResourceGroup -Name $subscriptionRGName -ErrorAction SilentlyContinue)
@@ -555,7 +563,7 @@ while ($runCount -le $NumberOfIterations)
555563
throw [System.Exception] "Custom role definition ($customRoleName) for subscription $tenantSubscriptionName is not available"
556564
}
557565
}
558-
}
566+
}
559567

560568
Invoke-Usecase -Name 'RegisterResourceProviders' -Description "Register resource providers" -UsecaseBlock `
561569
{
@@ -1089,7 +1097,7 @@ while ($runCount -le $NumberOfIterations)
10891097

10901098
if (($TenantAdminCredentials) -or ($listAvl))
10911099
{
1092-
Invoke-Usecase -Name 'TenantRelatedcleanup' -Description "Remove all the tenant related stuff" -UsecaseBlock `
1100+
Invoke-Usecase -Name 'TenantRelatedcleanup' -Description "Remove all the tenant related resources" -UsecaseBlock `
10931101
{
10941102
Invoke-Usecase -Name 'DeleteTenantSubscriptions' -Description "Remove all the tenant related subscriptions" -UsecaseBlock `
10951103
{
@@ -1115,7 +1123,6 @@ while ($runCount -le $NumberOfIterations)
11151123
Remove-AzsVMImage -publisher $linuxImagePublisher -offer $linuxImageOffer -sku $LinuxOSSku -version $linuxImageVersion -Location $ResourceLocation
11161124
}
11171125
}
1118-
11191126
Invoke-Usecase -Name 'DeleteSubscriptionResourceGroup' -Description "Delete the resource group that contains subscription resources" -UsecaseBlock `
11201127
{
11211128
if ($removeRG = Get-AzureRmResourceGroup -Name $subscriptionRGName -ErrorAction Stop)

CanaryValidator/Canary.Utilities.psm1

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,53 @@ function Log-JSONReport
118118

119119
function Get-CanaryResult
120120
{
121-
$logContent = Get-Content -Raw -Path $Global:JSONLogFile | ConvertFrom-Json
122-
Log-Info ($logContent.UseCases | Format-Table -AutoSize @{Expression = {$_.Name}; Label = "Name"; Align = "Left"},
123-
@{Expression = {$_.Result}; Label="Result"; Align = "Left"},
124-
@{Expression = {((Get-Date $_.EndTime) - (Get-Date $_.StartTime)).TotalSeconds}; Label = "Duration`n[Seconds]"; Align = "Left"},
125-
@{Expression = {$_.Description}; Label = "Description"; Align = "Left"})
121+
[CmdletBinding()]
122+
param(
123+
[parameter(Mandatory=$false)]
124+
[ValidateNotNullOrEmpty()]
125+
[string]$LogFilename
126+
)
127+
128+
if ($LogFilename)
129+
{
130+
$logContent = Get-Content -Raw -Path $LogFilename | ConvertFrom-Json
131+
}
132+
else
133+
{
134+
$logContent = Get-Content -Raw -Path $Global:JSONLogFile | ConvertFrom-Json
135+
}
136+
$results = @()
137+
foreach ($usecase in $logContent.UseCases)
138+
{
139+
$ucObj = New-Object -TypeName PSObject
140+
if ([bool]($usecase.PSobject.Properties.name -match "UseCase"))
141+
{
142+
$ucObj | Add-Member -Type NoteProperty -Name Name -Value $usecase.Name
143+
$ucObj | Add-Member -Type NoteProperty -Name Result -Value $usecase.Result
144+
$ucObj | Add-Member -Type NoteProperty -Name "Duration`n[Seconds]" -Value ((Get-Date $usecase.EndTime) - (Get-Date $usecase.StartTime)).TotalSeconds
145+
$ucObj | Add-Member -Type NoteProperty -Name Description -Value $usecase.Description
146+
$results += $ucObj
147+
148+
foreach ($subusecase in $usecase.UseCase)
149+
{
150+
$ucObj = New-Object -TypeName PSObject
151+
$ucObj | Add-Member -Type NoteProperty -Name Name -Value ("|-- $($subusecase.Name)")
152+
$ucObj | Add-Member -Type NoteProperty -Name Result -Value $subusecase.Result
153+
$ucObj | Add-Member -Type NoteProperty -Name "Duration`n[Seconds]" -Value ((Get-Date $subusecase.EndTime) - (Get-Date $subusecase.StartTime)).TotalSeconds
154+
$ucObj | Add-Member -Type NoteProperty -Name Description -Value ("|-- $($subusecase.Description)")
155+
$results += $ucObj
156+
}
157+
}
158+
else
159+
{
160+
$ucObj | Add-Member -Type NoteProperty -Name Name -Value $usecase.Name
161+
$ucObj | Add-Member -Type NoteProperty -Name Result -Value $usecase.Result
162+
$ucObj | Add-Member -Type NoteProperty -Name "Duration`n[Seconds]" -Value ((Get-Date $usecase.EndTime) - (Get-Date $usecase.StartTime)).TotalSeconds
163+
$ucObj | Add-Member -Type NoteProperty -Name Description -Value $usecase.Description
164+
$results += $ucObj
165+
}
166+
}
167+
Log-Info($results | Format-Table -AutoSize)
126168
}
127169

128170
function Get-CanaryLonghaulResult
@@ -249,7 +291,7 @@ function Invoke-Usecase
249291
$parentUsecase = $Name
250292
if ((Get-PSCallStack)[1].Arguments.Contains($parentUsecase))
251293
{
252-
" `t"*([math]::Floor((Get-PSCallStack).Count/3)) + "|--" + $Name
294+
" `t"*([math]::Floor((Get-PSCallStack).Count/3)) + "|-- " + $Name
253295
}
254296
else
255297
{
@@ -258,7 +300,8 @@ function Invoke-Usecase
258300
}
259301
if ($UsecaseBlock.ToString().Contains("Invoke-Usecase"))
260302
{
261-
Invoke-Command -ScriptBlock $UsecaseBlock -ErrorAction SilentlyContinue
303+
try {Invoke-Command -ScriptBlock $UsecaseBlock -ErrorAction SilentlyContinue}
304+
catch {}
262305
}
263306
return
264307
}

CanaryValidator/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ $ServiceAdminCreds = New-Object System.Management.Automation.PSCredential "<Ser
5252
# Install-AzureRmProfile -profile '2017-03-09-profile' -Force -Scope CurrentUser
5353
# Install-Module -Name AzureStack -RequiredVersion 1.2.9 -Scope CurrentUser
5454
.\Canary.Tests.ps1 -ListAvailable
55+
5556
Sample output:
56-
PS C:\AzureStack-Tools\CanaryValidator> .\Canary.Tests.ps1 -ListAvailable
57+
PS C:\AzureStack-Tools-vnext\CanaryValidator> .\Canary.Tests.ps1 -ListAvailable
58+
List of scenarios in Canary:
5759
CreateAdminAzureStackEnv
5860
LoginToAzureStackEnvAsSvcAdmin
5961
SelectDefaultProviderSubscription
@@ -75,6 +77,24 @@ Sample output:
7577
ListUpdatesResourceProviderInfo
7678
|--GetAzureStackUpdateSummary
7779
|--GetAzureStackUpdateToApply
80+
CreateTenantAzureStackEnv
81+
CreateResourceGroupForTenantSubscription
82+
CreateTenantPlan
83+
CreateTenantOffer
84+
CreateTenantDefaultManagedSubscription
85+
LoginToAzureStackEnvAsTenantAdmin
86+
CreateTenantSubscription
87+
RoleAssignmentAndCustomRoleDefinition
88+
|--ListAssignedRoles
89+
|--ListExistingRoleDefinitions
90+
|--GetProviderOperations
91+
|--AssignReaderRole
92+
|--VerifyReaderRoleAssignment
93+
|--RemoveReaderRoleAssignment
94+
|--CustomRoleDefinition
95+
|--ListRoleDefinitionsAfterCustomRoleCreation
96+
|--RemoveCustomRoleDefinition
97+
RegisterResourceProviders
7898
CreateResourceGroupForUtilities
7999
CreateStorageAccountForUtilities
80100
CreateStorageContainerForUtilities
@@ -85,6 +105,7 @@ Sample output:
85105
CreateKeyVaultStoreForCertSecret
86106
CreateResourceGroupForVMs
87107
DeployARMTemplate
108+
RetrieveResourceDeploymentTimes
88109
QueryTheVMsDeployed
89110
CheckVMCommunicationPreVMReboot
90111
AddDatadiskToVMWithPrivateIP
@@ -103,6 +124,11 @@ Sample output:
103124
DeleteVMWithPrivateIP
104125
DeleteVMResourceGroup
105126
DeleteUtilitiesResourceGroup
127+
TenantRelatedcleanup
128+
|--DeleteTenantSubscriptions
129+
|--LoginToAzureStackEnvAsSvcAdminForCleanup
130+
|--RemoveLinuxImageFromPIR
131+
|--DeleteSubscriptionResourceGroup
106132
```
107133

108134
## To exclude certain usecases from getting executed

CanaryValidator/azuredeploy.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@
8383
"metadata": {
8484
"description": "Maps to the sku in the Azure Stack Platform Image Repository manifest file Eg: 12.SP1, 6.7 , 7.2"
8585
}
86+
},
87+
"storageAccountEndPoint": {
88+
"type": "string",
89+
"metadata": {
90+
"description": "Storage account endpoint to be used to collect the diagnostic information from the VMs"
91+
}
8692
}
8793
},
8894

@@ -662,7 +668,7 @@
662668
"protectedSettings": {
663669
"storageAccountName": "[variables('storageAccountName3')]",
664670
"storageAccountKey": "[listKeys(variables('storageAccountName3ID'), variables('apiVersionSRP')).key1]",
665-
"storageAccountEndPoint": "http://azurestack.local"
671+
"storageAccountEndPoint": "[parameters('storageAccountEndPoint')]"
666672
}
667673
}
668674
},

CanaryValidator/azuredeploy.nolinux.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@
8686
"description": "Maps to the sku in the Azure Stack Platform Image Repository manifest file Eg: 12.SP1, 6.7 , 7.2"
8787
},
8888
"defaultValue": "14.04.3-LTS"
89+
},
90+
"storageAccountEndPoint": {
91+
"type": "string",
92+
"metadata": {
93+
"description": "Storage account endpoint to be used to collect the diagnostic information from the VMs"
94+
}
8995
}
9096
},
9197

@@ -561,7 +567,7 @@
561567
"protectedSettings": {
562568
"storageAccountName": "[variables('storageAccountName3')]",
563569
"storageAccountKey": "[listKeys(variables('storageAccountName3ID'), variables('apiVersionSRP')).key1]",
564-
"storageAccountEndPoint": "http://azurestack.local"
570+
"storageAccountEndPoint": "[parameters('storageAccountEndPoint')]"
565571
}
566572
}
567573
},

0 commit comments

Comments
 (0)