Skip to content

Commit 019934c

Browse files
committed
test
1 parent 9947f18 commit 019934c

File tree

6 files changed

+168
-144
lines changed

6 files changed

+168
-144
lines changed

.azure-pipelines/PipelineSteps/BatchGeneration/filter.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ $groupedBuildModules = Group-Modules -Modules $changedModules -MaxParallelJobs $
4545
Write-Matrix -GroupedModules $groupedBuildModules -VariableName 'buildTargets' -RepoRoot $RepoRoot
4646

4747
$groupedAnalyzeModules = Group-Modules -Modules $changedModules -MaxParallelJobs $MaxParallelAnalyzeJobs
48-
Write-Matrix -GroupedModules $groupedAnalyzeModules -variableName 'analyzeTargets' -RepoRoot $RepoRoot
48+
Write-Matrix -GroupedModules $groupedAnalyzeModules -VariableName 'analyzeTargets' -RepoRoot $RepoRoot
4949

50-
# $groupedTestWindowsModules = Split-List -subModules $changedSubModules -maxParallelJobs $MaxParallelTestWindowsJobs
51-
# Write-Matrix -variableName 'TestWindowsTargets' -groupedSubModules $groupedTestWindowsModules
50+
$groupedTestWindowsModules = Group-Modules -Modules $changedSubModules -MaxParallelJobs $MaxParallelTestWindowsJobs
51+
Write-Matrix -GroupedModules $groupedTestWindowsModules -VariableName 'testWindowsTargets' -RepoRoot $RepoRoot
5252

53-
# $groupedTestLinuxModules = Split-List -subModules $changedSubModules -maxParallelJobs $MaxParallelTestLinuxJobs
54-
# Write-Matrix -variableName 'TestLinuxTargets' -groupedSubModules $groupedTestLinuxModules
53+
$groupedTestLinuxModules = Group-Modules -Modules $changedSubModules -MaxParallelJobs $MaxParallelTestLinuxJobs
54+
Write-Matrix -GroupedModules $groupedTestLinuxModules -VariableName 'testLinuxTargets' -RepoRoot $RepoRoot
5555

56-
# $groupedTestMacModules = Split-List -subModules $changedSubModules -maxParallelJobs $MaxParallelTestMacJobs
57-
# Write-Matrix -variableName 'TestMacTargets' -groupedSubModules $groupedTestMacModules
56+
$groupedTestMacModules = Group-Modules -Modules $changedSubModules -MaxParallelJobs $MaxParallelTestMacJobs
57+
Write-Matrix -GroupedModules $groupedTestMacModules -VariableName 'testMacOSTargets' -RepoRoot $RepoRoot

.azure-pipelines/PipelineSteps/BatchGeneration/test-module.ps1

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
param (
2+
[string]$MatrixKey,
3+
[string]$TestEnvName,
4+
[string]$RepoRoot
5+
)
6+
7+
$utilFilePath = Join-Path $RepoRoot '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'util.psm1'
8+
Import-Module $utilFilePath -Force
9+
$subModuleGroup = Get-Targets -RepoRoot $RepoRoot -TargetsOutputFileName "test$($TestEnvName)Targets.json" -MatrixKey $MatrixKey
10+
11+
if ($TestEnvName -eq 'Linux') {
12+
$accountsModulePath = Join-Path $RepoRoot 'artifacts' 'Debug' "Az.Accounts" "Az.Accounts.psd1"
13+
Import-Module $accountsModulePath -Force
14+
}
15+
16+
$results = @()
17+
18+
foreach ($subModule in $subModuleGroup) {
19+
$startTime = Get-Date
20+
$moduleName, $subModuleName = $subModule -split '/'
21+
$result = @{
22+
Module = $moduleName
23+
SubModule = $subModuleName
24+
Status = "Success"
25+
DurationSeconds = 0
26+
Error = ""
27+
}
28+
29+
try {
30+
Write-Host "Testing sub module: $subModule"
31+
$subModulePath = Join-Path $RepoRoot 'artifacts' 'Debug' "Az.$ModuleName" $subModuleName
32+
Push-Location $subModulePath
33+
34+
& ".\test-module.ps1"
35+
36+
if ($LASTEXITCODE -ne 0) {
37+
Write-Warning "❌ Test failed: $subModule (exit code $LASTEXITCODE)"
38+
$result.Status = "Failed"
39+
$result.Error = "Test failed with exit code $LASTEXITCODE"
40+
}
41+
}
42+
catch {
43+
Write-Warning "Failed to test module: $module"
44+
Write-Warning "Error message: $($_.Exception.Message)"
45+
$result.Status = "Failed"
46+
$result.Error = $_.Exception.Message
47+
}
48+
finally {
49+
$endTime = Get-Date
50+
$result.DurationSeconds = ($endTime - $startTime).TotalSeconds
51+
$results += $result
52+
Pop-Location
53+
}
54+
}
55+
56+
$artifactRoot = Join-Path $RepoRoot 'artifacts'
57+
$reportPath = Join-Path $artifactRoot "Test$($TestEnvName)Report-$MatrixKey.json"
58+
$results | ConvertTo-Json -Depth 3 | Out-File -FilePath $reportPath -Encoding utf8

