Support namespace override for local stress test deployments (#3416)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2022-03-09 14:09:00 -08:00 committed by GitHub
parent 31edf57add
commit 3fc8cc0530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 7 deletions

View File

@ -18,7 +18,10 @@ param(
[string]$Subscription,
# Default to true in Azure Pipelines environments
[switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID)
[switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID),
# Optional namespace override, otherwise the shell user or chart annotation will be used
[string]$Namespace
)
. $PSScriptRoot/stress-test-deployment-lib.ps1

View File

@ -11,7 +11,12 @@ class StressTestPackageInfo {
[string]$DockerBuildDir
}
function FindStressPackages([string]$directory, [hashtable]$filters = @{}, [switch]$CI) {
function FindStressPackages(
[string]$directory,
[hashtable]$filters = @{},
[switch]$CI,
[string]$namespaceOverride
) {
# Bare minimum filter for stress tests
$filters['stressTest'] = 'true'
@ -20,7 +25,11 @@ function FindStressPackages([string]$directory, [hashtable]$filters = @{}, [swit
foreach ($chartFile in $chartFiles) {
$chart = ParseChart $chartFile
if (matchesAnnotations $chart $filters) {
$packages += NewStressTestPackageInfo -chart $chart -chartFile $chartFile -CI:$CI
$packages += NewStressTestPackageInfo `
-chart $chart `
-chartFile $chartFile `
-CI:$CI `
-namespaceOverride $namespaceOverride
}
}
@ -41,8 +50,15 @@ function MatchesAnnotations([hashtable]$chart, [hashtable]$filters) {
return $true
}
function NewStressTestPackageInfo([hashtable]$chart, [System.IO.FileInfo]$chartFile, [switch]$CI) {
$namespace = if ($CI) {
function NewStressTestPackageInfo(
[hashtable]$chart,
[System.IO.FileInfo]$chartFile,
[switch]$CI,
[object]$namespaceOverride
) {
$namespace = if ($namespaceOverride) {
$namespaceOverride
} elseif ($CI) {
$chart.annotations.namespace
} else {
# Check GITHUB_USER for users in codespaces environments, since the default user is `codespaces` and

View File

@ -70,7 +70,8 @@ function DeployStressTests(
[string]$deployId = 'local',
[switch]$login,
[string]$subscription = '',
[switch]$CI
[switch]$CI,
[string]$Namespace
) {
if ($environment -eq 'test') {
if ($clusterGroup -or $subscription) {
@ -97,7 +98,7 @@ function DeployStressTests(
Run helm repo update
if ($LASTEXITCODE) { return $LASTEXITCODE }
$pkgs = FindStressPackages -directory $searchDirectory -filters $filters -CI:$CI
$pkgs = FindStressPackages -directory $searchDirectory -filters $filters -CI:$CI -namespaceOverride $Namespace
Write-Host "" "Found $($pkgs.Length) stress test packages:"
Write-Host $pkgs.Directory ""
foreach ($pkg in $pkgs) {