Skip to content
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5ae5194
Add generated SDK files from `autorest --csharp`
mboersma Dec 12, 2018
6dc0182
Removal of preview objects and replacment of of objects from 2018-03-…
Dec 12, 2018
ca74945
Skeleton VS solution, projects, and tests
Dec 14, 2018
d812113
Created compiling test harness
Dec 18, 2018
9ad8b8e
Test proj compiling, need JSON payloads for testing
Dec 18, 2018
9d1541f
Regenerate classes without deprecated ACS service endpoints
mboersma Dec 18, 2018
ce6bf5e
Orchestrator list and create tests complete:
Dec 21, 2018
81f63f8
Adding session records and passing tests
Dec 21, 2018
4dc6e41
Moving SPID to environment variable
Dec 21, 2018
dd4e7b4
Refactoring for more forthcoming tests
Dec 21, 2018
81f2a82
Completing tests for initial PR
Dec 31, 2018
806d3eb
Removal of service principal reference
Jan 4, 2019
95740f9
Repairing dependencies
Jan 7, 2019
75eed68
Projects rebuilt
Jan 8, 2019
44f3b83
Helper and test refactoring along with test cleanup
Jan 10, 2019
787f206
Fixing unit tests, refactoring utilities, and addressing required ser…
Jan 10, 2019
97fad77
Updte minor version of Media Services SDK in Management.Media/Microso…
Dec 12, 2018
74f551b
Add ignore scopes to props file for local builds (#5074)
weshaggard Dec 12, 2018
27d6315
Add generated SDK files from `autorest --csharp`
mboersma Dec 12, 2018
e685ba8
Removal of preview objects and replacment of of objects from 2018-03-…
Dec 12, 2018
d6c0777
Regenerate classes without deprecated ACS service endpoints
mboersma Dec 18, 2018
1fe592f
Recorded and passing tests
Jan 21, 2019
e4c0bcd
Updating test agentpool name
Jan 22, 2019
efc4d09
Proper code-gen completed
Jan 25, 2019
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
7 changes: 7 additions & 0 deletions src/SDKs/ContainerService/AzSdk.RP.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file-->
<PropertyGroup>
<AzureApiTag>ContainerService_2018-08-31;</AzureApiTag>
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" />
<PropertyGroup>
<PackageId>Microsoft.Azure.Management.ContainerService.Tests</PackageId>
<Version>1.0.0</Version>
<Description>ContainerService.Tests Class Library</Description>
<Authors>Microsoft Corporation</Authors>
<AssemblyName>Microsoft.Azure.Management.ContainerService.Tests</AssemblyName>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Management.ContainerService\Microsoft.Azure.Management.ContainerService.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="SessionRecords\**\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Linq;
using ContainerService.Tests;
using Microsoft.Azure.Management.ContainerService.Models;
using Microsoft.Azure.Management.Resources;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.Azure.Management.Resources.Models;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace Microsoft.Azure.Management.ContainerService.Tests
{
public static class ContainerServiceTestUtilities
{
internal const string DnsPrefix = "aksdotnetsdk";
internal const string ResourceGroupPrefix = "aks-dotnet-sdk-RG-";
internal const string AgentPoolProfileName = "aksdotnetagent";
internal const string VMSize = "Standard_A1";

public static ResourceManagementClient GetResourceManagementClient(MockContext context, RecordedDelegatingHandler handler)
{
handler.IsPassThrough = true;
ResourceManagementClient resourceManagementClient = context.GetServiceClient<ResourceManagementClient>(handlers: handler);
return resourceManagementClient;
}

internal static ContainerServiceClient GetContainerServiceManagementClient(MockContext context, RecordedDelegatingHandler handler)
{
handler.IsPassThrough = true;
ContainerServiceClient containerServiceClient = context.GetServiceClient<ContainerServiceClient>(handlers: handler);
return containerServiceClient;
}

public static string GetLocationFromProvider(this ResourceManagementClient resourceManagementClient)
{
return "westus2";
}

public static void TryRegisterResourceGroup(this ResourceManagementClient resourceManagementClient, string location, string resourceGroupName)
{
resourceManagementClient.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup(location));
}

public static string TryGetResourceGroup(this ResourceManagementClient resourceManagementClient, string location)
{
const string DefaultResourceGroupName = "AKSTests";

var resourceGroup = resourceManagementClient.ResourceGroups
.List().Where(group => string.IsNullOrWhiteSpace(location) || group.Location.Equals(location.Replace(" ", string.Empty), StringComparison.OrdinalIgnoreCase))
.FirstOrDefault(group => group.Name.Contains(DefaultResourceGroupName));

return resourceGroup != null
? resourceGroup.Name
: string.Empty;
}

/// <summary>
/// CreateManagedCluster creates an AKS managed cluster
/// </summary>
/// <param name="resourceManagementClient"></param>
/// <param name="containerServiceClient"></param>
/// <param name="location"></param>
/// <param name="clusterName"></param>
/// <param name="resourceGroupName"></param>
/// <returns></returns>
internal async static Task<ManagedCluster> CreateManagedCluster(
MockContext context,
ResourceManagementClient resourceManagementClient,
ContainerServiceClient containerServiceClient,
string location,
string clusterName,
string resourceGroupName)
{

TestEnvironment testEnvironment = TestEnvironmentFactory.GetTestEnvironment();
string authClientId = testEnvironment.ConnectionString.KeyValuePairs[ConnectionStringKeys.ServicePrincipalKey];
string authSecret = testEnvironment.ConnectionString.KeyValuePairs[ConnectionStringKeys.ServicePrincipalSecretKey];

var agentPoolProfiles = new List<ManagedClusterAgentPoolProfile>
{
new ManagedClusterAgentPoolProfile
{
Name = AgentPoolProfileName,
VmSize = VMSize,
Count = 1
}
};

ManagedCluster desiredManagedCluster = new ManagedCluster
{
DnsPrefix = DnsPrefix,
Location = location,
AgentPoolProfiles = agentPoolProfiles,
ServicePrincipalProfile = new ManagedClusterServicePrincipalProfile
{
ClientId = authClientId,
Secret = authSecret
}
};

var cluster = await containerServiceClient.ManagedClusters.CreateOrUpdateAsync(resourceGroupName, clusterName, desiredManagedCluster);

return cluster;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace ContainerService.Tests
{
public class RecordedDelegatingHandler : DelegatingHandler
{
private HttpResponseMessage _response;

public RecordedDelegatingHandler()
{
StatusCodeToReturn = HttpStatusCode.Created;
SubsequentStatusCodeToReturn = StatusCodeToReturn;
}

public RecordedDelegatingHandler(HttpResponseMessage response)
{
StatusCodeToReturn = HttpStatusCode.Created;
SubsequentStatusCodeToReturn = StatusCodeToReturn;
_response = response;
}

public HttpStatusCode StatusCodeToReturn { get; set; }

public HttpStatusCode SubsequentStatusCodeToReturn { get; set; }

public string Request { get; private set; }

public HttpRequestHeaders RequestHeaders { get; private set; }

public HttpContentHeaders ContentHeaders { get; private set; }

public HttpMethod Method { get; private set; }

public Uri Uri { get; private set; }

public bool IsPassThrough { get; set; }

private int counter;

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
counter++;
// Save request
if (request.Content == null)
{
Request = string.Empty;
}
else
{
Request = await request.Content.ReadAsStringAsync();
}
RequestHeaders = request.Headers;
if (request.Content != null)
{
ContentHeaders = request.Content.Headers;
}
Method = request.Method;
Uri = request.RequestUri;

// Prepare response
if (IsPassThrough)
{
return await base.SendAsync(request, cancellationToken);
}
else
{
if (_response != null && counter == 1)
{
return _response;
}
else
{
var statusCode = StatusCodeToReturn;
if (counter > 1)
statusCode = SubsequentStatusCodeToReturn;
HttpResponseMessage response = new HttpResponseMessage(statusCode);
response.Content = new StringContent("");
return response;
}
}
}
}
}
Loading