Skip to content

Commit 27768a3

Browse files
committed
Enabled live test and added new function for local debug
1 parent 4c6d726 commit 27768a3

File tree

6 files changed

+441
-74
lines changed

6 files changed

+441
-74
lines changed

.azure-pipelines/live-test.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@ parameters:
4141
default: 7.0.x
4242

4343
variables:
44-
LiveTestArtifactsName: LiveTestArtifacts
45-
LiveTestDataLocation: $(Pipeline.Workspace)/$(LiveTestArtifactsName)
44+
ArtifactsName: LiveTestArtifacts
45+
DataLocation: $(Pipeline.Workspace)/$(ArtifactsName)
4646
EnableTestCoverage: true
47-
TestCoverageLocation: $(LiveTestDataLocation)
47+
TestCoverageLocation: $(DataLocation)
48+
49+
schedules:
50+
- cron: "0 19 * * *"
51+
displayName: Daily Live Test
52+
branches:
53+
include:
54+
- shared/livetest
4855

4956
pr: none
50-
trigger: none
5157

5258
jobs:
5359
- template: util/live-test-steps.yml

.azure-pipelines/util/live-test-steps.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ parameters:
66

77
jobs:
88
- job: ${{ parameters.name }}
9-
timeoutInMinutes: 180
109
pool:
1110
vmImage: ${{ parameters.vmImage }}
1211

@@ -32,7 +31,7 @@ jobs:
3231
pwsh: true
3332
targetType: inline
3433
script:
35-
New-Item -Name $(LiveTestArtifactsName) -Path $(Pipeline.Workspace) -ItemType Directory -Force
34+
New-Item -Name $(ArtifactsName) -Path $(Pipeline.Workspace) -ItemType Directory -Force
3635

3736
- task: DownloadPipelineArtifact@2
3837
condition: and(succeeded(), eq(variables['GalleryName'], 'DailyBuild'), eq(variables['BuildPipelineBuildId'], ''))
@@ -65,7 +64,7 @@ jobs:
6564
pwsh: true
6665
targetType: inline
6766
script: |
68-
$azPackagesDir = New-Item -Name AzPackages -Path $(LiveTestDataLocation) -ItemType Directory -Force
67+
$azPackagesDir = New-Item -Name AzPackages -Path $(DataLocation) -ItemType Directory -Force
6968
$azPackagesFiles = Join-Path -Path $(Pipeline.Workspace) -ChildPath *.nupkg
7069
Move-Item -Path $azPackagesFiles -Destination $azPackagesDir
7170
Get-ChildItem -LiteralPath $azPackagesDir
@@ -76,7 +75,7 @@ jobs:
7675
pwsh: true
7776
targetType: filePath
7877
filePath: ./tools/TestFx/Live/InvokeLiveTestCITask.ps1
79-
arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InstallLiveTestAzModules.ps1 -Source $(GalleryName) -AzPackagesLocation (Convert-Path -LiteralPath $(LiveTestDataLocation) | Join-Path -ChildPath AzPackages)'
78+
arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InstallLiveTestAzModules.ps1 -Source $(GalleryName) -AzPackagesLocation (Convert-Path -LiteralPath $(DataLocation) | Join-Path -ChildPath AzPackages)'
8079

8180
- task: PowerShell@2
8281
displayName: Connect Azure with live test service principal
@@ -92,7 +91,7 @@ jobs:
9291
pwsh: true
9392
targetType: filePath
9493
filePath: ./tools/TestFx/Live/InvokeLiveTestCITask.ps1
95-
arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InvokeLiveTestScenarios.ps1 $(Build.BuildId) ${{ parameters.vmImage }} ${{ parameters.psVersion }} $(Build.SourcesDirectory) $(LiveTestDataLocation)'
94+
arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/InvokeLiveTestScenarios.ps1 -BuildId $(Build.BuildId) -OSVersion ${{ parameters.vmImage }} -PSVersion ${{ parameters.psVersion }} -RepoLocation $(Build.SourcesDirectory)'
9695
failOnStderr: true
9796

9897
- task: PowerShell@2
@@ -101,11 +100,11 @@ jobs:
101100
pwsh: true
102101
targetType: filePath
103102
filePath: ./tools/TestFx/Live/SaveLiveTestResult.ps1
104-
arguments: $(KustoServicePrincipalTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion) $(LiveTestDatabaseName) $(LiveTestTableName) $(TestCoverageTableName) $(LiveTestDataLocation)
103+
arguments: $(KustoServicePrincipalTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion) $(LiveTestDatabaseName) $(LiveTestTableName) $(TestCoverageTableName) $(DataLocation)
105104