.azure-pipelines/batch-generation.yml

Lines changed: 41 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ variables:
88
MaxParallelBuildJobs: 15
99
MaxParallelAnalyzeJobs: 5
1010
MaxParallelTestWindowsJobs: 5
11-
MaxParallelTestLinuxJobs: 5
12-
MaxParallelTestMacJobs: 5
11+
MaxParallelTestLinuxJobs: 4
12+
MaxParallelTestMacJobs: 2
1313
WindowsAgentPoolName: pool-windows-2019
1414
LinuxAgentPoolName: pool-ubuntu-2004
1515
MacOSAgentPoolName: 'Azure Pipelines'
@@ -67,7 +67,10 @@ stages:
6767
- job: generate
6868
displayName: "Batch Generate: "
6969
dependsOn: prepare
70-
condition: ne(dependencies.prepare.outputs['mtrx.generateTargets'], '{}')
70+
condition: and(
71+
ne(dependencies.prepare.outputs['mtrx.generateTargets'], ''),
72+
ne(dependencies.prepare.outputs['mtrx.generateTargets'], '{}')
73+
)
7174
timeoutInMinutes: ${{ variables.GenerateTimeoutInMinutes }}
7275
pool: ${{ variables.WindowsAgentPoolName }}
7376
strategy:
@@ -182,7 +185,10 @@ stages:
182185
- job: build
183186
displayName: "Build:"
184187
dependsOn: filter
185-
condition: ne(dependencies.filter.outputs['mtrx.buildTargets'], '{}')
188+
condition: and(
189+
ne(dependencies.filter.outputs['mtrx.buildTargets'], ''),
190+
ne(dependencies.filter.outputs['mtrx.buildTargets'], '{}')
191+
)
186192
timeoutInMinutes: ${{ variables.BuildTimeoutInMinutes }}
187193
pool: ${{ variables.WindowsAgentPoolName }}
188194
strategy:
@@ -235,7 +241,7 @@ stages:
235241

