Skip to content

Commit 6b18d74

Browse files
authored
Run MHSM tests weekly, disable attestation in Canary (Azure#35770)
* Only run Managed HSM weekly * Disable attestation testing in Canary * Replace matrix configuration Thanks to @benbp for help figuring this out. * Use correct key/value separator Mixing too much JSON and PowerShell. 🤦‍♂️ * Add condition to Microsoft.Web/sites resource
1 parent 3bd56e0 commit 6b18d74

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

sdk/keyvault/Azure.Security.KeyVault.Shared/tests/KeyVaultTestEnvironment.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public class KeyVaultTestEnvironment : TestEnvironment
7575
/// <summary>
7676
/// Gets the value of the "AZURE_KEYVAULT_ATTESTATION_URL" variable.
7777
/// </summary>
78-
public Uri AttestationUri => new(GetRecordedVariable("AZURE_KEYVAULT_ATTESTATION_URL"), UriKind.Absolute);
78+
public Uri AttestationUri => Uri.TryCreate(GetRecordedOptionalVariable("AZURE_KEYVAULT_ATTESTATION_URL"), UriKind.Absolute, out Uri attestationUri)
79+
? attestationUri
80+
: throw new IgnoreException("Required variable 'AZURE_KEYVAULT_ATTESTATION_URL' is not defined");
7981

8082
/// <summary>
8183
/// Throws an <see cref="IgnoreException"/> if <see cref="ManagedHsmUrl"/> is not defined.

sdk/keyvault/platform-matrix.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
2+
"matrix": {
3+
"$IMPORT": "eng/pipelines/templates/stages/platform-matrix.json",
4+
"ArmTemplateParameters": "@{ enableAttestation = $true }"
5+
},
26
"displayNames": {
3-
"@{ enableHsm = $true }": "HSM"
7+
"@{ enableAttestation = $true }": "",
8+
"@{ enableAttestation = $false }": "NoAttestation",
9+
"@{ enableHsm = $true }": "HSM"
410
},
511
"include": [
612
{

sdk/keyvault/test-resources.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
"description": "The location of the Managed HSM. By default, this is 'northcentralus'."
7070
}
7171
},
72+
"enableAttestation": {
73+
"type": "bool",
74+
"defaultValue": true,
75+
"metadata": {
76+
"description": "Whether to enable deployment of attestation resources. The default is true."
77+
}
78+
},
7279
"enableHsm": {
7380
"type": "bool",
7481
"defaultValue": false,
@@ -223,6 +230,7 @@
223230
"type": "Microsoft.Web/serverfarms",
224231
"apiVersion": "2020-12-01",
225232
"name": "[variables('attestationFarm')]",
233+
"condition": "[parameters('enableAttestation')]",
226234
"location": "[parameters('location')]",
227235
"kind": "linux",
228236
"sku": {
@@ -237,6 +245,7 @@
237245
"type": "Microsoft.Web/sites",
238246
"apiVersion": "2020-12-01",
239247
"name": "[variables('attestationSite')]",
248+
"condition": "[parameters('enableAttestation')]",
240249
"dependsOn": [
241250
"[resourceId('Microsoft.Web/serverfarms', variables('attestationFarm'))]"
242251
],
@@ -290,6 +299,7 @@
290299
},
291300
"AZURE_KEYVAULT_ATTESTATION_URL": {
292301
"type": "string",
302+
"condition": "[parameters('enableAttestation')]",
293303
"value": "[format('https://{0}/', reference(variables('attestationSite')).defaultHostName)]"
294304
}
295305
}

sdk/keyvault/tests.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,29 @@ extends:
1010
CloudConfig:
1111
Public:
1212
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
13+
${{ if not(contains(variables['Build.DefinitionName'], 'tests-weekly')) }}:
14+
MatrixFilters:
15+
- ArmTemplateParameters=^(?!.*enableHsm.*true)
1316
Canary:
1417
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
1518
Location: 'eastus2euap'
1619
# Managed HSM test resources are expensive and provisioning has not been reliable.
1720
# Given test coverage of non-canary regions we probably don't need to test in canary.
1821
MatrixFilters:
1922
- ArmTemplateParameters=^(?!.*enableHsm.*true)
23+
# Some resource providers required for attestation are not supported in canary.
24+
MatrixReplace:
25+
- 'ArmTemplateParameters=(.*)enableAttestation.*?\$true(.*)/$1enableAttestation \= $false$2'
2026
UsGov:
2127
SubscriptionConfiguration: $(sub-config-gov-test-resources)
2228
MatrixFilters:
2329
- ArmTemplateParameters=^(?!.*enableHsm.*true)
2430
China:
2531
SubscriptionConfiguration: $(sub-config-cn-test-resources)
2632
MatrixFilters:
27-
- ArmTemplateParameters=^(?!.*enableHsm.*true)
28-
AdditionalMatrixConfigs:
29-
- Name: keyvault_test_matrix_addons
33+
- ArmTemplateParameters=^(?!.*enableHsm.*true)
34+
MatrixConfigs:
35+
- Name: keyvault_test_matrix
3036
Path: sdk/keyvault/platform-matrix.json
3137
Selection: sparse
3238
GenerateVMJobs: true

0 commit comments

Comments
 (0)