Skip to content

Commit 2001d50

Browse files
author
Maddie Clayton
authored
Merge pull request #5371 from deepaft/stack-compute-test-pr3
Fixing compute tests by rerecording against azurestack
2 parents 40a7511 + ac0dccf commit 2001d50

File tree

54 files changed

+77151
-67211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+77151
-67211
lines changed

src/ResourceManager/Compute/Stack/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 159 additions & 83 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Stack/Commands.Compute.Test/ScenarioTests/AddVhdTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Test-AddVhd
2929

3030
# Storage Account (SA)
3131
$stoname = 'sto' + $rgname;
32-
$stotype = 'Standard_GRS';
32+
$stotype = 'Standard_LRS';
3333
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
3434
$stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;
3535
$storageKey = Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname;

src/ResourceManager/Compute/Stack/Commands.Compute.Test/ScenarioTests/ComputeTestCommon.ps1

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15-
$PLACEHOLDER = "PLACEHOLDER1@"
16-
1715
<#
1816
.SYNOPSIS
1917
Gets valid resource name for compute test
@@ -90,6 +88,24 @@ function Get-ComputeTestMode
9088
return $testMode;
9189
}
9290

91+
# Get Storage Endpoint Suffix
92+
function Get-StorageEndpointSuffix
93+
{
94+
return $env:STORAGEENDPOINTSUFFIX;
95+
}
96+
97+
# Get Default Storage Endpoint Suffix
98+
function Get-DefaultStorageEndpointSuffix
99+
{
100+
$storageEndpointSuffix = Get-StorageEndpointSuffix;
101+
if ($storageEndpointSuffix -eq '' -or $storageEndpointSuffix -eq $null)
102+
{
103+
$storageEndpointSuffix = 'local.azurestack.external';
104+
}
105+
106+
return $storageEndpointSuffix;
107+
}
108+
93109
# Get Compute Test Location
94110
function Get-ComputeTestLocation
95111
{
@@ -115,10 +131,10 @@ function Create-VirtualMachine($rgname, $vmname, $loc)
115131
$rgname = if ([string]::IsNullOrEmpty($rgname)) { Get-ComputeTestResourceName } else { $rgname }
116132
$vmname = if ([string]::IsNullOrEmpty($vmname)) { 'vm' + $rgname } else { $vmname }
117133
$loc = if ([string]::IsNullOrEmpty($loc)) { Get-ComputeVMLocation } else { $loc }
118-
Write-Host $vmname
134+
$storageEndpointSuffix = Get-DefaultStorageEndpointSuffix;
119135

120136
# Common
121-
$g = New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
137+
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
122138

123139
# VM Profile & Hardware
124140
$vmsize = 'Standard_A2';
@@ -134,7 +150,7 @@ function Create-VirtualMachine($rgname, $vmname, $loc)
134150
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
135151
$pubipId = $pubip.Id;
136152
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
137-
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
153+
#$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
138154
$nicId = $nic.Id;
139155

140156
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
@@ -143,17 +159,17 @@ function Create-VirtualMachine($rgname, $vmname, $loc)
143159

144160
# Storage Account (SA)
145161
$stoname = 'sto' + $rgname;
146-
$stotype = 'Standard_GRS';
147-
$sa = New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
162+
$stotype = 'Standard_LRS';
163+
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
148164
Retry-IfException { $global:stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname; }
149165
$stokey = (Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname).Key1;
150166

151167
$osDiskName = 'osDisk';
152168
$osDiskCaching = 'ReadWrite';
153-
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
154-
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
155-
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
156-
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";
169+
$osDiskVhdUri = "https://$stoname.blob.$storageEndpointSuffix/test/os.vhd";
170+
$dataDiskVhdUri1 = "https://$stoname.blob.$storageEndpointSuffix/test/data1.vhd";
171+
$dataDiskVhdUri2 = "https://$stoname.blob.$storageEndpointSuffix/test/data2.vhd";
172+
$dataDiskVhdUri3 = "https://$stoname.blob.$storageEndpointSuffix/test/data3.vhd";
157173

158174
$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
159175

@@ -177,11 +193,11 @@ function Create-VirtualMachine($rgname, $vmname, $loc)
177193

178194
# OS & Image
179195
$user = "Foo12";
180-
$password = $PLACEHOLDER;
196+
$password = 'BaR@123' + $rgname;
181197
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
182198
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
183199
$computerName = 'test';
184-
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
200+
$vhdContainer = "https://$stoname.blob.$storageEndpointSuffix/test";
185201

186202
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent;
187203

@@ -199,7 +215,7 @@ function Create-VirtualMachine($rgname, $vmname, $loc)
199215
Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version;
200216

201217
# Virtual Machine
202-
$v = New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
218+
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
203219

204220
$vm = Get-AzureRmVM -ResourceGroupName $rgname -VMName $vmname
205221
return $vm
@@ -294,6 +310,7 @@ Gets default VM size string
294310
function Get-DefaultVMSize
295311
{
296312
param([string] $location = "westus")
313+
$location = Get-ComputeVMLocation;
297314

298315
$vmSizes = Get-AzureRmVMSize -Location $location | where { $_.NumberOfCores -ge 4 -and $_.MaxDataDiskCount -ge 8 };
299316

@@ -335,7 +352,7 @@ Gets default storage type string
335352
#>
336353
function Get-DefaultStorageType
337354
{
338-
return 'Standard_GRS';
355+
return 'Standard_LRS';
339356
}
340357

341358
<#
@@ -344,7 +361,8 @@ Gets default CRP Image
344361
#>
345362
function Get-DefaultCRPImage
346363
{
347-
param([string] $loc = "westus", [string] $query = '*Microsoft*Windows*Server*')
364+
param([string] $loc = "westus", [string] $query = '*Microsoft*Windows*Server')
365+
$loc = Get-ComputeVMLocation;
348366

349367
$result = (Get-AzureRmVMImagePublisher -Location $loc) | select -ExpandProperty PublisherName | where { $_ -like $query };
350368
if ($result.Count -eq 1)
@@ -356,7 +374,7 @@ function Get-DefaultCRPImage
356374
$defaultPublisher = $result[0];
357375
}
358376

359-
$result = (Get-AzureRmVMImageOffer -Location $loc -PublisherName $defaultPublisher) | select -ExpandProperty Offer | where { $_ -like '*Windows*' -and -not ($_ -like '*HUB') };
377+
$result = (Get-AzureRmVMImageOffer -Location $loc -PublisherName $defaultPublisher) | select -ExpandProperty Offer | where { $_ -like '*Windows*' };
360378
if ($result.Count -eq 1)
361379
{
362380
$defaultOffer = $result;
@@ -408,13 +426,13 @@ function Create-ComputeVMImageObject
408426
# Get Default CRP Windows Image Object Offline
409427
function Get-DefaultCRPWindowsImageOffline
410428
{
411-
return Create-ComputeVMImageObject 'MicrosoftWindowsServer' 'WindowsServer' '2008-R2-SP1' 'latest';
429+
return Create-ComputeVMImageObject 'MicrosoftWindowsServer' 'WindowsServer' '2012-R2-Datacenter' '1.0.0';
412430
}
413431

414432
# Get Default CRP Linux Image Object Offline
415433
function Get-DefaultCRPLinuxImageOffline
416434
{
417-
return Create-ComputeVMImageObject 'SUSE' 'openSUSE' '13.2' 'latest';
435+
return Create-ComputeVMImageObject 'Canonical' 'UbuntuServer' '14.04.3-LTS' '1.0.0';
418436
}
419437

420438
<#
@@ -424,7 +442,9 @@ Gets VMM Images
424442
function Get-MarketplaceImage
425443
{
426444
param([string] $location = "westus", [string] $pubFilter = '*', [string] $offerFilter = '*')
427-
445+
$location = Get-ComputeVMLocation;
446+
$pubFilter = 'MicrosoftWindowsServer'
447+
$offerFilter = 'WindowsServer'
428448
$imgs = Get-AzureRmVMImagePublisher -Location $location | where { $_.PublisherName -like $pubFilter } | Get-AzureRmVMImageOffer | where { $_.Offer -like $offerFilter } | Get-AzureRmVMImageSku | Get-AzureRmVMImage | Get-AzureRmVMImage | where { $_.PurchasePlan -ne $null };
429449

430450
return $imgs;
@@ -437,6 +457,7 @@ Gets default VM config object
437457
function Get-DefaultVMConfig
438458
{
439459
param([string] $location = "westus")
460+
$location = Get-ComputeVMLocation;
440461

441462
# VM Profile & Hardware
442463
$vmsize = Get-DefaultVMSize $location;
@@ -480,8 +501,9 @@ function Assert-OutputContains
480501
function Get-SasUri
481502
{
482503
param ([string] $storageAccount, [string] $storageKey, [string] $container, [string] $file, [TimeSpan] $duration, [Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions] $type)
504+
$storageEndpointSuffix = Get-DefaultStorageEndpointSuffix;
483505

484-
$uri = [string]::Format("https://{0}.blob.core.windows.net/{1}/{2}", $storageAccount, $container, $file);
506+
$uri = [string]::Format("https://{0}.blob.$storageEndpointSuffix/{1}/{2}", $storageAccount, $container, $file);
485507

486508
$destUri = New-Object -TypeName System.Uri($uri);
487509
$cred = New-Object -TypeName Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($storageAccount, $storageKey);
@@ -576,8 +598,3 @@ function Get-SubscriptionIdFromResourceGroup
576598
$last = $rgid.IndexOf('/', $first + 1);
577599
return $rgid.Substring($first + 1, $last - $first - 1);
578600
}
579-
580-
function Get-ComputeVmssLocation
581-
{
582-
Get-ResourceProviderLocation "Microsoft.Compute/virtualMachineScaleSets"
583-
}

src/ResourceManager/Compute/Stack/Commands.Compute.Test/ScenarioTests/DiagnosticsExtensionTests.cs

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -12,134 +12,18 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.Compute.Common;
1615
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17-
using System;
18-
using System.IO;
19-
using System.Reflection;
2016
using Xunit;
2117

2218
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
2319
{
2420
public class DiagnosticsExtensionTests
2521
{
26-
private static string configDirPath = Path.Combine(Path.GetDirectoryName(Uri.UnescapeDataString(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath)), "ConfigFiles");
27-
28-
private static string GetConfigFilePath(string filename)
29-
{
30-
return Path.Combine(configDirPath, filename);
31-
}
32-
33-
public DiagnosticsExtensionTests(Xunit.Abstractions.ITestOutputHelper output)
34-
{
35-
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
36-
}
37-
38-
[Fact]
39-
[Trait(Category.AcceptanceType, Category.CheckIn)]
40-
public void TestDiagnosticsExtensionBasic()
41-
{
42-
ComputeTestController.NewInstance.RunPsTest("Test-DiagnosticsExtensionBasic");
43-
}
44-
45-
[Fact]
46-
[Trait(Category.AcceptanceType, Category.CheckIn)]
47-
public void TestDiagnosticsExtensionSepcifyStorageAccountName()
48-
{
49-
ComputeTestController.NewInstance.RunPsTest("Test-DiagnosticsExtensionSepcifyStorageAccountName");
50-
}
51-
5222
[Fact]
5323
[Trait(Category.AcceptanceType, Category.CheckIn)]
5424
public void TestDiagnosticsExtensionCantListSepcifyStorageAccountKey()
5525
{
5626
ComputeTestController.NewInstance.RunPsTest("Test-DiagnosticsExtensionCantListSepcifyStorageAccountKey");
5727
}
58-
59-
[Fact]
60-
[Trait(Category.AcceptanceType, Category.CheckIn)]
61-
public void TestDiagnosticsExtensionSupportJsonConfig()
62-
{
63-
ComputeTestController.NewInstance.RunPsTest("Test-DiagnosticsExtensionSupportJsonConfig");
64-
}
65-
66-
[Fact]
67-
[Trait(Category.AcceptanceType, Category.CheckIn)]
68-
public void TestVmssDiagnosticsExtension()
69-
{
70-
ComputeTestController.NewInstance.RunPsTest("Test-VmssDiagnosticsExtension");
71-
}
72-
73-
[Fact]
74-
[Trait(Category.AcceptanceType, Category.CheckIn)]
75-
public void TestDiagnosticsConfigBuilderMismatchAccountNames()
76-
{
77-
string pubJsonConfigPath = GetConfigFilePath("DiagnosticsExtensionPublicConfigWithStorageType.json");
78-
string privJsonConfigPath = GetConfigFilePath("DiagnosticsExtensionprivateConfigWithWrongName.json");
79-
80-
var exception = Record.Exception(() => DiagnosticsHelper.GetConfigurationsFromFiles(pubJsonConfigPath, privJsonConfigPath, "a-resouce-id", null, null));
81-
Assert.IsType(typeof(ArgumentException), exception);
82-
83-
84-
string[] configs = new[] {
85-
GetConfigFilePath("DiagnosticsExtensionConfigWithWrongName.json"),
86-
GetConfigFilePath("DiagnosticsExtensionConfigWithWrongName.xml")
87-
};
88-
89-
foreach (var configPath in configs)
90-
{
91-
exception = Record.Exception(() => DiagnosticsHelper.GetPrivateDiagnosticsConfiguration(configPath, "wrong-name", "a-key", "an-endpoint"));
92-
Assert.IsType(typeof(ArgumentException), exception);
93-
}
94-
}
95-
96-
[Fact]
97-
[Trait(Category.AcceptanceType, Category.CheckIn)]
98-
public void TestDiagnosticsConfigBuilderWithSasToken()
99-
{
100-
string pubJsonConfigPath = GetConfigFilePath("DiagnosticsExtensionPublicConfigWithStorageType.json");
101-
string privJsonConfigPath = GetConfigFilePath("DiagnosticsExtensionprivateConfigWithSasToken.json");
102-
103-
string sasTokenValue = "This-is-a-sas-token";
104-
var result = DiagnosticsHelper.GetConfigurationsFromFiles(pubJsonConfigPath, privJsonConfigPath, "a-resource-id", null, null);
105-
Assert.Equal<string>(sasTokenValue, result.Item2["storageAccountSasToken"] as string);
106-
107-
string[] configs = new[] {
108-
GetConfigFilePath("DiagnosticsExtensionConfigWithSasToken.json"),
109-
GetConfigFilePath("DiagnosticsExtensionConfigWithSasToken.xml")
110-
};
111-
112-
foreach (var configPath in configs)
113-
{
114-
var privateSettings = DiagnosticsHelper.GetPrivateDiagnosticsConfiguration(configPath, "[StorageAccountName]", "a-key", "an-endpoint");
115-
Assert.Null(privateSettings["storageAccountKey"]);
116-
Assert.NotNull(privateSettings["storageAccountEndPoint"]);
117-
Assert.Equal<string>(sasTokenValue, privateSettings["storageAccountSasToken"] as string);
118-
}
119-
}
120-
121-
[Fact]
122-
[Trait(Category.AcceptanceType, Category.CheckIn)]
123-
public void TestDiagnosticsConfigBuilderWithStorageType()
124-
{
125-
string pubJsonConfigPath = GetConfigFilePath("DiagnosticsExtensionPublicConfigWithStorageType.json");
126-
string privJsonConfigPath = GetConfigFilePath("DiagnosticsExtensionprivateConfigWithSasToken.json");
127-
128-
string storageTypeValue = "TableAndBlob";
129-
130-
var result = DiagnosticsHelper.GetConfigurationsFromFiles(pubJsonConfigPath, privJsonConfigPath, "a-resource-id", null, null);
131-
Assert.Equal<string>(storageTypeValue, result.Item1["StorageType"] as string);
132-
133-
string[] configs = new[] {
134-
GetConfigFilePath("DiagnosticsExtensionConfigWithStorageType.json"),
135-
GetConfigFilePath("DiagnosticsExtensionConfigWithStorageType.xml")
136-
};
137-
138-
foreach (var configPath in configs)
139-
{
140-
var publicSettings = DiagnosticsHelper.GetPublicDiagnosticsConfigurationFromFile(configPath, "[StorageAccountName]", "dummy", null);
141-
Assert.Equal<string>(storageTypeValue, publicSettings["StorageType"] as string);
142-
}
143-
}
14428
}
14529
}

0 commit comments

Comments
 (0)