Skip to content

Commit

Permalink
Fix broken relative paths in matrix-generator tests and samples + m…
Browse files Browse the repository at this point in the history
…ake the tests runnable by `common-tests/ci.yml`. (#5095)

This PR fixes paths I forgot to update when I did this PR:
- #5027

And as such this PR contributes to addressing:
- #4995

It also adds `UnitTest` tags to the `matrix-generator` tests so [`common-tests/ci.yml` pipeline](https://dev.azure.com/azure-sdk/internal/_build?definitionId=5809) executes them.

### Related work

- #5098
  • Loading branch information
Konrad Jamrozik authored Jan 10, 2023
1 parent b49031d commit 3418b9a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 28 deletions.
6 changes: 3 additions & 3 deletions eng/common-tests/matrix-generator/samples/matrix-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ variables:
jobs:
- template: /eng/common/pipelines/templates/jobs/archetype-sdk-tests-generate.yml
parameters:
JobTemplatePath: /eng/common/scripts/job-matrix/samples/matrix-job-sample.yml
JobTemplatePath: /eng/common-tests/matrix-generator/samples/matrix-job-sample.yml
AdditionalParameters: {}
Pool: Azure Pipelines
OsVmImage: ubuntu-18.04
Expand All @@ -22,11 +22,11 @@ jobs:
- .*Framework.*=net5.0/net5.1
MatrixConfigs:
- Name: base_product_matrix
Path: eng/common/scripts/job-matrix/samples/matrix.json
Path: eng/common-tests/matrix-generator/samples/matrix.json
Selection: all
GenerateVMJobs: true
- Name: sparse_product_matrix
Path: eng/common/scripts/job-matrix/samples/matrix.json
Path: eng/common-tests/matrix-generator/samples/matrix.json
Selection: sparse
NonSparseParameters:
- framework
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Import-Module Pester

BeforeAll {
. $PSScriptRoot/../job-matrix-functions.ps1
. $PSScriptRoot/../../../common/scripts/job-matrix/job-matrix-functions.ps1

$matrixConfig = @"
{
Expand All @@ -15,7 +15,7 @@ BeforeAll {
$config = GetMatrixConfigFromJson $matrixConfig
}

Describe "Matrix Filter" -Tag "filter" {
Describe "Matrix Filter" -Tag "UnitTest", "filter" {
It "Should filter by matrix display name" -TestCases @(
@{ regex = "windows.*"; expectedFirst = "windows2022_net461"; length = 4 }
@{ regex = "windows2022_netcoreapp21_modetest"; expectedFirst = "windows2022_netcoreapp21_modetest"; length = 1 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Import-Module Pester


BeforeAll {
. $PSScriptRoot/../job-matrix-functions.ps1
. $PSScriptRoot/../../../common/scripts/job-matrix/job-matrix-functions.ps1

function CompareMatrices([Array]$matrix, [Array]$expected) {
$matrix.Length | Should -Be $expected.Length
Expand All @@ -18,7 +18,7 @@ BeforeAll {
}
}

Describe "Platform Matrix nonSparse" -Tag "nonsparse" {
Describe "Platform Matrix nonSparse" -Tag "UnitTest", "nonsparse" {
BeforeEach {
$matrixJson = @'
{
Expand Down Expand Up @@ -88,7 +88,7 @@ Describe "Platform Matrix nonSparse" -Tag "nonsparse" {
$matrixJson = @'
{
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json",
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json",
"TestField1": "test1"
},
"exclude": [ { "Baz": "importedBaz" } ]
Expand Down Expand Up @@ -125,12 +125,26 @@ Describe "Platform Matrix nonSparse" -Tag "nonsparse" {
}
}

# This test is currently disabled (it doesn't have "UnitTest" tag) as it fails
# in test "Should generate a sparse matrix where the entire base matrix is imported" on line:
#
# $matrix = GenerateMatrix $importConfig "sparse"
#
# with message:
#
# ParameterBindingArgumentTransformationException: Cannot process argument transformation on parameter 'parameters'. Cannot convert the "System.Collections.Hashtable" value of type "System.Collections.Hashtable" to type "MatrixParameter".
#
# See full build failure:
# https://dev.azure.com/azure-sdk/internal/_build/results?buildId=2102328&view=logs&j=375fdae1-accf-5db0-5fc3-af258c8525cc&t=9e9d0eca-bdb6-593f-47d7-63cf69095eca&l=22
#
# Issue to track:
# https://github.com/Azure/azure-sdk-tools/issues/5098
Describe "Platform Matrix Import" -Tag "import" {
It "Should generate a sparse matrix where the entire base matrix is imported" {
$matrixJson = @'
{
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json"
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json"
},
"include": [
{
Expand Down Expand Up @@ -173,7 +187,7 @@ Describe "Platform Matrix Import" -Tag "import" {
$matrixJson = @'
{
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json",
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json",
"TestField1": "test1",
"TestField2": "test2"
},
Expand Down Expand Up @@ -206,7 +220,7 @@ Describe "Platform Matrix Import" -Tag "import" {
$matrixJson = @'
{
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json",
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json",
"testField": [ "test1", "test2" ]
}
}
Expand Down Expand Up @@ -235,7 +249,7 @@ Describe "Platform Matrix Import" -Tag "import" {
"importedBaz": "importedBazNameOverride"
},
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json",
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json",
"testField": [ "test1", "test2" ]
}
}
Expand All @@ -251,7 +265,7 @@ Describe "Platform Matrix Import" -Tag "import" {
$matrixJson = @'
{
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json",
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json",
"testField1": [ "test11", "test12" ],
"testField2": [ "test21", "test22" ]
}
Expand Down Expand Up @@ -299,7 +313,7 @@ Describe "Platform Matrix Import" -Tag "import" {
$matrixJson = @'
{
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json",
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json",
"testField": [ "test1", "test2", "test3" ],
},
"include": [
Expand Down Expand Up @@ -364,7 +378,7 @@ Describe "Platform Matrix Import" -Tag "import" {
$matrixJson = @'
{
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json",
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json",
"Foo": [ "fooOverride1", "fooOverride2" ],
}
}
Expand All @@ -376,7 +390,7 @@ Describe "Platform Matrix Import" -Tag "import" {

}

Describe "Platform Matrix Replace" -Tag "replace" {
Describe "Platform Matrix Replace" -Tag "UnitTest", "replace" {
It "Should parse replacement syntax" -TestCases @(
@{ query = 'foo=bar/baz'; key = '^foo$'; value = '^bar$'; replace = 'baz' },
@{ query = 'foo=\/p:bar/\/p:baz'; key = '^foo$'; value = '^\/p:bar$'; replace = '/p:baz' },
Expand Down Expand Up @@ -450,7 +464,7 @@ Describe "Platform Matrix Replace" -Tag "replace" {
$matrixJson = @'
{
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json",
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json",
"testField": [ "test1", "test2" ]
}
}
Expand Down Expand Up @@ -550,7 +564,7 @@ Describe "Platform Matrix Replace" -Tag "replace" {
"replaceme": ""
},
"matrix": {
"$IMPORT": "./eng/common/scripts/job-matrix/tests/test-import-matrix.json",
"$IMPORT": "./matrix-generator/tests/test-import-matrix.json",
"replaceme": "replaceme"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Import-Module Pester

BeforeAll {
. $PSScriptRoot/../job-matrix-functions.ps1
. $PSScriptRoot/../../../common/scripts/job-matrix/job-matrix-functions.ps1

$matrixConfig = @"
{
Expand Down Expand Up @@ -48,7 +48,7 @@ BeforeAll {
"@
}

Describe "Matrix-Lookup" -Tag "lookup" {
Describe "Matrix-Lookup" -Tag "UnitTest", "lookup" {
It "Should navigate a 2d matrix: <row> <col>" -TestCases @(
@{ row = 0; col = 0; expected = 1 },
@{ row = 0; col = 1; expected = 2 },
Expand Down Expand Up @@ -148,7 +148,7 @@ Describe "Matrix-Lookup" -Tag "lookup" {
}
}

Describe "Matrix-Reverse-Lookup" -Tag "lookup" {
Describe "Matrix-Reverse-Lookup" -Tag "UnitTest", "lookup" {
It "Should lookup a 2d matrix index: <index>" -TestCases @(
@{ index = 0; expected = @(0,0) }
@{ index = 1; expected = @(0,1) }
Expand Down Expand Up @@ -251,7 +251,7 @@ Describe "Matrix-Reverse-Lookup" -Tag "lookup" {
}
}

Describe 'Matrix-Set' -Tag "set" {
Describe 'Matrix-Set' -Tag "UnitTest", "set" {
It "Should set a matrix element" -TestCases @(
@{ value = "set"; index = @(0,0,0,0); arrayIndex = 0 }
@{ value = "ones"; index = @(0,1,1,1); arrayIndex = 13 }
Expand All @@ -264,7 +264,7 @@ Describe 'Matrix-Set' -Tag "set" {
}
}

Describe "Platform Matrix Generation" -Tag "generate" {
Describe "Platform Matrix Generation" -Tag "UnitTest", "generate" {
BeforeEach {
$matrixConfigForGenerate = @"
{
Expand Down Expand Up @@ -373,7 +373,7 @@ Describe "Platform Matrix Generation" -Tag "generate" {
}
}

Describe "Config File Object Conversion" -Tag "convert" {
Describe "Config File Object Conversion" -Tag "UnitTest", "convert" {
BeforeEach {
$config = GetMatrixConfigFromJson $matrixConfig
}
Expand All @@ -390,7 +390,7 @@ Describe "Config File Object Conversion" -Tag "convert" {
}
}

Describe "Platform Matrix Post Transformation" -Tag "transform" {
Describe "Platform Matrix Post Transformation" -Tag "UnitTest", "transform" {
BeforeEach {
$config = GetMatrixConfigFromJson $matrixConfig
}
Expand Down Expand Up @@ -486,7 +486,7 @@ Describe "Platform Matrix Post Transformation" -Tag "transform" {
}
}

Describe "Platform Matrix Generation With Object Fields" -Tag "objectfields" {
Describe "Platform Matrix Generation With Object Fields" -Tag "UnitTest", "objectfields" {
BeforeEach {
$matrixConfigForObject = @"
{
Expand Down Expand Up @@ -572,7 +572,7 @@ Describe "Platform Matrix Generation With Object Fields" -Tag "objectfields" {
}
}

Describe "Platform Matrix Job and Display Names" -Tag "displaynames" {
Describe "Platform Matrix Job and Display Names" -Tag "UnitTest", "displaynames" {
BeforeEach {
$matrixConfigForGenerate = @"
{
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/job-matrix/job-matrix-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function ProcessImport([MatrixParameter[]]$matrix, [String]$selection, [Array]$n
}

if (!(Test-Path $importPath)) {
Write-Error "`$IMPORT path '$importPath' does not exist."
Write-Error "`$IMPORT path '$importPath' does not exist. Current dir: $(Get-Location)"
exit 1
}
$importedMatrixConfig = GetMatrixConfigFromFile (Get-Content -Raw $importPath)
Expand Down

0 comments on commit 3418b9a

Please sign in to comment.