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

Enable validation in CI #43957

Merged
merged 12 commits into from
May 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/provisioning/Azure.Provisioning.AppConfiguration",
"Tag": "net/provisioning/Azure.Provisioning.AppConfiguration_3c7936e93e"
"Tag": "net/provisioning/Azure.Provisioning.AppConfiguration_55fde9399d"
}
2 changes: 1 addition & 1 deletion sdk/provisioning/Azure.Provisioning.KeyVault/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/provisioning/Azure.Provisioning.KeyVault",
"Tag": "net/provisioning/Azure.Provisioning.KeyVault_cb7a21a215"
"Tag": "net/provisioning/Azure.Provisioning.KeyVault_7cbe7ccb75"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ param location string = resourceGroup().location
param enableSoftDelete bool = true


resource keyVault_7LloDNJK5 'Microsoft.KeyVault/vaults@2022-07-01' = {
resource keyVault_NEuaN7OeP 'Microsoft.KeyVault/vaults@2022-07-01' = {
name: toLower(take('kv${uniqueString(resourceGroup().id)}', 24))
location: location
properties: {
tenantId: '00000000-0000-0000-0000-000000000000'
tenantId: tenant().tenantId
sku: {
family: 'A'
name: 'standard'
Expand All @@ -21,4 +21,4 @@ resource keyVault_7LloDNJK5 'Microsoft.KeyVault/vaults@2022-07-01' = {
}
}

output VAULT_URI string = keyVault_7LloDNJK5.properties.vaultUri
output VAULT_URI string = keyVault_NEuaN7OeP.properties.vaultUri
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ targetScope = 'resourceGroup'
param location string = resourceGroup().location


resource keyVault_7LloDNJK5 'Microsoft.KeyVault/vaults@2022-07-01' = {
resource keyVault_NEuaN7OeP 'Microsoft.KeyVault/vaults@2022-07-01' = {
name: toLower(take('kv${uniqueString(resourceGroup().id)}', 24))
location: location
properties: {
tenantId: '00000000-0000-0000-0000-000000000000'
tenantId: tenant().tenantId
sku: {
family: 'A'
name: 'standard'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ param location string = resourceGroup().location
param enableSoftDelete bool = true


resource keyVault_7LloDNJK5 'Microsoft.KeyVault/vaults@2022-07-01' = {
resource keyVault_NEuaN7OeP 'Microsoft.KeyVault/vaults@2022-07-01' = {
name: toLower(take('kv${uniqueString(resourceGroup().id)}', 24))
location: location
properties: {
tenantId: '00000000-0000-0000-0000-000000000000'
tenantId: tenant().tenantId
sku: {
family: 'A'
name: 'standard'
Expand Down
2 changes: 1 addition & 1 deletion sdk/provisioning/Azure.Provisioning.Search/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/provisioning/Azure.Provisioning.Search",
"Tag": "net/provisioning/Azure.Provisioning.Search_0f74a99f10"
"Tag": "net/provisioning/Azure.Provisioning.Search_3d009da219"
}
2 changes: 1 addition & 1 deletion sdk/provisioning/Azure.Provisioning.SignalR/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/provisioning/Azure.Provisioning.SignalR",
"Tag": ""
"Tag": "net/provisioning/Azure.Provisioning.SignalR_a88305db5e"
}
2 changes: 1 addition & 1 deletion sdk/provisioning/Azure.Provisioning.Storage/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/provisioning/Azure.Provisioning.Storage",
"Tag": "net/provisioning/Azure.Provisioning.Storage_bcaeab9180"
"Tag": "net/provisioning/Azure.Provisioning.Storage_13a772dbd6"
}
49 changes: 16 additions & 33 deletions sdk/provisioning/Azure.Provisioning/tests/ProvisioningTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,24 @@ namespace Azure.Provisioning.Tests
[AsyncOnly]
public class ProvisioningTestBase : ManagementRecordedTestBase<ProvisioningTestEnvironment>
{
private DateTime _testStartTime;
protected override DateTime TestStartTime => _testStartTime;

public ProvisioningTestBase(bool async) : base(async)
{
// Ignore the version of the AZ CLI used to generate the ARM template as this will differ based on the environment
JsonPathSanitizers.Add("$.._generator.version");
JsonPathSanitizers.Add("$.._generator.templateHash");
}

protected async Task ValidateBicepAsync(BinaryData? parameters = null, bool interactiveMode = false)
[SetUp]
public void Setup()
{
if (CoreTestEnvironment.GlobalIsRunningInCI)
{
return;
}
_testStartTime = base.TestStartTime;
}

protected async Task ValidateBicepAsync(BinaryData? parameters = null, bool interactiveMode = false)
{
var testPath = GetOutputPath();
var client = GetArmClient();
ResourceGroupResource? rg = null;
Expand All @@ -44,7 +51,7 @@ protected async Task ValidateBicepAsync(BinaryData? parameters = null, bool inte
"eng",
"scripts",
$"Validate-Bicep.ps1 {bicepPath}");
var processInfo = new ProcessStartInfo("pwsh.exe", args)
var processInfo = new ProcessStartInfo("pwsh", args)
{
UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true,
};
Expand All @@ -59,6 +66,9 @@ protected async Task ValidateBicepAsync(BinaryData? parameters = null, bool inte
}
}

// exclude the time taken to validate the bicep file
_testStartTime = DateTime.UtcNow;

ResourceIdentifier scope;
if (interactiveMode)
{
Expand Down Expand Up @@ -99,33 +109,6 @@ protected async Task ValidateBicepAsync(BinaryData? parameters = null, bool inte
}
}

private static string GetGitRoot()
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "git",
Arguments = "rev-parse --show-toplevel",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};

using (Process process = Process.Start(startInfo)!)
{
process.WaitForExit();

if (process.ExitCode == 0)
{
string gitRoot = process.StandardOutput.ReadToEnd().Trim();
return gitRoot;
}
else
{
throw new Exception("Failed to get the root of the Git repository.");
}
}
}

protected string GetOutputPath()
{
var output = Path.Combine(CoreTestEnvironment.GetSourcePath(GetType().Assembly), "Infrastructure",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ public static SearchServiceData SearchServiceData(ResourceIdentifier id = null,
systemData,
tags,
location,
skuName.ToString(),
// ternary operator must use a nullable instance of the type to avoid triggering the implicit cast on the null
skuName.HasValue ? new SearchServiceSkuName?(skuName.Value.ToSerialString()) : null,
identity,
replicaCount,
partitionCount,
hostingMode,
publicNetworkAccess.ToString(),
// ternary operator must use a nullable instance of the type to avoid triggering the implicit cast on the null
publicNetworkAccess.HasValue ? new SearchServicePublicInternetAccess?(publicNetworkAccess.Value.ToSerialString()) : null,
status,
statusDetails,
provisioningState,
Expand Down