Skip to content

Commit 790025c

Browse files
authored
Implemented live test and integrated into Azure pipeline (Azure#20505)
* Implemented live test and integrated into Azure pipeline * Updated GenerateDocumentationFile from switch to string
1 parent 8cbb06f commit 790025c

19 files changed

+1612
-219
lines changed

.azure-pipelines/daily-build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
git clean -xdf
3030
3131
- task: PowerShell@2
32-
displayName: Prepare Powershell $(PSVersion)
32+
displayName: Prepare Powershell $(PSVersion)
3333
inputs:
3434
filePath: 'tools/Test/SmokeTest/PrepareRequiredPowershell.ps1'
35-
arguments: '-RequiredPsVersion $(PSVersion)'
35+
arguments: '-RequiredPsVersion $(PSVersion)'
3636

3737
- task: PowerShell@2
3838
displayName: 'Install platyPS'
@@ -49,7 +49,7 @@ jobs:
4949
inputs:
5050
command: custom
5151
custom: msbuild
52-
arguments: 'build.proj /t:"Build" /p:"Configuration=Release"'
52+
arguments: 'build.proj /t:"Build" /p:"Configuration=Release;TurnOnTestCoverage=true"'
5353

5454
- task: PowerShell@2
5555
displayName: 'Bump Version'
@@ -60,7 +60,7 @@ jobs:
6060
Get-PSRepository `
6161
./tools/RunVersionController.ps1 -Release 'Daily Build $(today)' `
6262
Exit"
63-
dotnet tool run pwsh -c $command
63+
dotnet tool run pwsh -c $command
6464
6565
- task: PowerShell@2
6666
displayName: 'Clean artifacts folder'
@@ -74,7 +74,7 @@ jobs:
7474
inputs:
7575
command: custom
7676
custom: msbuild
77-
arguments: 'build.proj /t:Build /p:Configuration=Release'
77+
arguments: 'build.proj /t:Build /p:Configuration=Release;TurnOnTestCoverage=true'
7878

7979
- task: EsrpCodeSigning@1
8080
inputs:
@@ -133,7 +133,7 @@ jobs:
133133
SessionTimeout: '60'
134134
MaxConcurrency: '50'
135135
MaxRetryAttempts: '5'
136-
136+
137137
- task: EsrpCodeSigning@1
138138
displayName: 'Sign 3rd Party [Strong Name]'
139139
inputs:

.azure-pipelines/live-test.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
parameters:
2+
- name: win_image
3+
displayName: Windows Image Version
4+
type: string
5+
default: windows-2019
6+
- name: linux_image
7+
displayName: Linux Image Version
8+
type: string
9+
default: ubuntu-20.04
10+
- name: macOS_image
11+
displayName: MacOS Image Version
12+
type: string
13+
default: macOS-11
14+
- name: win_ps_5_1
15+
displayName: Windows PowerShell 5.1 Version
16+
type: string
17+
default: 5.1
18+
- name: ps_7_0_x
19+
displayName: PowerShell 7.0.x Version
20+
type: string
21+
default: 7.0.13
22+
- name: ps_7_1_x
23+
displayName: PowerShell 7.1.x Version
24+
type: string
25+
default: 7.1.7
26+
- name: ps_7_2_x
27+
displayName: PowerShell 7.2.x Version
28+
type: string
29+
default: 7.2.7
30+
- name: ps_latest
31+
displayName: PowerShell Latest Version
32+
type: string
33+
default: latest
34+
- name: dotnet_sdk_6
35+
displayName: .NET 6 SDK Version
36+
type: string
37+
default: 6.0.x
38+
- name: dotnet_sdk_7
39+
displayName: .NET 7 SDK Version
40+
type: string
41+
default: 7.0.x
42+
43+
variables:
44+
LiveTestArtifactsName: LiveTestArtifacts
45+
LiveTestDataLocation: $(Pipeline.Workspace)/$(LiveTestArtifactsName)
46+
EnableTestCoverage: true
47+
TestCoverageLocation: $(LiveTestDataLocation)
48+
49+
pr: none
50+
trigger: none
51+
52+
jobs:
53+
- template: util/live-test-steps.yml
54+
parameters:
55+
name: 'win_ps_5_1'
56+
vmImage: ${{ parameters.win_image }}
57+
psVersion: ${{ parameters.win_ps_5_1 }}
58+
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
59+
60+
- template: util/live-test-steps.yml
61+
parameters:
62+
name: 'ps_7_0_x_win'
63+
vmImage: ${{ parameters.win_image }}
64+
psVersion: ${{ parameters.ps_7_0_x }}
65+
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
66+
67+
- template: util/live-test-steps.yml
68+
parameters:
69+
name: 'ps_7_1_x_win'
70+
vmImage: ${{ parameters.win_image }}
71+
psVersion: ${{ parameters.ps_7_1_x }}
72+
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
73+
74+
- template: util/live-test-steps.yml
75+
parameters:
76+
name: 'ps_7_2_x_win'
77+
vmImage: ${{ parameters.win_image }}
78+
psVersion: ${{ parameters.ps_7_2_x }}
79+
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
80+
81+
- template: util/live-test-steps.yml
82+
parameters:
83+
name: 'ps_latest_win'
84+
vmImage: ${{ parameters.win_image }}
85+
psVersion: ${{ parameters.ps_latest }}
86+
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}
87+
88+
- template: util/live-test-steps.yml
89+
parameters:
90+
name: 'ps_7_0_x_linux'
91+
vmImage: ${{ parameters.linux_image }}
92+
psVersion: ${{ parameters.ps_7_0_x }}
93+
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
94+
95+
- template: util/live-test-steps.yml
96+
parameters:
97+
name: 'ps_7_1_x_linux'
98+
vmImage: ${{ parameters.linux_image }}
99+
psVersion: ${{ parameters.ps_7_1_x }}
100+
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
101+
102+
- template: util/live-test-steps.yml
103+
parameters:
104+
name: 'ps_7_2_x_linux'
105+
vmImage: ${{ parameters.linux_image }}
106+
psVersion: ${{ parameters.ps_7_2_x }}
107+
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
108+
109+
- template: util/live-test-steps.yml
110+
parameters:
111+
name: 'ps_latest_linux'
112+
vmImage: ${{ parameters.linux_image }}
113+
psVersion: ${{ parameters.ps_latest }}
114+
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}
115+
116+
- template: util/live-test-steps.yml
117+
parameters:
118+
name: 'ps_7_2_x_macOS'
119+
vmImage: ${{ parameters.macOS_image }}
120+
psVersion: ${{ parameters.ps_7_2_x }}
121+
dotnetVersion: ${{ parameters.dotnet_sdk_6 }}
122+
123+
- template: util/live-test-steps.yml
124+
parameters:
125+
name: 'ps_latest_macOS'
126+
vmImage: ${{ parameters.macOS_image }}
127+
psVersion: ${{ parameters.ps_latest }}
128+
dotnetVersion: ${{ parameters.dotnet_sdk_7 }}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
parameters:
2+
- name: name
3+
- name: vmImage
4+
- name: psVersion
5+
- name: dotnetVersion
6+
7+
jobs:
8+
- job: ${{ parameters.name }}
9+
timeoutInMinutes: 180
10+
pool:
11+
vmImage: ${{ parameters.vmImage }}
12+
13+
steps:
14+
- task: UseDotNet@2
15+
condition: ne('${{ parameters.dotnetVersion }}', '')
16+
displayName: Install desired .NET version ${{ parameters.dotnetVersion }}
17+
inputs:
18+
packageType: sdk
19+
version: ${{ parameters.dotnetVersion }}
20+
21+
- task: PowerShell@2
22+
displayName: Install desired Powershell version ${{ parameters.psVersion }}
23+
inputs:
24+
pwsh: true
25+
targetType: filePath
26+
filePath: ./tools/TestFx/Live/InitializeLiveTestEnvironment.ps1
27+
arguments: -DesiredVersion ${{ parameters.psVersion }}
28+
29+
- task: PowerShell@2
30+
displayName: Create live test data location directory
31+
inputs:
32+
pwsh: true
33+
targetType: inline
34+
script:
35+
New-Item -Name $(LiveTestArtifactsName) -Path $(Pipeline.Workspace) -ItemType Directory -Force
36+
37+
- task: DownloadPipelineArtifact@2
38+
condition: and(succeeded(), eq(variables['GalleryName'], 'DailyBuild'), eq(variables['BuildPipelineBuildId'], ''))
39+
displayName: Download latest artifacts from daily build pipeline main branch
40+
inputs:
41+
buildType: specific
42+
project: $(ProjectToDownloadArtifacts)
43+
definition: $(BuildPipelineDefinitionId)
44+
buildVersionToDownload: latestFromBranch
45+
branchName: refs/heads/master
46+
artifactName: $(ArtifactName)
47+
targetPath: $(Pipeline.Workspace)
48+
49+
- task: DownloadPipelineArtifact@2
50+
condition: and(succeeded(), eq(variables['GalleryName'], 'DailyBuild'), ne(variables['BuildPipelineBuildId'], ''))
51+
displayName: Download specific artifacts from daily build pipeline
52+
inputs:
53+
buildType: specific
54+
project: $(ProjectToDownloadArtifacts)
55+
definition: $(BuildPipelineDefinitionId)
56+
buildVersionToDownload: specific
57+
pipelineId: $(BuildPipelineBuildId)
58+
artifactName: $(ArtifactName)
59+
targetPath: $(Pipeline.Workspace)
60+
61+
- task: PowerShell@2
62+
condition: and(succeeded(), eq(variables['GalleryName'], 'DailyBuild'))
63+
displayName: Copy artifacts to local repository
64+
inputs:
65+
pwsh: true
66+
targetType: inline
67+
script: |
68+
$azPackagesDir = New-Item -Name AzPackages -Path $(LiveTestDataLocation) -ItemType Directory -Force
69+
$azPackagesFiles = Join-Path -Path $(Pipeline.Workspace) -ChildPath *.nupkg
70+
Move-Item -Path $azPackagesFiles -Destination $azPackagesDir
71+
Get-ChildItem -LiteralPath $azPackagesDir
72+
73+
- task: PowerShell@2
74+
displayName: Install desired Az module from $(GalleryName)
75+
inputs:
76+
pwsh: true
77+
targetType: filePath
78+
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)'
80+
81+
- task: PowerShell@2
82+
displayName: Connect Azure with live test service principal
83+
inputs:
84+
pwsh: true
85+
targetType: filePath
86+
filePath: ./tools/TestFx/Live/InvokeLiveTestCITask.ps1
87+
arguments: -UseWindowsPowerShell ('${{ parameters.psVersion }}' -eq '5.1') -ScriptFile './tools/TestFx/Live/ConnectLiveTestServicePrincipal.ps1 $(LiveTestServicePrincipalSubscriptionId) $(LiveTestServicePrincipalTenantId) $(LiveTestServicePrincipalId) $(LiveTestServicePrincipalSecret)'
88+
89+
- task: PowerShell@2
90+
displayName: Run top E2E live scenarios
91+
inputs:
92+
pwsh: true
93+
targetType: filePath
94+
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)'
96+
failOnStderr: true
97+
98+
- task: PowerShell@2
99+
displayName: Save live test results to Kusto
100+
inputs:
101+
pwsh: true
102+
targetType: filePath
103+
filePath: ./tools/TestFx/Live/SaveLiveTestResult.ps1
104+
arguments: $(KustoServicePrincipalTenantId) $(KustoServicePrincipalId) $(KustoServicePrincipalSecret) $(KustoClusterName) $(KustoClusterRegion) $(LiveTestDatabaseName) $(LiveTestTableName) $(TestCoverageTableName) $(LiveTestDataLocation)
105+
106+
- task: PublishPipelineArtifact@1
107+
displayName: Publish live test results to pipeline artifact
108+
inputs:
109+
artifact: livetest-os-${{ parameters.vmImage }}-powershell-${{ parameters.psVersion }}
110+
targetPath: $(LiveTestDataLocation)
111+
condition: always()

