Skip to content

Commit b2c0815

Browse files
committed
Added UsageAggregates module and test to netcore. Updated ApiManagement to use correct Hyak management library version. Re-enabled ApiManagement tests after having the management library constructed properly. Fixed Automation netcore test controller to construct the Hyak library properly. Updated DataFactories Hyak version.
1 parent 2c4b15d commit b2c0815

20 files changed

+90
-209
lines changed

Azure.PowerShell.Netcore.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.AnalysisServices.D
135135
EndProject
136136
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Storage.Netcore", "src\Storage\Commands.Storage\Commands.Storage.Netcore.csproj", "{4F18000A-0329-4450-ADC8-8AA1C04A4666}"
137137
EndProject
138+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.UsageAggregates.Netcore", "src\ResourceManager\UsageAggregates\Commands.UsageAggregates\Commands.UsageAggregates.Netcore.csproj", "{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}"
139+
EndProject
138140
Global
139141
GlobalSection(SolutionConfigurationPlatforms) = preSolution
140142
Debug|Any CPU = Debug|Any CPU
@@ -937,6 +939,18 @@ Global
937939
{4F18000A-0329-4450-ADC8-8AA1C04A4666}.Release|x64.Build.0 = Release|Any CPU
938940
{4F18000A-0329-4450-ADC8-8AA1C04A4666}.Release|x86.ActiveCfg = Release|Any CPU
939941
{4F18000A-0329-4450-ADC8-8AA1C04A4666}.Release|x86.Build.0 = Release|Any CPU
942+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
943+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Debug|Any CPU.Build.0 = Debug|Any CPU
944+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Debug|x64.ActiveCfg = Debug|Any CPU
945+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Debug|x64.Build.0 = Debug|Any CPU
946+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Debug|x86.ActiveCfg = Debug|Any CPU
947+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Debug|x86.Build.0 = Debug|Any CPU
948+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Release|Any CPU.ActiveCfg = Release|Any CPU
949+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Release|Any CPU.Build.0 = Release|Any CPU
950+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Release|x64.ActiveCfg = Release|Any CPU
951+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Release|x64.Build.0 = Release|Any CPU
952+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Release|x86.ActiveCfg = Release|Any CPU
953+
{AC30CFA4-0EC7-4303-ABC1-A60DFCA44B74}.Release|x86.Build.0 = Release|Any CPU
940954
EndGlobalSection
941955
GlobalSection(SolutionProperties) = preSolution
942956
HideSolutionNode = FALSE

src/Azure.PowerShell.Netcore.Test.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.Automation.Test.Ne
4747
EndProject
4848
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.ApiManagement.Test.Netcore", "ResourceManager\ApiManagement\Commands.ApiManagement.Test\Commands.ApiManagement.Test.Netcore.csproj", "{0BE9F3AF-AF6D-4595-B716-46CA53DEA995}"
4949
EndProject
50+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commands.UsageAggregates.Test.Netcore", "ResourceManager\UsageAggregates\Commands.UsageAggregates.Test\Commands.UsageAggregates.Test.Netcore.csproj", "{D95226AC-55D6-4152-9214-25F8BEB6E7F5}"
51+
EndProject
5052
Global
5153
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5254
Debug|Any CPU = Debug|Any CPU
@@ -321,6 +323,18 @@ Global
321323
{0BE9F3AF-AF6D-4595-B716-46CA53DEA995}.Release|x64.Build.0 = Release|Any CPU
322324
{0BE9F3AF-AF6D-4595-B716-46CA53DEA995}.Release|x86.ActiveCfg = Release|Any CPU
323325
{0BE9F3AF-AF6D-4595-B716-46CA53DEA995}.Release|x86.Build.0 = Release|Any CPU
326+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
327+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
328+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Debug|x64.ActiveCfg = Debug|Any CPU
329+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Debug|x64.Build.0 = Debug|Any CPU
330+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Debug|x86.ActiveCfg = Debug|Any CPU
331+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Debug|x86.Build.0 = Debug|Any CPU
332+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
333+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Release|Any CPU.Build.0 = Release|Any CPU
334+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Release|x64.ActiveCfg = Release|Any CPU
335+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Release|x64.Build.0 = Release|Any CPU
336+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Release|x86.ActiveCfg = Release|Any CPU
337+
{D95226AC-55D6-4152-9214-25F8BEB6E7F5}.Release|x86.Build.0 = Release|Any CPU
324338
EndGlobalSection
325339
GlobalSection(SolutionProperties) = preSolution
326340
HideSolutionNode = FALSE

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands.ApiManagement.ServiceManagement.Netcore.csproj

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

