Skip to content

Commit

Permalink
Improve scenario matrix edge case handling (#27070)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
  • Loading branch information
azure-sdk and benbp authored Oct 26, 2022
1 parent 0366ac2 commit 5c1fe4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions eng/common/scripts/stress-testing/generate-scenario-matrix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ function GenerateScenarioMatrix(
$scenariosMatrix += $entry
}

$valuesYaml = Get-Content -Raw (Join-Path (Split-Path $matrixFilePath) 'values.yaml')
$values = $valuesYaml | ConvertFrom-Yaml -Ordered
if (!$values) {$values = @{}}
$valuesConfig = Join-Path (Split-Path $matrixFilePath) 'values.yaml'
$values = [ordered]@{}
if (Test-Path $valuesConfig) {
$valuesYaml = Get-Content -Raw $valuesConfig
$values = $valuesYaml | ConvertFrom-Yaml -Ordered
if (!$values) {$values = @{}}

if ($values.ContainsKey('Scenarios')) {
throw "Please use matrix generation for stress test scenarios."
if ($values.ContainsKey('Scenarios')) {
throw "Please use matrix generation for stress test scenarios."
}
}

$values.scenarios = $scenariosMatrix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function DeployStressPackage(
}
}
}
$genVal.scenarios = foreach ($scenario in $genVal.scenarios) {
$genVal.scenarios = @( foreach ($scenario in $genVal.scenarios) {
$dockerPath = Join-Path $pkg.Directory $scenario.image
if ("image" -notin $scenario) {
$dockerPath = $dockerFilePath
Expand All @@ -257,7 +257,7 @@ function DeployStressPackage(
$scenario.imageTag = $imageTag
}
$scenario
}
} )

$genVal | ConvertTo-Yaml | Out-File -FilePath $genValFile
}
Expand Down

0 comments on commit 5c1fe4d

Please sign in to comment.