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

AzureRT S54 PR #1 - Compute Test Fix #1416

Merged
merged 18 commits into from
Sep 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime">
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.Rest.ClientRuntime.1.2.0\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.1.3.0\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.Rest.ClientRuntime.Azure.1.0.20\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.Rest.ClientRuntime.Azure.1.0.21\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,11 @@ public static HttpRecorderMode GetCurrentMode()
return mode;
}

public static Records Records
{
get { return records; }
set { records = value; }
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<description>Test utilities for xunit test suites for AutoRest generated Azure clients</description>
<copyright>Copyright 2015</copyright>
<dependencies>
<dependency id="Microsoft.Rest.ClientRuntime.Azure" version="[1.0.20,2.0)" />
<dependency id="Microsoft.Rest.ClientRuntime.Azure" version="[1.0.21,2.0)" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.18.206251556" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime" version="1.2.0" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure" version="1.0.20" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime" version="1.3.0" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure" version="1.0.21" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="0.9.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime">
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.Rest.ClientRuntime.1.2.0\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.Rest.ClientRuntime.1.3.0\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.Rest.ClientRuntime.Azure.1.0.20\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<HintPath>$(LibraryNugetPackageFolder)\Microsoft.Rest.ClientRuntime.Azure.1.0.21\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void TestVMExtensionOperations()
using (MockContext context = MockContext.Start())
{
EnsureClientsInitialized(context);
//VMNetworkInterfaceTests.FixRecords();

ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true);
// Create resource group
Expand Down Expand Up @@ -88,7 +89,7 @@ public void TestVMExtensionOperations()
// Validate the extension in the VM info
var getVMResponse = m_CrpClient.VirtualMachines.Get(rgName, vm.Name);
// TODO AutoRest: Recording Passed, but these assertions failed in Playback mode
// ValidateVMExtension(vmExtension, getVMResponse.Resources.FirstOrDefault());
ValidateVMExtension(vmExtension, getVMResponse.Resources.FirstOrDefault());

// Validate the extension instance view in the VM instance-view
var getVMWithInstanceViewResponse = m_CrpClient.VirtualMachines.Get(rgName, vm.Name, "instanceView");
Expand Down Expand Up @@ -119,10 +120,10 @@ private void ValidateVMExtension(VirtualMachineExtension vmExtExpected, VirtualM
private void ValidateVMExtensionInstanceView(VirtualMachineExtensionInstanceView vmExtInstanceView)
{
Assert.NotNull(vmExtInstanceView);
//Assert.NotNull(vmExtInstanceView.Statuses[0].DisplayStatus);
//Assert.NotNull(vmExtInstanceView.Statuses[0].Code);
//Assert.NotNull(vmExtInstanceView.Statuses[0].Level);
//Assert.NotNull(vmExtInstanceView.Statuses[0].Message);
Assert.NotNull(vmExtInstanceView.Statuses[0].DisplayStatus);
Assert.NotNull(vmExtInstanceView.Statuses[0].Code);
Assert.NotNull(vmExtInstanceView.Statuses[0].Level);
Assert.NotNull(vmExtInstanceView.Statuses[0].Message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.
//

using System.Collections;
using System.Collections.Generic;
using System.Net;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
Expand All @@ -22,16 +24,55 @@
using Microsoft.Azure.Management.Resources.Models;
using Xunit;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework.HttpRecorder;

namespace Compute.Tests
{
public class VMNetworkInterfaceTests : VMTestBase
{

public static void FixRecords()
{
if (HttpMockServer.Mode == HttpRecorderMode.Playback)
{
var records = new Dictionary<string, Queue<RecordEntry>>();
foreach (var record in HttpMockServer.Records.GetAllEntities())
{
var key = HttpMockServer.Matcher.GetMatchingKey(record);
if (!records.ContainsKey(key))
{
records[key] = new Queue<RecordEntry>();
}

records[key].Enqueue(record);
}

var newRecords = new Dictionary<string, Queue<RecordEntry>>();
foreach (var key in records.Keys)
{
Queue<RecordEntry> newRecord = new Queue<RecordEntry>();
var queue = records[key];

while (queue.Count > 0)
{
newRecord.Enqueue(queue.Dequeue());
//queue.Dequeue();
//queue.Dequeue();
//queue.Dequeue();
}

newRecords[key] = newRecord;
}
HttpMockServer.Records = new Records( newRecords, HttpMockServer.Matcher);
}
}

[Fact]
public void TestNicVirtualMachineReference()
{
using (MockContext context = MockContext.Start())
{
//FixRecords();
EnsureClientsInitialized(context);

ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true);
Expand All @@ -40,7 +81,6 @@ public void TestNicVirtualMachineReference()
string asName = TestUtilities.GenerateName("as");
string storageAccountName = TestUtilities.GenerateName(TestPrefix);
VirtualMachine inputVM;

try
{
// Create the resource Group, it might have been already created during StorageAccount creation.
Expand Down Expand Up @@ -78,9 +118,9 @@ public void TestNicVirtualMachineReference()

var getNicResponse = m_NrpClient.NetworkInterfaces.Get(rgName, nicResponse.Name);
// TODO AutoRest: Recording Passed, but these assertions failed in Playback mode
// Assert.NotNull(getNicResponse.MacAddress);
// Assert.NotNull(getNicResponse.Primary);
// Assert.True(getNicResponse.Primary != null && getNicResponse.Primary.Value);
Assert.NotNull(getNicResponse.MacAddress);
Assert.NotNull(getNicResponse.Primary);
Assert.True(getNicResponse.Primary != null && getNicResponse.Primary.Value);
}
finally
{
Expand All @@ -95,6 +135,7 @@ public void TestMultiNicVirtualMachineReference()
{
using (MockContext context = MockContext.Start())
{
//FixRecords();
EnsureClientsInitialized(context);

ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true);
Expand Down Expand Up @@ -149,15 +190,15 @@ public void TestMultiNicVirtualMachineReference()

var getNicResponse1 = m_NrpClient.NetworkInterfaces.Get(rgName, nicResponse1.Name);
// TODO AutoRest: Recording Passed, but these assertions failed in Playback mode
// Assert.NotNull(getNicResponse1.MacAddress);
// Assert.NotNull(getNicResponse1.Primary);
// Assert.True(getNicResponse1.Primary != null && !getNicResponse1.Primary.Value);
Assert.NotNull(getNicResponse1.MacAddress);
Assert.NotNull(getNicResponse1.Primary);
Assert.True(getNicResponse1.Primary != null && !getNicResponse1.Primary.Value);

var getNicResponse2 = m_NrpClient.NetworkInterfaces.Get(rgName, nicResponse2.Name);
// TODO AutoRest: Recording Passed, but these assertions failed in Playback mode
// Assert.NotNull(getNicResponse2.MacAddress);
// Assert.NotNull(getNicResponse2.Primary);
// Assert.True(getNicResponse2.Primary != null && getNicResponse2.Primary.Value);
Assert.NotNull(getNicResponse2.MacAddress);
Assert.NotNull(getNicResponse2.Primary);
Assert.True(getNicResponse2.Primary != null && getNicResponse2.Primary.Value);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public void TestVMOperations()
string storageAccountName = TestUtilities.GenerateName(TestPrefix);
VirtualMachine inputVM1;

bool passed = false;
try
{
// Create Storage Account, so that both the VMs can share it
Expand All @@ -78,23 +77,18 @@ public void TestVMOperations()

var captureResponse = m_CrpClient.VirtualMachines.Capture(rg1Name, vm1.Name, captureParams);

// [TODO] AutoRest Problem: captureResponse is null
// Assert.NotNull(captureResponse.Properties.Output);
// string outputAsString = captureResponse.Properties.Output.ToString();
// Assert.Equal('{', outputAsString[0]);
// Assert.True(outputAsString.Contains(captureParams.DestinationContainerName.ToLowerInvariant()));
// Assert.True(outputAsString.ToLowerInvariant().Contains(captureParams.VhdPrefix.ToLowerInvariant()));

passed = true;
Assert.NotNull(captureResponse.Properties.Output);
string outputAsString = captureResponse.Properties.Output.ToString();
Assert.Equal('{', outputAsString[0]);
Assert.True(outputAsString.Contains(captureParams.DestinationContainerName.ToLowerInvariant()));
Assert.True(outputAsString.ToLowerInvariant().Contains(captureParams.VhdPrefix.ToLowerInvariant()));
}
finally
{
// Cleanup the created resources. But don't wait since it takes too long, and it's not the purpose
// of the test to cover deletion. CSM does persistent retrying over all RG resources.
m_ResourcesClient.ResourceGroups.Delete(rg1Name);
}

Assert.True(passed);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ protected void EnsureClientsInitialized(MockContext context)
{
if (!m_initialized)
{
var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK };

m_ResourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(context, handler);
m_CrpClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, handler);
m_SrpClient = ComputeManagementTestUtilities.GetStorageManagementClient(context, handler);
m_NrpClient = ComputeManagementTestUtilities.GetNetworkResourceProviderClient(context, handler);
m_ResourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
m_CrpClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
m_SrpClient = ComputeManagementTestUtilities.GetStorageManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
m_NrpClient = ComputeManagementTestUtilities.GetNetworkResourceProviderClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });

m_subId = m_CrpClient.SubscriptionId;
m_location = ComputeManagementTestUtilities.DefaultLocation;
Expand Down
Loading