236242
- download: current
237243
patterns: |
238-
**/debug/**
244+
**/Debug/**
239245
**/StaticAnalysis/**
240246
displayName: 'Download build artifacts'
241247

@@ -255,14 +261,14 @@ stages:
255261
$workspace = "$env:PIPELINE_WORKSPACE"
256262
$repoRoot = "$(Build.SourcesDirectory)"
257263
$artifactsRoot = Join-Path $repoRoot "artifacts"
258-
$debugArtifactDestPath = Join-Path $artifactsRoot "debug"
264+
$debugArtifactDestPath = Join-Path $artifactsRoot "Debug"
259265
New-Item -ItemType Directory -Force -Path $debugArtifactDestPath | Out-Null
260266
261267
$copiedModules = @{}
262268
$StaticAnalysisCopied = $false
263269
264270
Get-ChildItem -Path $workspace -Directory | ForEach-Object {
265-
$debugArtifactSrcPath = Join-Path $_.FullName "debug"
271+
$debugArtifactSrcPath = Join-Path $_.FullName "Debug"
266272
$StaticAnalysisSrcDirectory = Join-Path $_.FullName 'StaticAnalysis'
267273
268274
if (Test-Path $debugArtifactSrcPath) {
@@ -308,7 +314,10 @@ stages:
308314
displayName: "Analyze:"
309315
dependsOn:
310316
- collect
311-
condition: ne(stageDependencies.Build.filter.outputs['mtrx.analyzeTargets'], '{}')
317+
condition: and(
318+
ne(stageDependencies.Build.filter.outputs['mtrx.analyzeTargets'], ''),
319+
ne(stageDependencies.Build.filter.outputs['mtrx.analyzeTargets'], '{}')
320+
)
312321
timeoutInMinutes: ${{ variables.AnalysisTimeoutInMinutes }}
313322
pool: ${{ variables.WindowsAgentPoolName }}
314323
strategy:
@@ -318,7 +327,6 @@ stages:
318327
steps:
319328
- checkout: self
320329
fetchDepth: 1
321-
sparseCheckoutDirectories: tools/ .azure-pipelines/
322330
fetchTags: false
323331

324332
- task: DownloadPipelineArtifact@2
@@ -357,95 +365,37 @@ stages:
357365
script: |
358366
Write-Host "Matrix Key: $(MatrixKey)"
359367
360-
Write-Host "Top-level contents of $(Build.SourcesDirectory):"
361-
Get-ChildItem -Path "$(Build.SourcesDirectory)" | ForEach-Object {
362-
Write-Host $_.FullName
363-
}
364-
365368
$analyseModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'analyse-modules.ps1'
366369
& $analyseModulesPath -MatrixKey "$(MatrixKey)" -RepoRoot "$(Build.SourcesDirectory)"
367370
368-
369371
- task: PublishPipelineArtifact@1
370372
displayName: 'Save Analyse Report'
371373
inputs:
372374
targetPath: artifacts
373375
artifact: 'analyse-$(MatrixKey)'
374376
condition: always()
375377

376-
377-
# - job: test_windows
378-
# displayName: "Test Windows:"
379-
# dependsOn:
380-
# - filter
381-
# - build
382-
# condition: and(succeeded(), ne(dependencies.filter.outputs['mtrx.TestWindowsTargets'], '{}'))
383-
# timeoutInMinutes: ${{ variables.TestTimeoutInMinutes }}
384-
# pool: ${{ variables.WindowsAgentPoolName }}
385-
# strategy:
386-
# matrix: $[ dependencies.filter.outputs['mtrx.TestWindowsTargets'] ]
387-
# maxParallel: ${{ variables.MaxParallelTestWindowsJobs }}
388-
389-
# steps:
390-
# - checkout: none
391-
392-
# - task: PowerShell@2
393-
# name: test
394-
# displayName: 'Test Windows'
395-
# inputs:
396-
# targetType: inline
397-
# pwsh: true
398-
# script: |
399-
# $testModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'test-module.ps1'
400-
# & $testModulesPath -MatrixKey "$(MatrixKey)" -Target "$(Target)" -TestEnvName 'Windows' -RepoRoot "$(Build.SourcesDirectory)" -ArtifactRoot "$(Build.ArtifactStagingDirectory)"
401-
402-
# - job: test_linux
403-
# displayName: "Test Linux:"
404-
# dependsOn:
405-
# - filter
406-
# - build
407-
# condition: and(succeeded(), ne(dependencies.filter.outputs['mtrx.TestLinuxTargets'], '{}'))
408-
# timeoutInMinutes: ${{ variables.TestTimeoutInMinutes }}
409-
# pool: ${{ variables.LinuxAgentPoolName }}
410-
# strategy:
411-
# matrix: $[ dependencies.filter.outputs['mtrx.TestLinuxTargets'] ]
412-
# maxParallel: ${{ variables.MaxParallelTestLinuxJobs }}
413-
414-
# steps:
415-
# - checkout: none
416-
417-
# - task: PowerShell@2
418-
# name: test
419-
# displayName: 'Test Linux'
420-
# inputs:
421-
# targetType: inline
422-
# pwsh: true
423-
# script: |
424-
# $testModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'test-module.ps1'
425-
# & $testModulesPath -MatrixKey "$(MatrixKey)" -Target "$(Target)" -TestEnvName 'Linux' -RepoRoot "$(Build.SourcesDirectory)" -ArtifactRoot "$(Build.ArtifactStagingDirectory)"
426-
427-
# - job: test_mac
428-
# displayName: "Test Mac:"
429-
# dependsOn: filter
430-
# condition: and(succeeded(), ne(dependencies.filter.outputs['mtrx.TestMacTargets'], '{}'))
431-
# timeoutInMinutes: ${{ variables.TestTimeoutInMinutes }}
432-
# pool:
433-
# name: ${{ variables.MacOSAgentPoolName }}
434-
# vmImage: ${{ variables.MacOSAgentPoolVMImage }}
435-
# strategy:
436-
# matrix: $[ dependencies.filter.outputs['mtrx.TestMacTargets'] ]
437-
# maxParallel: ${{ variables.MaxParallelTestMacJobs }}
438-
439-
# steps:
440-
# - checkout: none
441-
442-
# - task: PowerShell@2
443-
# name: test
444-
# displayName: 'Test Mac'
445-
# inputs:
446-
# targetType: inline
447-
# pwsh: true
448-
# script: |
449-
# $testModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'test-module.ps1'
450-
# & $testModulesPath -MatrixKey "$(MatrixKey)" -Target "$(Target)" -TestEnvName 'Mac' -RepoRoot "$(Build.SourcesDirectory)" -ArtifactRoot "$(Build.ArtifactStagingDirectory)"
451-
378+
- template: util/batch-generation-test-job.yml
379+
parameters:
380+
jobName: 'test_windows'
381+
OSName: 'Windows'
382+
timeoutInMinutes: ${{ variables.TestTimeoutInMinutes }}
383+
agentPoolName: ${{ variables.WindowsAgentPoolName }}
384+
maxParallel: ${{ variables.MaxParallelTestWindowsJobs }}
385+
386+
- template: util/batch-generation-test-job.yml
387+
parameters:
388+
jobName: 'test_linux'
389+
OSName: 'Linux'
390+
timeoutInMinutes: ${{ variables.TestTimeoutInMinutes }}
391+
agentPoolName: ${{ variables.LinuxAgentPoolName }}
392+
maxParallel: ${{ variables.MaxParallelTestLinuxJobs }}
393+
394+
- template: util/batch-generation-test-job.yml
395+
parameters:
396+
jobName: 'test_mac'
397+
OSName: 'MacOS'
398+
timeoutInMinutes: ${{ variables.TestTimeoutInMinutes }}
399+
agentPoolName: ${{ variables.MacOSAgentPoolName }}
400+
agentPoolVMImage: ${{ variables.MacOSAgentPoolVMImage }}
401+
maxParallel: ${{ variables.MaxParallelTestMacJobs }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
parameters:
2+
jobName: 'test_windows'
3+
OSName: 'Windows'
4+
timeoutInMinutes: 60
5+
agentPoolName: 'pool-windows-2019'
6+
agentPoolVMImage: ''
7+
maxParallel: 3
8+
9+
jobs:
10+
- job: ${{ parameters.jobName }}
11+
displayName: "Test ${{ parameters.OSName }}:"
12+
dependsOn:
13+
- collect
14+
condition: and(
15+
ne(stageDependencies.Build.filter.outputs['mtrx.test${{ parameters.OSName }}Targets'], ''),
16+
ne(stageDependencies.Build.filter.outputs['mtrx.test${{ parameters.OSName }}Targets'], '{}')
17+
)
18+
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
19+
pool:
20+
name: ${{ parameters.agentPoolName }}
21+
${{ if ne(parameters.agentPoolVMImage, '') }}:
22+
vmImage: ${{ parameters.agentPoolVMImage }}
23+
strategy:
24+
matrix: $[ stageDependencies.Build.filter.outputs['mtrx.test${{ parameters.OSName }}Targets'] ]
25+
maxParallel: ${{ parameters.maxParallel }}
26+
27+
steps:
28+
#TODO(Bernard) check if can skip checkout step after move this to template
29+
- checkout: self
30+
fetchDepth: 1
31+
fetchTags: false
32+
33+
- task: DownloadPipelineArtifact@2
34+
inputs:
35+
artifact: collect
36+
path: $(Build.SourcesDirectory)/artifacts
37+
displayName: 'Download collected artifact to artifacts folder'
38+
39+
- task: UseDotNet@2
40+
displayName: 'Use .NET SDK for Test'
41+
inputs:
42+
packageType: sdk
43+
version: 8.x
44+
45+
- task: PowerShell@2
46+
name: test
47+
displayName: 'Test ${{ parameters.OSName }}'
48+
inputs:
49+
targetType: inline
50+
pwsh: true
51+
script: |
52+
$testModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'test-modules.ps1'
53+
& $testModulesPath -MatrixKey "$(MatrixKey)" -TestEnvName ${{ parameters.OSName }} -RepoRoot "$(Build.SourcesDirectory)"
54+
55+
- task: PublishPipelineArtifact@1
56+
displayName: 'Save Test ${{ parameters.OSName }} Report'
57+
inputs:
58+
targetPath: artifacts
59+
artifact: 'test${{ parameters.OSName }}-$(MatrixKey)'
60+
condition: always()
61+

src/Astro/Astro.Autorest/test/Get-AzAstroOrganization.Recording.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
},
2020
"Response": {
21-
"StatusCode": 200,
21+
"StatusCode": 800,
2222
"Headers": {
2323
"Cache-Control": [ "no-cache" ],
2424
"Pragma": [ "no-cache" ],

0 commit comments

Comments
 (0)