Skip to content

Moving to swagger generated .net client #2098

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

Merged
merged 10 commits into from
Apr 19, 2016
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 @@ -58,7 +58,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Redis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Redis.1.2.0-preview\lib\net40\Microsoft.Azure.Management.Redis.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Redis.2.0.0-preview\lib\net45\Microsoft.Azure.Management.Redis.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand All @@ -69,9 +69,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5896.19355-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.HttpRecorder">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5896.19355-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.6.0-preview\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm">
<HintPath>..\..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
Expand All @@ -97,10 +97,18 @@
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.1.0\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.1.0\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.0.1-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.TestFramework.1.2.1-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.TestFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
Expand Down Expand Up @@ -152,6 +160,7 @@
<HintPath>..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Spatial">
<HintPath>..\..\..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -180,7 +189,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScenarioTests\RedisCacheTestsBase.cs" />
<Compile Include="ScenarioTests\RedisCacheController.cs" />
<Compile Include="ScenarioTests\RedisCacheTests.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Management.Insights;
using Microsoft.Azure.Management.Redis;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.ServiceManagemenet.Common;
using Microsoft.Azure.Subscriptions;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using LegacyTest = Microsoft.Azure.Test;
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
using TestUtilities = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities;

namespace Microsoft.Azure.Commands.RedisCache.Test.ScenarioTests
{
public class RedisCacheController
{
private EnvironmentSetupHelper helper;
private LegacyTest.CSMTestEnvironmentFactory csmTestFactory;

public ResourceManagementClient ResourceManagementClient { get; private set; }

public InsightsManagementClient InsightsManagementClient { get; private set; }

public RedisManagementClient RedisManagementClient { get; private set; }

public RedisCacheController()
{
helper = new EnvironmentSetupHelper();
}

public static RedisCacheController NewInstance
{
get
{
return new RedisCacheController();
}
}

private void SetupManagementClients(MockContext context)
{
RedisManagementClient = GetRedisManagementClient(context);
InsightsManagementClient = GetInsightsManagementClient();
ResourceManagementClient = GetResourceManagementClient();
helper.SetupManagementClients(ResourceManagementClient,
InsightsManagementClient,
RedisManagementClient
);
}

public void RunPowerShellTest(params string[] scripts)
{
var callingClassType = TestUtilities.GetCallingClass(2);
var mockName = TestUtilities.GetCurrentMethodName(2);

HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
using (MockContext context = MockContext.Start(callingClassType, mockName))
{
this.csmTestFactory = new LegacyTest.CSMTestEnvironmentFactory();
SetupManagementClients(context);

var callingClassName = callingClassType
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
.Last();
helper.SetupEnvironment(AzureModule.AzureResourceManager);
helper.SetupModules(AzureModule.AzureResourceManager,
"ScenarioTests\\" + callingClassName + ".ps1",
helper.RMProfileModule,
helper.RMResourceModule,
helper.GetRMModulePath(@"AzureRM.RedisCache.psd1"));

if (scripts != null)
{
helper.RunPowerShellTest(scripts);
}
}
}

private RedisManagementClient GetRedisManagementClient(MockContext context)
{
return context.GetServiceClient<RedisManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
}

private InsightsManagementClient GetInsightsManagementClient()
{
return LegacyTest.TestBase.GetServiceClient<InsightsManagementClient>(this.csmTestFactory);
}

private ResourceManagementClient GetResourceManagementClient()
{
return LegacyTest.TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,65 +15,66 @@
namespace Microsoft.Azure.Commands.RedisCache.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Microsoft.Azure.Test;
using Xunit;

public class RedisCacheTests : RedisCacheTestsBase
public class RedisCacheTests : RMTestBase
{
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRedisCache()
{
RunPowerShellTest("Test-RedisCache");
RedisCacheController.NewInstance.RunPowerShellTest("Test-RedisCache");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetNonExistingRedisCacheTest()
{
RunPowerShellTest("Test-SetNonExistingRedisCacheTest");
RedisCacheController.NewInstance.RunPowerShellTest("Test-SetNonExistingRedisCacheTest");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRedisCachePipeline()
{
RunPowerShellTest("Test-RedisCachePipeline");
RedisCacheController.NewInstance.RunPowerShellTest("Test-RedisCachePipeline");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetRedisCacheBugFixTest()
{
RunPowerShellTest("Test-SetRedisCacheBugFixTest");
RedisCacheController.NewInstance.RunPowerShellTest("Test-SetRedisCacheBugFixTest");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestMaxMemoryPolicyErrorCheck()
{
RunPowerShellTest("Test-MaxMemoryPolicyErrorCheck");
RedisCacheController.NewInstance.RunPowerShellTest("Test-MaxMemoryPolicyErrorCheck");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRedisCacheClustering()
{
RunPowerShellTest("Test-RedisCacheClustering");
RedisCacheController.NewInstance.RunPowerShellTest("Test-RedisCacheClustering");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetAzureRedisCacheDiagnostics()
{
RunPowerShellTest("Test-SetAzureRedisCacheDiagnostics");
RedisCacheController.NewInstance.RunPowerShellTest("Test-SetAzureRedisCacheDiagnostics");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveAzureRedisCacheDiagnostics()
{
RunPowerShellTest("Test-RemoveAzureRedisCacheDiagnostics");
RedisCacheController.NewInstance.RunPowerShellTest("Test-RemoveAzureRedisCacheDiagnostics");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Test-RedisCache
# In loop to check if cache exists
for ($i = 0; $i -le 60; $i++)
{
[Microsoft.WindowsAzure.Commands.Utilities.Common.TestMockSupport]::Delay(30000)
Start-TestSleep 30000
$cacheGet = Get-AzureRmRedisCache -ResourceGroupName $resourceGroupName -Name $cacheName
if ([string]::Compare("succeeded", $cacheGet[0].ProvisioningState, $True) -eq 0)
{
Expand Down Expand Up @@ -187,7 +187,7 @@ function Test-RedisCachePipeline
# In loop to check if cache exists
for ($i = 0; $i -le 60; $i++)
{
[Microsoft.WindowsAzure.Commands.Utilities.Common.TestMockSupport]::Delay(30000)
Start-TestSleep 30000
$cacheGet = Get-AzureRmRedisCache -ResourceGroupName $resourceGroupName -Name $cacheName
if ([string]::Compare("succeeded", $cacheGet[0].ProvisioningState, $True) -eq 0)
{
Expand Down Expand Up @@ -306,7 +306,7 @@ function Test-RedisCacheClustering
# In loop to check if cache exists
for ($i = 0; $i -le 60; $i++)
{
[Microsoft.WindowsAzure.Commands.Utilities.Common.TestMockSupport]::Delay(30000)
Start-TestSleep 30000
$cacheGet = Get-AzureRmRedisCache -ResourceGroupName $resourceGroupName -Name $cacheName
if ([string]::Compare("succeeded", $cacheGet[0].ProvisioningState, $True) -eq 0)
{
Expand Down Expand Up @@ -423,4 +423,16 @@ function Test-RemoveAzureRedisCacheDiagnostics

# Set Diagnostics
Remove-AzureRmRedisCacheDiagnostics -ResourceGroupName $resourceGroupName -Name $cacheName -Force
}

<#
.SYNOPSIS
Sleeps but only during recording.
#>
function Start-TestSleep($milliseconds)
{
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
{
Start-Sleep -Milliseconds $milliseconds
}
}

This file was deleted.

Loading