build.proj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@
7474
<DockerRoot>$(RepoRoot)docker</DockerRoot>
7575
<DockerTools>$(RepoTools)Docker</DockerTools>
7676
<DockerImageName Condition="'$(DockerImageName)' == ''">azure-powershell</DockerImageName>
77-
78-
<!-- XML documentation related -->
77+
78+
<!-- XML documentation related -->
7979
<GenerateDocumentationFile Condition="'$(GenerateDocumentationFile)' != 'false'">true</GenerateDocumentationFile>
80+
81+
<!-- Test coverage flag -->
82+
<TurnOnTestCoverage Condition="'$(TurnOnTestCoverage)' != 'true'">false</TurnOnTestCoverage>
8083
</PropertyGroup>
8184

8285
<!-- Tasks -->
@@ -194,9 +197,9 @@
194197
<BuildAction Condition="'$(Configuration)' != 'Release'">build</BuildAction>
195198
<BuildAction Condition="'$(Configuration)' == 'Release'">publish</BuildAction>
196199
</PropertyGroup>
197-
198-
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\ExecuteCIStep.ps1 -Build -RepoArtifacts $(RepoArtifacts) -Configuration $(Configuration) -GenerateDocumentationFile $(GenerateDocumentationFile) -BuildAction $(BuildAction)&quot;" />
199-
200+
201+
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\ExecuteCIStep.ps1 -Build -RepoArtifacts $(RepoArtifacts) -Configuration $(Configuration) -GenerateDocumentationFile $(GenerateDocumentationFile) -EnableTestCoverage $(TurnOnTestCoverage) -BuildAction $(BuildAction)&quot;" />
202+
200203
<!-- Build version controller -->
201204
<Exec Command="dotnet build $(RepoTools)VersionController/VersionController.Netcore.csproj -c $(Configuration)" />
202205