3030
<ItemGroup>
3131
<PackageReference Include="AutoMapper" Version="6.2.2" />
32-
<PackageReference Include="Microsoft.Azure.Management.ApiManagement" Version="3.4.0" />
32+
<PackageReference Include="Microsoft.Azure.Management.ApiManagement" Version="3.4.1" />
3333
</ItemGroup>
3434

3535
<ItemGroup>

src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.Netcore.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</PropertyGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="Microsoft.Azure.Management.ApiManagement" Version="3.4.0" />
25+
<PackageReference Include="Microsoft.Azure.Management.ApiManagement" Version="3.4.1" />
2626
</ItemGroup>
2727

2828
<ItemGroup>
@@ -56,4 +56,10 @@
5656
</None>
5757
</ItemGroup>
5858

59+
<ItemGroup>
60+
<None Update="testcertificate.pfx">
61+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
62+
</None>
63+
</ItemGroup>
64+
5965
</Project>

src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/ScenarioTests/ApiManagementTests.cs

Lines changed: 17 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@
1818
using System.Diagnostics;
1919
using System.IO;
2020
using Microsoft.Azure.Management.Storage;
21+
using Microsoft.Azure.ServiceManagemenet.Common.Models;
2122
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2223
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
23-
#if !NETSTANDARD
24-
using Microsoft.Azure.Test;
25-
using TestBase = Microsoft.Azure.Test.TestBase;
26-
#endif
2724

2825
namespace Microsoft.Azure.Commands.ApiManagement.Test.ScenarioTests
2926
{
3027
using Azure.Test.HttpRecorder;
3128
using WindowsAzure.Commands.ScenarioTest;
3229
using WindowsAzure.Commands.Test.Utilities.Common;
33-
using ApiManagementClient = Management.ApiManagement.ApiManagementClient;
3430
using ResourceManagementClient = Management.Internal.Resources.ResourceManagementClient;
3531
using Xunit;
3632

@@ -40,21 +36,19 @@ public class ApiManagementTests : RMTestBase
4036

4137
public ApiManagementTests(Xunit.Abstractions.ITestOutputHelper output)
4238
{
43-
_helper = new EnvironmentSetupHelper();
44-
_helper.TracingInterceptor = new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output);
45-
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(_helper.TracingInterceptor);
39+
_helper = new EnvironmentSetupHelper
40+
{
41+
TracingInterceptor = new XunitTracingInterceptor(output)
42+
};
43+
XunitTracingInterceptor.AddToContext(_helper.TracingInterceptor);
4644
}
4745

4846
protected void SetupManagementClients(MockContext context)
4947
{
50-
var apiManagementManagementClient = GetApiManagementManagementClient(context);
5148
var resourceManagementClient = GetResourceManagementClient(context);
5249
var armStorageManagementClient = GetArmStorageManagementClient(context);
5350

54-
_helper.SetupManagementClients(
55-
apiManagementManagementClient,
56-
resourceManagementClient,
57-
armStorageManagementClient);
51+
_helper.SetupSomeOfManagementClients( resourceManagementClient, armStorageManagementClient);
5852
}
5953

6054
protected StorageManagementClient GetArmStorageManagementClient(MockContext context)
@@ -67,22 +61,7 @@ private ResourceManagementClient GetResourceManagementClient(MockContext context
6761
return context.GetServiceClient<ResourceManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
6862
}
6963

70-
private ApiManagementClient GetApiManagementManagementClient(MockContext context)
71-
{
72-
#if NETSTANDARD
73-
//return context.GetServiceClient<ApiManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
74-
return null;
75-
#else
76-
return TestBase.GetServiceClient<ApiManagementClient>(new CSMTestEnvironmentFactory());
77-
#endif
78-
}
79-
80-
#if NETSTANDARD
81-
[Fact(Skip = "Cannot construct ApiManagementClient using MockContext")]
82-
[Trait(Category.RunType, Category.DesktopOnly)]
83-
#else
8464
[Fact]
85-
#endif
8665
[Trait(Category.AcceptanceType, Category.CheckIn)]
8766
public void TestCrudApiManagement()
8867
{
@@ -101,96 +80,56 @@ public void TestBackupRestoreApiManagement()
10180
RunPowerShellTest("Test-BackupRestoreApiManagement");
10281
}
10382

