From d4ad7e66cea5190627ac6e10e8e667798eadf082 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Mon, 24 Oct 2022 23:06:57 -0400 Subject: [PATCH] Improve scenario matrix edge case handling --- .../stress-testing/generate-scenario-matrix.ps1 | 14 +++++++++----- .../stress-testing/stress-test-deployment-lib.ps1 | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/eng/common/scripts/stress-testing/generate-scenario-matrix.ps1 b/eng/common/scripts/stress-testing/generate-scenario-matrix.ps1 index aba8be3451dd..1ddb05cd0cd7 100644 --- a/eng/common/scripts/stress-testing/generate-scenario-matrix.ps1 +++ b/eng/common/scripts/stress-testing/generate-scenario-matrix.ps1 @@ -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 diff --git a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 index a08247777976..0365bbb30cbb 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -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 @@ -257,7 +257,7 @@ function DeployStressPackage( $scenario.imageTag = $imageTag } $scenario - } + } ) $genVal | ConvertTo-Yaml | Out-File -FilePath $genValFile }