-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync eng/common directory with azure-sdk-tools for PR 3790 (#4041)
* Added yaml support for job matrix creation * autogen scenario matrix for stress test * Temporary Working State * update to default sparse * pr comments and some error handling * custom matrixfilename and ordering of generatedValues.yaml * common module import * JobMatrix write host Co-authored-by: Albert Cheng <[email protected]>
- Loading branch information
Showing
7 changed files
with
251 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
eng/common/scripts/stress-testing/generate-scenario-matrix.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
param( | ||
[string]$matrixFilePath, | ||
[string]$Selection, | ||
[Parameter(Mandatory=$False)][string]$DisplayNameFilter, | ||
[Parameter(Mandatory=$False)][array]$Filters, | ||
[Parameter(Mandatory=$False)][array]$Replace, | ||
[Parameter(Mandatory=$False)][array]$NonSparseParameters | ||
) | ||
|
||
function GenerateScenarioMatrix( | ||
[string]$matrixFilePath, | ||
[string]$Selection, | ||
[Parameter(Mandatory=$False)][string]$DisplayNameFilter, | ||
[Parameter(Mandatory=$False)][array]$Filters, | ||
[Parameter(Mandatory=$False)][array]$Replace, | ||
[Parameter(Mandatory=$False)][array]$NonSparseParameters | ||
) { | ||
$yamlConfig = Get-Content $matrixFilePath -Raw | ||
|
||
$prettyMatrix = &"$PSScriptRoot/../job-matrix/Create-JobMatrix.ps1" ` | ||
-ConfigPath $matrixFilePath ` | ||
-Selection $Selection ` | ||
-DisplayNameFilter $DisplayNameFilter ` | ||
-Filters $Filters ` | ||
-Replace $Replace ` | ||
-NonSparseParameters $NonSparseParameters | ||
Write-Host $prettyMatrix | ||
$prettyMatrix = $prettyMatrix | ConvertFrom-Json | ||
|
||
$scenariosMatrix = @() | ||
foreach($permutation in $prettyMatrix.psobject.properties) { | ||
$entry = @{} | ||
$entry.Name = $permutation.Name -replace '_', '-' | ||
$entry.Scenario = $entry.Name | ||
$entry.Remove("Name") | ||
foreach ($param in $permutation.value.psobject.properties) { | ||
$entry.add($param.Name, $param.value) | ||
} | ||
$scenariosMatrix += $entry | ||
} | ||
|
||
$valuesYaml = Get-Content -Raw (Join-Path (Split-Path $matrixFilePath) 'values.yaml') | ||
$values = $valuesYaml | ConvertFrom-Yaml -Ordered | ||
if (!$values) {$values = @{}} | ||
|
||
if ($values.ContainsKey('Scenarios')) { | ||
throw "Please use matrix generation for stress test scenarios." | ||
} | ||
|
||
$values.scenarios = $scenariosMatrix | ||
$values | ConvertTo-Yaml | Out-File -FilePath (Join-Path $matrixFilePath '../generatedValues.yaml') | ||
} | ||
|
||
function NewStressTestPackageInfo( | ||
[hashtable]$chart, | ||
[System.IO.FileInfo]$chartFile, | ||
[switch]$CI, | ||
[object]$namespaceOverride | ||
) { | ||
$namespace = if ($namespaceOverride) { | ||
$namespaceOverride | ||
} elseif ($CI) { | ||
$chart.annotations.namespace | ||
} else { | ||
GetUsername | ||
} | ||
|
||
return [StressTestPackageInfo]@{ | ||
Namespace = $namespace.ToLower() | ||
Directory = $chartFile.DirectoryName | ||
ReleaseName = $chart.name | ||
Dockerfile = $chart.annotations.dockerfile | ||
DockerBuildDir = $chart.annotations.dockerbuilddir | ||
} | ||
} | ||
|
||
# Don't call functions when the script is being dot sourced | ||
if ($MyInvocation.InvocationName -ne ".") { | ||
GenerateScenarioMatrix ` | ||
-matrixFilePath $matrixFilePath ` | ||
-Selection $Selection ` | ||
-DisplayNameFilter $DisplayNameFilter ` | ||
-Filters $Filters ` | ||
-Replace $Replace ` | ||
-NonSparseParameters $NonSparseParameters | ||
} |
Oops, something went wrong.