104-
#if NETSTANDARD
105-
[Fact(Skip = "Cannot construct ApiManagementClient using MockContext")]
106-
[Trait(Category.RunType, Category.DesktopOnly)]
107-
#else
10883
[Fact]
109-
#endif
11084
[Trait(Category.AcceptanceType, Category.CheckIn)]
11185
public void TestSetApiManagementDeploymentExternalVN()
11286
{
11387
RunPowerShellTest("Test-SetApiManagementDeploymentExternalVirtualNetwork");
11488
}
11589

116-
#if NETSTANDARD
117-
[Fact(Skip = "Cannot construct ApiManagementClient using MockContext")]
118-
[Trait(Category.RunType, Category.DesktopOnly)]
119-
#else
12090
[Fact]
121-
#endif
12291
[Trait(Category.AcceptanceType, Category.CheckIn)]
12392
public void TestSetApiManagementDeploymentInternalVN()
12493
{
12594
RunPowerShellTest("Test-SetApiManagementDeploymentInternalVirtualNetwork");
12695
}
12796

128-
#if NETSTANDARD
129-
[Fact(Skip = "Cannot construct ApiManagementClient using MockContext")]
130-
[Trait(Category.RunType, Category.DesktopOnly)]
131-
#else
13297
[Fact]
133-
#endif
13498
[Trait(Category.AcceptanceType, Category.CheckIn)]
13599
public void TestUpdateApiManagementDeployment()
136100
{
137101
RunPowerShellTest("Test-UpdateApiManagementDeployment");
138102
}
139103

140-
#if NETSTANDARD
141-
[Fact(Skip = "Cannot construct ApiManagementClient using MockContext")]
142-
[Trait(Category.RunType, Category.DesktopOnly)]
143-
#else
144104
[Fact]
145-
#endif
146105
[Trait(Category.AcceptanceType, Category.CheckIn)]
147106
public void TestUpdateDeploymentComplex()
148107
{
149108
RunPowerShellTest("Test-UpdateApiManagementDeploymentWithHelpersAndPipeline");
150109
}
151110

152-
#if NETSTANDARD
153-
[Fact(Skip = "Cannot construct ApiManagementClient using MockContext")]
154-
[Trait(Category.RunType, Category.DesktopOnly)]
155-
#else
156111
[Fact]
157-
#endif
158112
[Trait(Category.AcceptanceType, Category.CheckIn)]
159113
public void TestImportApiManagementHostnameCertificate()
160114
{
161115
RunPowerShellTest("Test-ImportApiManagementHostnameCertificate");
162116
}
163117

164-
#if NETSTANDARD
165-
[Fact(Skip = "Cannot construct ApiManagementClient using MockContext")]
166-
[Trait(Category.RunType, Category.DesktopOnly)]
167-
#else
168118
[Fact]
169-
#endif
170119
[Trait(Category.AcceptanceType, Category.CheckIn)]
171120
public void TestSetApiManagementHostnames()
172121
{
173122
RunPowerShellTest("Test-SetApiManagementHostnames");
174123
}
175124

176-
#if NETSTANDARD
177-
[Fact(Skip = "Cannot construct ApiManagementClient using MockContext")]
178-
[Trait(Category.RunType, Category.DesktopOnly)]
179-
#else
180125
[Fact]
181-
#endif
182126
[Trait(Category.AcceptanceType, Category.CheckIn)]
183127
public void TestCrudApiManagementWithExternalVpn()
184128
{
185129
RunPowerShellTest("Test-CrudApiManagementWithExternalVpn");
186130
}
187131