src/Az.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<SignAssembly>true</SignAssembly>
2525
<DelaySign>true</DelaySign>
2626
<AssemblyOriginatorKeyFile>$(RepoSrc)MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
27-
<DefineConstants>TRACE;RELEASE;NETSTANDARD;SIGN</DefineConstants>
27+
<DefineConstants>TRACE;RELEASE;NETSTANDARD;SIGN;$(TestCoverage)</DefineConstants>
2828
</PropertyGroup>
2929

3030
<!-- Resources -->
@@ -53,4 +53,4 @@
5353
<None Update="*.ps1xml" CopyToOutputDirectory="PreserveNewest" />
5454
</ItemGroup>
5555

56-
</Project>
56+
</Project>

tools/ExecuteCIStep.ps1

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ Param(
2323
[String]
2424
$BuildAction='build',
2525

26-
[Switch]
26+
[String]
2727
$GenerateDocumentationFile,
2828

29+
[String]
30+
$EnableTestCoverage,
31+
2932
[Switch]
3033
$Test,
3134

@@ -37,10 +40,10 @@ Param(
3740

3841
[Switch]
3942
$StaticAnalysisDependency,
40-
43+
4144
[Switch]
4245
$StaticAnalysisSignature,
43-
46+
4447
[Switch]
4548
$StaticAnalysisHelp,
4649

@@ -70,14 +73,17 @@ $ErrorActionPreference = 'Stop'
7073
If ($Build)
7174
{
7275
$LogFile = "$RepoArtifacts/Build.Log"
73-
If ($GenerateDocumentationFile)
76+
$buildCmdResult = "dotnet $BuildAction $RepoArtifacts/Azure.PowerShell.sln -c $Configuration -fl '/flp1:logFile=$LogFile;verbosity=quiet'"
77+
If ($GenerateDocumentationFile -eq "false")
7478
{
75-
dotnet $BuildAction $RepoArtifacts/Azure.PowerShell.sln -c $Configuration -fl "/flp1:logFile=$LogFile;verbosity=quiet"
79+
$buildCmdResult += " -p:GenerateDocumentationFile=false"
7680
}
77-
Else
81+
if ($EnableTestCoverage -eq "true")
7882
{
79-
dotnet $BuildAction $RepoArtifacts/Azure.PowerShell.sln -c $Configuration -p:GenerateDocumentationFile=false -fl "/flp1:logFile=$LogFile;verbosity=quiet"
83+
$buildCmdResult += " -p:TestCoverage=TESTCOVERAGE"
8084
}
85+
Invoke-Expression -Command $buildCmdResult
86+
8187
If (Test-Path -Path "$RepoArtifacts/PipelineResult")
8288
{
8389
$LogContent = Get-Content $LogFile
@@ -324,4 +330,4 @@ If ($StaticAnalysisUX)
324330
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers ux -u -m $UXModuleList
325331
}
326332
Return
327-
}
333+
}

0 commit comments

Comments
 (0)