Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync eng/common directory with azure-sdk-tools for PR 6103 #34860

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions eng/common/scripts/stress-testing/deploy-stress-tests.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Set a default parameter set here so we can call this script without requiring -Login and -Subscription,
# but if it IS called with either of those, then both parameters need to be required. Not defining a
# default parameter set makes Login/Subscription required all the time.
# Not defining a default parameter set makes SkipLogin/Subscription required all the time.
[CmdletBinding(DefaultParameterSetName = 'Default')]
param(
[string]$SearchDirectory,
[hashtable]$Filters,
[string]$Environment,
[string]$Repository,
[switch]$PushImages,
[switch]$SkipPushImages,
[string]$ClusterGroup,
[string]$DeployId,
[switch]$Login,
[switch]$SkipLogin,
[string]$Subscription,

# Default to true in Azure Pipelines environments
Expand Down
26 changes: 13 additions & 13 deletions eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function RunOrExitOnFailure()
}
}

function Login([string]$subscription, [string]$clusterGroup, [switch]$pushImages)
function Login([string]$subscription, [string]$clusterGroup, [switch]$skipPushImages)
{
Write-Host "Logging in to subscription, cluster and container registry"
az account show *> $null
Expand Down Expand Up @@ -73,7 +73,7 @@ function Login([string]$subscription, [string]$clusterGroup, [switch]$pushImages
RunOrExitOnFailure kubectl config set-context $clusterName --namespace $defaultNamespace
}

if ($pushImages) {
if (!$skipPushImages) {
$registry = RunOrExitOnFailure az acr list -g $clusterGroup --subscription $subscription -o json
$registryName = ($registry | ConvertFrom-Json).name
RunOrExitOnFailure az acr login -n $registryName
Expand All @@ -86,10 +86,10 @@ function DeployStressTests(
# Default to playground environment
[string]$environment = 'pg',
[string]$repository = '',
[switch]$pushImages,
[switch]$skipPushImages,
[string]$clusterGroup = '',
[string]$deployId = '',
[switch]$login,
[switch]$skipLogin,
[string]$subscription = '',
[switch]$CI,
[string]$Namespace,
Expand Down Expand Up @@ -125,8 +125,8 @@ function DeployStressTests(
throw "clusterGroup and subscription parameters must be specified when deploying to an environment that is not pg or prod."
}

if ($login) {
Login -subscription $subscription -clusterGroup $clusterGroup -pushImages:$pushImages
if (!$skipLogin) {
Login -subscription $subscription -clusterGroup $clusterGroup -skipPushImages:$skipPushImages
}

$chartRepoName = 'stress-test-charts'
Expand Down Expand Up @@ -162,8 +162,8 @@ function DeployStressTests(
-deployId $deployer `
-environment $environment `
-repositoryBase $repository `
-pushImages:$pushImages `
-login:$login `
-skipPushImages:$skipPushImages `
-skipLogin:$skipLogin `
-clusterGroup $clusterGroup `
-subscription $subscription
}
Expand All @@ -189,8 +189,8 @@ function DeployStressPackage(
[string]$deployId,
[string]$environment,
[string]$repositoryBase,
[switch]$pushImages,
[switch]$login,
[switch]$skipPushImages,
[switch]$skipLogin,
[string]$clusterGroup,
[string]$subscription
) {
Expand Down Expand Up @@ -267,7 +267,7 @@ function DeployStressPackage(
}
$dockerfileName = ($dockerFilePath -split { $_ -in '\', '/' })[-1].ToLower()
$imageTag = $imageTagBase + "/${dockerfileName}:${deployId}"
if ($pushImages) {
if (!$skipPushImages) {
Write-Host "Building and pushing stress test docker image '$imageTag'"
$dockerFile = Get-ChildItem $dockerFilePath

Expand All @@ -290,8 +290,8 @@ function DeployStressPackage(

Run docker push $imageTag
if ($LASTEXITCODE) {
if ($login) {
Write-Warning "If docker push is failing due to authentication issues, try calling this script with '-Login'"
if (!$skipLogin) {
Write-Warning "If docker push is failing due to authentication issues, try calling this script without '-SkipLogin'"
}
}
}
Expand Down