Skip to content

Commit 40de429

Browse files
committed
Merge pull request Azure#115 from levhayr/ignite_team
Updates to AzureDns cmdlets with new features and fixes for Ignite
2 parents 967e5bc + 5389208 commit 40de429

File tree

47 files changed

+4220
-2463
lines changed

Some content is hidden

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

47 files changed

+4220
-2463
lines changed

src/Common/Commands.ScenarioTests.Common/EnvironmentSetupHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void SetupEnvironment(AzureModule mode)
9292

9393
ProfileClient.Profile.Save();
9494
}
95-
95+
9696
private void SetupAzureEnvironmentFromEnvironmentVariables(AzureModule mode)
9797
{
9898
TestEnvironment rdfeEnvironment = new RDFETestEnvironmentFactory().GetTestEnvironment();

src/ResourceManager/Dns/Commands.Dns.Test/Commands.Dns.Test.csproj

Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,18 @@
5353
<SpecificVersion>False</SpecificVersion>
5454
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Authentication.1.0.21-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
5555
</Reference>
56+
<Reference Include="Microsoft.Azure.Gallery, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
57+
<SpecificVersion>False</SpecificVersion>
58+
<HintPath>..\..\..\packages\Microsoft.Azure.Gallery.2.6.2-preview\lib\net40\Microsoft.Azure.Gallery.dll</HintPath>
59+
</Reference>
5660
<Reference Include="Microsoft.Azure.Management.Authorization, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5761
<SpecificVersion>False</SpecificVersion>
5862
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.0-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
5963
</Reference>
64+
<Reference Include="Microsoft.Azure.Management.Dns, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
65+
<SpecificVersion>False</SpecificVersion>
66+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.1.2.1-preview\lib\net40\Microsoft.Azure.Management.Dns.dll</HintPath>
67+
</Reference>
6068
<Reference Include="Microsoft.Azure.Monitoring, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6169
<SpecificVersion>False</SpecificVersion>
6270
<HintPath>..\..\..\packages\Microsoft.Azure.Monitoring.2.2.1-preview\lib\net40\Microsoft.Azure.Monitoring.dll</HintPath>
@@ -137,6 +145,8 @@
137145
<Compile Include="ScenarioTests\ZoneTests.cs" />
138146
<Compile Include="ScenarioTests\RecordsTests.cs" />
139147
<Compile Include="ScenarioTests\DnsTestsBase.cs" />
148+
<Compile Include="UnitTests\GetAzureDnsRecordSetTests.cs" />
149+
<Compile Include="UnitTests\GetAzureDnsZoneTests.cs" />
140150
</ItemGroup>
141151
<ItemGroup>
142152
<ProjectReference Include="..\..\..\Common\Commands.ScenarioTests.Common\Commands.ScenarioTests.Common.csproj">
@@ -164,7 +174,7 @@
164174
<Name>Commands.Common</Name>
165175
</ProjectReference>
166176
<ProjectReference Include="..\Commands.Dns\Commands.Dns.csproj">
167-
<Project>{69ed499e-6f3c-488f-86b8-b74cfda4d47e}</Project>
177+
<Project>{3cae1b57-ffec-4945-a6c5-6e5e8dea4ba9}</Project>
168178
<Name>Commands.Dns</Name>
169179
</ProjectReference>
170180
</ItemGroup>
@@ -185,70 +195,7 @@
185195
<None Include="ScenarioTests\Common.ps1">
186196
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
187197
</None>
188-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetA.json">
189-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
190-
</None>
191-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetAAAA.json">
192-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
193-
</None>
194-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetAddRecordTypeMismatch.json">
195-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
196-
</None>
197-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetAddTwoCnames.json">
198-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
199-
</None>
200-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetCNAME.json">
201-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
202-
</None>
203-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetCrud.json">
204-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
205-
</None>
206-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetCrudWithPiping.json">
207-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
208-
</None>
209-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetEtagMismatch.json">
210-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
211-
</None>
212-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetGet.json">
213-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
214-
</None>
215-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetMX.json">
216-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
217-
</None>
218-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetNS.json">
219-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
220-
</None>
221-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetRemoveRecordTypeMismatch.json">
222-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
223-
</None>
224-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetSOA.json">
225-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
226-
</None>
227-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetSRV.json">
228-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
229-
</None>
230-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetTXT.json">
231-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
232-
</None>
233-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrud.json">
234-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
235-
</None>
236-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrudWithPiping.json">
237-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
238-
</None>
239-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneList.json">
240-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
241-
</None>
242-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneRemoveEtagMismatch.json">
243-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
244-
</None>
245-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneRemoveNotFound.json">
246-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
247-
</None>
248-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneSetEtagMismatch.json">
249-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
250-
</None>
251-
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneSetNotFound.json">
198+
<None Include="SessionRecords\**\*.json">
252199
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
253200
</None>
254201
</ItemGroup>

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/DnsTestsBase.cs

Lines changed: 167 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,182 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Common.Authentication;
16-
using Microsoft.Azure.Management.Resources;
17-
using Microsoft.Azure.Test;
18-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20-
2115
namespace Microsoft.Azure.Commands.ScenarioTest.DnsTests
2216
{
23-
public class DnsTestsBase
24-
{
25-
private EnvironmentSetupHelper helper;
17+
using System;
18+
using System.Linq;
19+
using Microsoft.Azure.Common.Authentication;
20+
using Microsoft.Azure.Gallery;
21+
using Microsoft.Azure.Management.Authorization;
22+
using Microsoft.Azure.Management.Resources;
23+
using Microsoft.Azure.Subscriptions.Csm;
24+
using Microsoft.Azure.Test;
25+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
26+
using Microsoft.Azure.Management.Dns;
2627

27-
protected DnsTestsBase()
28-
{
29-
helper = new EnvironmentSetupHelper();
30-
}
3128

32-
protected void SetupManagementClients()
33-
{
34-
var resourcesClient = GetResourcesClient();
35-
helper.SetupSomeOfManagementClients(resourcesClient);
36-
}
29+
public class DnsTestsBase
30+
{
31+
private CSMTestEnvironmentFactory csmTestFactory;
3732

38-
protected void RunPowerShellTest(params string[] scripts)
39-
{
40-
// Enable undo functionality as well as mock recording
41-
using (UndoContext context = UndoContext.Current)
42-
{
43-
// Configure recordings
44-
context.Start(TestUtilities.GetCallingClass(2), TestUtilities.GetCurrentMethodName(2));
4533

46-
SetupManagementClients();
34+
private readonly EnvironmentSetupHelper helper;
35+
36+
37+
public ResourceManagementClient ResourceManagementClient { get; private set; }
38+
39+
40+
public SubscriptionClient SubscriptionClient { get; private set; }
41+
42+
43+
public GalleryClient GalleryClient { get; private set; }
44+
45+
46+
public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }
47+
48+
49+
public DnsManagementClient DnsClient { get; private set; }
50+
51+
52+
public static DnsTestsBase NewInstance
53+
{
54+
get
55+
{
56+
return new DnsTestsBase();
57+
}
58+
}
59+
60+
61+
protected DnsTestsBase()
62+
{
63+
this.helper = new EnvironmentSetupHelper();
64+
}
65+
66+
67+
protected void SetupManagementClients()
68+
{
69+
this.ResourceManagementClient = this.GetResourceManagementClient();
70+
this.SubscriptionClient = this.GetSubscriptionClient();
71+
this.GalleryClient = this.GetGalleryClient();
72+
this.AuthorizationManagementClient = this.GetAuthorizationManagementClient();
73+
this.DnsClient = this.GetFeatureClient();
74+
75+
76+
this.helper.SetupManagementClients(
77+
this.ResourceManagementClient,
78+
this.SubscriptionClient,
79+
this.GalleryClient,
80+
this.AuthorizationManagementClient,
81+
this.DnsClient);
82+
}
83+
84+
85+
public void RunPowerShellTest(params string[] scripts)
86+
{
87+
string callingClassType = TestUtilities.GetCallingClass(2);
88+
string mockName = TestUtilities.GetCurrentMethodName(2);
89+
4790

48-
helper.SetupEnvironment(AzureModule.AzureResourceManager);
91+
this.RunPsTestWorkflow(
92+
() => scripts,
93+
// no custom initializer
94+
null,
95+
// no custom cleanup
96+
null,
97+
callingClassType,
98+
mockName);
99+
}
49100

50-
helper.SetupModules(AzureModule.AzureProfile, "ScenarioTests\\Common.ps1",
51-
"ScenarioTests\\" + this.GetType().Name + ".ps1");
52101

53-
helper.RunPowerShellTest(scripts);
54-
}
102+
public void RunPsTestWorkflow(
103+
Func<string[]> scriptBuilder,
104+
Action<CSMTestEnvironmentFactory> initialize,
105+
Action cleanup,
106+
string callingClassType,
107+
string mockName)
108+
{
109+
using (UndoContext context = UndoContext.Current)
110+
{
111+
context.Start(callingClassType, mockName);
112+
113+
114+
this.csmTestFactory = new CSMTestEnvironmentFactory();
115+
116+
117+
if (initialize != null)
118+
{
119+
initialize(this.csmTestFactory);
120+
}
121+
122+
123+
this.SetupManagementClients();
124+
125+
126+
this.helper.SetupEnvironment(AzureModule.AzureResourceManager);
127+
128+
129+
string callingClassName = callingClassType
130+
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
131+
.Last();
132+
133+
134+
this.helper.SetupModules(
135+
AzureModule.AzureResourceManager,
136+
"ScenarioTests\\Common.ps1",
137+
"ScenarioTests\\" + callingClassName + ".ps1");
138+
139+
140+
try
141+
{
142+
if (scriptBuilder != null)
143+
{
144+
string[] psScripts = scriptBuilder();
145+
146+
147+
if (psScripts != null)
148+
{
149+
this.helper.RunPowerShellTest(psScripts);
150+
}
151+
}
152+
}
153+
finally
154+
{
155+
if (cleanup != null)
156+
{
157+
cleanup();
158+
}
159+
}
160+
}
161+
}
162+
163+
164+
protected ResourceManagementClient GetResourceManagementClient()
165+
{
166+
return TestBase.GetServiceClient<ResourceManagementClient>(this.csmTestFactory);
167+
}
168+
169+
170+
private AuthorizationManagementClient GetAuthorizationManagementClient()
171+
{
172+
return TestBase.GetServiceClient<AuthorizationManagementClient>(this.csmTestFactory);
173+
}
174+
175+
176+
private SubscriptionClient GetSubscriptionClient()
177+
{
178+
return TestBase.GetServiceClient<SubscriptionClient>(this.csmTestFactory);
179+
}
180+
181+
182+
private GalleryClient GetGalleryClient()
183+
{
184+
return TestBase.GetServiceClient<GalleryClient>(this.csmTestFactory);
55185
}
56186

57-
protected ResourceManagementClient GetResourcesClient()
187+
188+
private DnsManagementClient GetFeatureClient()
58189
{
59-
return TestBase.GetServiceClient<ResourceManagementClient>(new CSMTestEnvironmentFactory());
60-
}
61-
}
62-
}
190+
return TestBase.GetServiceClient<DnsManagementClient>(this.csmTestFactory);
191+
}
192+
}
193+
}

0 commit comments

Comments
 (0)