Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 6103 (Azure#25816)
Browse files Browse the repository at this point in the history
Sync eng/common directory with azure-sdk-tools for PR
Azure/azure-sdk-tools#6103 See [eng/common
workflow](https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/README.md#workflow)

Co-authored-by: Ben Broderick Phillips <[email protected]>
  • Loading branch information
2 people authored and minhanh-phan committed Jun 12, 2023
1 parent 5c40519 commit f03c46c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
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

0 comments on commit f03c46c

Please sign in to comment.