Skip to content

Commit bae6ad5

Browse files
azure-sdkbenbp
andauthored
Support namespace override for local stress test deployments (Azure#20751)
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
1 parent 37c67f0 commit bae6ad5

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

eng/common/scripts/stress-testing/deploy-stress-tests.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ param(
1818
[string]$Subscription,
1919

2020
# Default to true in Azure Pipelines environments
21-
[switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID)
21+
[switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID),
22+
23+
# Optional namespace override, otherwise the shell user or chart annotation will be used
24+
[string]$Namespace
2225
)
2326

2427
. $PSScriptRoot/stress-test-deployment-lib.ps1

eng/common/scripts/stress-testing/find-all-stress-packages.ps1

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ class StressTestPackageInfo {
1111
[string]$DockerBuildDir
1212
}
1313

14-
function FindStressPackages([string]$directory, [hashtable]$filters = @{}, [switch]$CI) {
14+
function FindStressPackages(
15+
[string]$directory,
16+
[hashtable]$filters = @{},
17+
[switch]$CI,
18+
[string]$namespaceOverride
19+
) {
1520
# Bare minimum filter for stress tests
1621
$filters['stressTest'] = 'true'
1722

@@ -20,7 +25,11 @@ function FindStressPackages([string]$directory, [hashtable]$filters = @{}, [swit
2025
foreach ($chartFile in $chartFiles) {
2126
$chart = ParseChart $chartFile
2227
if (matchesAnnotations $chart $filters) {
23-
$packages += NewStressTestPackageInfo -chart $chart -chartFile $chartFile -CI:$CI
28+
$packages += NewStressTestPackageInfo `
29+
-chart $chart `
30+
-chartFile $chartFile `
31+
-CI:$CI `
32+
-namespaceOverride $namespaceOverride
2433
}
2534
}
2635

@@ -41,8 +50,15 @@ function MatchesAnnotations([hashtable]$chart, [hashtable]$filters) {
4150
return $true
4251
}
4352

44-
function NewStressTestPackageInfo([hashtable]$chart, [System.IO.FileInfo]$chartFile, [switch]$CI) {
45-
$namespace = if ($CI) {
53+
function NewStressTestPackageInfo(
54+
[hashtable]$chart,
55+
[System.IO.FileInfo]$chartFile,
56+
[switch]$CI,
57+
[object]$namespaceOverride
58+
) {
59+
$namespace = if ($namespaceOverride) {
60+
$namespaceOverride
61+
} elseif ($CI) {
4662
$chart.annotations.namespace
4763
} else {
4864
# Check GITHUB_USER for users in codespaces environments, since the default user is `codespaces` and

eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ function DeployStressTests(
7070
[string]$deployId = 'local',
7171
[switch]$login,
7272
[string]$subscription = '',
73-
[switch]$CI
73+
[switch]$CI,
74+
[string]$Namespace
7475
) {
7576
if ($environment -eq 'test') {
7677
if ($clusterGroup -or $subscription) {
@@ -97,7 +98,7 @@ function DeployStressTests(
9798
Run helm repo update
9899
if ($LASTEXITCODE) { return $LASTEXITCODE }
99100

100-
$pkgs = FindStressPackages -directory $searchDirectory -filters $filters -CI:$CI
101+
$pkgs = FindStressPackages -directory $searchDirectory -filters $filters -CI:$CI -namespaceOverride $Namespace
101102
Write-Host "" "Found $($pkgs.Length) stress test packages:"
102103
Write-Host $pkgs.Directory ""
103104
foreach ($pkg in $pkgs) {

0 commit comments

Comments
 (0)