Skip to content

Commit e536d9f

Browse files
committed
Fix compute runner tests
1 parent eefe2ec commit e536d9f

File tree

3 files changed

+27
-47
lines changed

3 files changed

+27
-47
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/RunnerTests.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,6 @@ public RunnerTests(Xunit.Abstractions.ITestOutputHelper output)
1717
[Fact]
1818
public void ExecuteRunnerTests()
1919
{
20-
var mode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
21-
var csmAuth = Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION");
22-
23-
if (mode == null || csmAuth == null || mode.ToLower() != "record")
24-
{
25-
return;
26-
}
27-
28-
Assert.False(string.IsNullOrEmpty(csmAuth));
29-
Assert.True(csmAuth.Contains("AADTenant"));
30-
31-
var envDictionary = TestUtilities.ParseConnectionString(csmAuth);
32-
var testEnv = new TestEnvironment(envDictionary);
33-
Assert.NotNull(testEnv.Tenant);
34-
Assert.NotNull(testEnv.SubscriptionId);
35-
Assert.NotNull(testEnv.ClientId);
36-
Assert.True(envDictionary.ContainsKey("ApplicationSecret"));
37-
38-
var authenticationContext = new AuthenticationContext("https://login.windows.net/" + testEnv.Tenant);
39-
var credential = new ClientCredential(testEnv.ClientId, envDictionary["ApplicationSecret"]);
40-
41-
var result = authenticationContext.AcquireToken("https://management.core.windows.net/", clientCredential: credential);
42-
43-
Assert.NotNull(result.AccessToken);
44-
envDictionary["RawToken"] = result.AccessToken;
45-
46-
FixCSMAuthEnvVariable(envDictionary);
47-
48-
Console.WriteLine(Environment.GetEnvironmentVariable("TEST_CSM_ORGID_AUTHENTICATION"));
49-
5020
var testFile = File.ReadAllLines("ScenarioTests\\RunnerTests.csv");
5121
foreach (var line in testFile)
5222
{

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VMDynamicTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
1919
{
2020
public partial class VMDynamicTests
2121
{
22+
public VMDynamicTests() { }
23+
2224
public VMDynamicTests(Xunit.Abstractions.ITestOutputHelper output)
2325
{
2426
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VMDynamicTests.ps1

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,26 @@
1414

1515
function get_all_vm_locations
1616
{
17-
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
18-
{
19-
$namespace = "Microsoft.Compute"
20-
$type = "virtualMachines"
21-
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
17+
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
18+
{
19+
$namespace = "Microsoft.Compute"
20+
$type = "virtualMachines"
21+
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
2222

23-
if ($location -eq $null)
24-
{
25-
$st = Write-Verbose 'Getting all Azure location - End';
26-
return @("West US", "East US")
27-
} else
28-
{
29-
$st = Write-Verbose 'Getting all Azure location - End';
30-
return $location.Locations
31-
}
32-
}
23+
if ($location -eq $null)
24+
{
25+
$st = Write-Verbose 'Getting all Azure location - End';
26+
return @("West US", "East US")
27+
}
28+
else
29+
{
30+
$st = Write-Verbose 'Getting all Azure location - End';
31+
return $location.Locations
32+
}
33+
}
3334

3435
$st = Write-Verbose 'Getting all Azure location - End';
35-
return @("West US", "East US")
36+
return @("West US", "East US")
3637
}
3738

3839
function get_all_standard_vm_sizes
@@ -336,7 +337,14 @@ function Run-VMDynamicTests
336337
$st = (func_create_and_setup_nic_ids $random_seed) | Out-File -Encoding ASCII -Append -FilePath $generated_file_name -Force;
337338
$st = $func_create_and_setup_vm_config_object | Out-File -Encoding ASCII -Append -FilePath $generated_file_name -Force;
338339

339-
$loc_name_str = $locations[$i % $locations.Count];
340+
if ($locations.Count -eq 1)
341+
{
342+
$loc_name_str = $locations
343+
}
344+
else
345+
{
346+
$loc_name_str = $locations[$i % $locations.Count];
347+
}
340348

341349
if ($target_location -ne $null -and $target_location -ne '')
342350
{

0 commit comments

Comments
 (0)