Support namespace override for local stress test deployments (#3416)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
parent
31edf57add
commit
3fc8cc0530
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user