From f174d97e8a0f1a9aa37c6c7e388c2b2fff84cf08 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 26 Oct 2022 12:51:22 -0700 Subject: [PATCH] Improve scenario matrix edge case handling (#4065) Co-authored-by: Ben Broderick Phillips --- .../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 aba8be345..1ddb05cd0 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 a08247777..0365bbb30 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 }