106105
- task: PublishPipelineArtifact@1
107106
displayName: Publish live test results to pipeline artifact
108107
inputs:
109108
artifact: livetest-os-${{ parameters.vmImage }}-powershell-${{ parameters.psVersion }}
110-
targetPath: $(LiveTestDataLocation)
109+
targetPath: $(DataLocation)
111110
condition: always()
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
Invoke-LiveTestScenario -Name "Create new standard key vault" -Description "Test creating a new standard key vault with all default values" -ScenarioScript `
2+
{
3+
param ($rg)
4+
5+
$rgName = $rg.ResourceGroupName
6+
$vaultName = New-LiveTestResourceName
7+
$vaultLocation = "westus"
8+
9+
$actual = New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation
10+
Assert-AreEqual $vaultName $actual.VaultName
11+
Assert-AreEqual $rgName $actual.ResourceGroupName
12+
Assert-AreEqual $vaultLocation $actual.Location
13+
Assert-AreEqual "Standard" $actual.Sku
14+
Assert-AreEqual $false $actual.EnabledForDeployment
15+
Assert-True { $actual.EnableSoftDelete } "By default EnableSoftDelete should be true"
16+
Assert-Null $actual.EnablePurgeProtection "By default EnablePurgeProtection should be null"
17+
Assert-False { $actual.EnableRbacAuthorization } "By default EnableRbacAuthorization should be false"
18+
Assert-AreEqual 90 $actual.SoftDeleteRetentionInDays "By default SoftDeleteRetentionInDays should be 90"
19+
}
20+
21+
Invoke-LiveTestScenario -Name "Create new premium key vault" -Description "Test creating a new premium key vault with all default values" -ScenarioScript `
22+
{
23+
param ($rg)
24+
25+
$rgName = $rg.ResourceGroupName
26+
$vaultName = New-LiveTestResourceName
27+
$vaultLocation = "eastus"
28+
29+
$actual = New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation -Sku premium -EnabledForDeployment
30+
Assert-AreEqual $vaultName $actual.VaultName
31+
Assert-AreEqual $rgName $actual.ResourceGroupName
32+
Assert-AreEqual $vaultLocation $actual.Location
33+
Assert-AreEqual "Premium" $actual.Sku
34+
Assert-AreEqual $true $actual.EnabledForDeployment
35+
}
36+
37+
Invoke-LiveTestScenario -Name "Update key vault" -Description "Test updating properties EnableRbacAuthorization and Tag for existing key vault" -ScenarioScript `
38+
{
39+
param ($rg)
40+
41+
$rgName = $rg.ResourceGroupName
42+
$vaultName = New-LiveTestResourceName
43+
$vaultLocation = "eastus"
44+
45+
# Update EnableRbacAuthorization
46+
$vault = New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName -Location $vaultLocation
47+
$vault = $vault | Update-AzKeyVault -EnableRbacAuthorization $true
48+
Assert-True { $vault.EnableRbacAuthorization } "EnableRbacAuthorization should be true"
49+
50+
$vault = $vault | Update-AzKeyVault -EnableRbacAuthorization $false
51+
Assert-False { $vault.EnableRbacAuthorization } "EnableRbacAuthorization should be false"
52+
53+
# Update Tags
54+
$vault = $vault | Update-AzKeyVault -Tag @{ key = "value" }
55+
Assert-AreEqual 1 $vault.Tags.Count "Tags should contain a key-value pair (key, value)"
56+
Assert-True { $vault.Tags.Contains("key") } "Tags should contain a key-value pair (key, value)"
57+
Assert-AreEqual "value" $vault.Tags["key"] "Tags should contain a key-value pair (key, value)"
58+
59+
# Clean Tags
60+
$vault = $vault | Update-AzKeyVault -Tag @{}
61+
Assert-AreEqual 0 $vault.Tags.Count "Tags should be empty"
62+
}
63+
64+
Invoke-LiveTestScenario -Name "Delete key vault" -Description "Test deleting key vault" -ScenarioScript `
65+
{
66+
param ($rg)
67+
68+
$rgName = $rg.ResourceGroupName
69+
$vaultName = New-LiveTestResourceName
70+
$vaultLocation = "westus"
71+
72+
New-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgname -Location $vaultLocation
73+
Remove-AzKeyVault -VaultName $vaultName -Force
74+
75+
$deletedVault = Get-AzKeyVault -VaultName $vaultName -ResourceGroupName $rgName
76+
Assert-Null $deletedVault
77+
78+
# purge deleted vault
79+
Remove-AzKeyVault -VaultName $vaultName -Location $vaultLocation -InRemovedState -Force
80+
}

0 commit comments

Comments
 (0)