188-
#if NETSTANDARD
189-
[Fact(Skip = "Cannot construct ApiManagementClient using MockContext")]
190-
[Trait(Category.RunType, Category.DesktopOnly)]
191-
#else
192132
[Fact]
193-
#endif
194133
[Trait(Category.AcceptanceType, Category.CheckIn)]
195134
public void TestCrudApiManagementWithAdditionalRegions()
196135
{
@@ -203,12 +142,16 @@ private void RunPowerShellTest(params string[] scripts)
203142
var callingClassType = sf.GetMethod().ReflectedType?.ToString();
204143
var mockName = sf.GetMethod().Name;
205144

206-
Dictionary<string, string> d = new Dictionary<string, string>();
207-
d.Add("Microsoft.Resources", null);
208-
d.Add("Microsoft.Features", null);
209-
d.Add("Microsoft.Authorization", null);
210-
var providersToIgnore = new Dictionary<string, string>();
211-
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
145+
Dictionary<string, string> d = new Dictionary<string, string>
146+
{
147+
{"Microsoft.Resources", null},
148+
{"Microsoft.Features", null},
149+
{"Microsoft.Authorization", null}
150+
};
151+
var providersToIgnore = new Dictionary<string, string>
152+
{
153+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
154+
};
212155
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
213156
HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
214157

src/ResourceManager/ApiManagement/Commands.ApiManagement/Commands.ApiManagement.Netcore.csproj

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

3030
<ItemGroup>
3131
<PackageReference Include="AutoMapper" Version="6.2.2" />
32-
<PackageReference Include="Microsoft.Azure.Management.ApiManagement" Version="3.4.0" />
32+
<PackageReference Include="Microsoft.Azure.Management.ApiManagement" Version="3.4.1" />
3333
</ItemGroup>
3434

3535
<ItemGroup>

src/ResourceManager/ApiManagement/Commands.SMAPI.Test/Commands.ApiManagement.ServiceManagement.Test.Netcore.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
</PropertyGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="Microsoft.Azure.Management.ApiManagement" Version="3.4.0" />
26-
<!-- <PackageReference Include="Microsoft.Azure.Management.Storage" Version="3.0.0" />
27-
<PackageReference Include="Microsoft.WindowsAzure.Management.Compute" Version="12.8.0" />
28-
<PackageReference Include="Microsoft.WindowsAzure.Management.Storage" Version="5.1.1" />
29-
<PackageReference Include="System.Management.Automation" Version="3.0.0.0" /> -->
25+
<PackageReference Include="Microsoft.Azure.Management.ApiManagement" Version="3.4.1" />
3026
</ItemGroup>
3127

3228
<ItemGroup>

src/ResourceManager/ApiManagement/Commands.SMAPI.Test/ScenarioTests/ApiManagementTests.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@
1919
using Microsoft.Azure.Commands.Common.Authentication;
2020
using Microsoft.Azure.Test.HttpRecorder;
2121
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
22-
#if !NETSTANDARD
23-
using Microsoft.Azure.Test;
24-
using TestBase = Microsoft.Azure.Test.TestBase;
25-
#endif
2622

2723
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Test.ScenarioTests
2824
{
29-
using Management.ApiManagement;
3025
using WindowsAzure.Commands.ScenarioTest;
3126
using WindowsAzure.Commands.Test.Utilities.Common;
3227
using Xunit;
@@ -42,23 +37,6 @@ public ApiManagementTests(ApiManagementTestsFixture fixture)
4237
_helper = new EnvironmentSetupHelper();
4338
}
4439

45-
protected void SetupManagementClients(MockContext context)
46-
{
47-
var apiManagementManagementClient = GetApiManagementManagementClient(context);
48-
_helper.SetupManagementClients(apiManagementManagementClient);
49-
}
50-
51-
private ApiManagementClient GetApiManagementManagementClient(MockContext context)
52-
{
53-
#if NETSTANDARD
54-
//return context.GetServiceClient<ApiManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
55-
return null;
56-
#else
57-
return TestBase.GetServiceClient<ApiManagementClient>(new CSMTestEnvironmentFactory());
58-
#endif
59-
}
60-
61-
6240
[Fact]
6341
[Trait(Category.AcceptanceType, Category.CheckIn)]
6442
public void ApiCrudTest()
@@ -207,9 +185,9 @@ private void RunPowerShellTest(params string[] scripts)
207185

208186
HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
209187

210-
using (MockContext context = MockContext.Start(callingClassType, mockName))
188+
using (MockContext.Start(callingClassType, mockName))
211189
{
212-
SetupManagementClients(context);
190+
_helper.SetupSomeOfManagementClients();
213191

214192
_helper.SetupEnvironment(AzureModule.AzureResourceManager);
215193
_helper.SetupModules(AzureModule.AzureResourceManager,

0 commit comments

Comments
 (0)