Skip to content

Commit d300324

Browse files
authored
Merge pull request Azure#2835 from corinajacobson/SeptemberCojaco
Azure RM Dns Bug Fixes and Update to Help File
2 parents ec2a0c7 + f5d7c03 commit d300324

File tree

20 files changed

+3808
-896
lines changed

20 files changed

+3808
-896
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@
315315
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetTXTNonEmpty.json">
316316
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
317317
</None>
318+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetEndsWithZoneName.json">
319+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
320+
</None>
321+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.RecordsTests\TestRecordSetNewRecordNoName.json">
322+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
323+
</None>
318324
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneCrud.json">
319325
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
320326
</None>
@@ -348,6 +354,9 @@
348354
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneSetNotFound.json">
349355
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
350356
</None>
357+
<None Include="SessionRecords\Microsoft.Azure.Commands.ScenarioTest.DnsTests.ZoneTests\TestZoneAddRemoveRecordSet.json">
358+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
359+
</None>
351360
</ItemGroup>
352361
<ItemGroup />
353362
<ItemGroup>
@@ -357,4 +366,4 @@
357366
</EmbeddedResource>
358367
</ItemGroup>
359368
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
360-
</Project>
369+
</Project>

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,18 @@ public void TestRecordSetGet()
229229
{
230230
DnsTestsBase.NewInstance.RunPowerShellTest("Test-RecordSetGet");
231231
}
232+
233+
[Fact]
234+
[Trait(Category.AcceptanceType, Category.CheckIn)]
235+
public void TestRecordSetEndsWithZoneName()
236+
{
237+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-RecordSetEndsWithZoneName");
238+
}
239+
[Fact]
240+
[Trait(Category.AcceptanceType, Category.CheckIn)]
241+
public void TestRecordSetNewRecordNoName()
242+
{
243+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-RecordSetNewRecordNoName");
244+
}
232245
}
233246
}

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/RecordsTests.ps1

Lines changed: 118 additions & 64 deletions
Large diffs are not rendered by default.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,12 @@ public void TestZoneRemoveNotFound()
100100
{
101101
DnsTestsBase.NewInstance.RunPowerShellTest("Test-ZoneRemoveNonExisting");
102102
}
103+
104+
[Fact()]
105+
[Trait(Category.AcceptanceType, Category.CheckIn)]
106+
public void TestZoneAddRemoveRecordSet()
107+
{
108+
DnsTestsBase.NewInstance.RunPowerShellTest("Test-AddRemoveRecordSet");
109+
}
103110
}
104111
}

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/ZoneTests.ps1

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ function Test-ZoneCrud
2727
Assert-AreEqual $zoneName $createdZone.Name
2828
Assert-AreEqual $resourceGroup.ResourceGroupName $createdZone.ResourceGroupName
2929
Assert-AreEqual 1 $createdZone.Tags.Count
30+
Assert-AreEqual 2 $createdZone.NumberOfRecordSets
31+
Assert-AreNotEqual $createdZone.NumberOfRecordSets $createdZone.MaxNumberOfRecordSets
32+
3033

3134
$retrievedZone = Get-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName
3235

@@ -36,6 +39,9 @@ function Test-ZoneCrud
3639
Assert-AreEqual $resourceGroup.ResourceGroupName $retrievedZone.ResourceGroupName
3740
Assert-AreEqual $retrievedZone.Etag $createdZone.Etag
3841
Assert-AreEqual 1 $retrievedZone.Tags.Count
42+
Assert-AreEqual $createdZone.NumberOfRecordSets $retrievedZone.NumberOfRecordSets
43+
# broken by bug RDBug #6993514
44+
#Assert-AreEqual $createdZone.MaxNumberOfRecordSets $retrievedZone.MaxNumberOfRecordSets
3945

4046
$updatedZone = Set-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -Tags @{tag1="value1";tag2="value2"}
4147

@@ -55,7 +61,7 @@ function Test-ZoneCrud
5561
Assert-AreEqual $retrievedZone.Etag $updatedZone.Etag
5662
Assert-AreEqual 2 $retrievedZone.Tags.Count
5763

58-
$removed = Remove-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -PassThru -Force
64+
$removed = Remove-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -PassThru -Confirm:$false
5965

6066
Assert-True { $removed }
6167

@@ -86,7 +92,7 @@ function Test-ZoneCrudTrimsDot
8692
Assert-NotNull $updatedZone
8793
Assert-AreEqual $zoneName $updatedZone.Name
8894

89-
$removed = Remove-AzureRmDnsZone -Name $zoneNameWithDot -ResourceGroupName $resourceGroup.ResourceGroupName -PassThru -Force
95+
$removed = Remove-AzureRmDnsZone -Name $zoneNameWithDot -ResourceGroupName $resourceGroup.ResourceGroupName -PassThru -Confirm:$false
9096

9197
Assert-True { $removed }
9298

@@ -119,7 +125,7 @@ function Test-ZoneCrudWithPiping
119125
Assert-AreNotEqual $updatedZone.Etag $createdZone.Etag
120126
Assert-AreEqual 0 $updatedZone.Tags.Count
121127

122-
$removed = Get-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroupName | Remove-AzureRmDnsZone -PassThru -Force
128+
$removed = Get-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroupName | Remove-AzureRmDnsZone -PassThru -Confirm:$false
123129

124130
Assert-True { $removed }
125131

@@ -147,7 +153,7 @@ function Test-ZoneCrudWithPipingTrimsDot
147153
Assert-NotNull $updatedZone
148154
Assert-AreEqual $zoneName $updatedZone.Name
149155

150-
$removed = $zoneObjectWithDot | Remove-AzureRmDnsZone -Overwrite -PassThru -Force
156+
$removed = $zoneObjectWithDot | Remove-AzureRmDnsZone -Overwrite -PassThru -Confirm:$false
151157

152158
Assert-True { $removed }
153159

@@ -168,7 +174,7 @@ function Test-ZoneNewAlreadyExists
168174
$message = [System.String]::Format("The Zone {0} exists already and hence cannot be created again.", $zoneName);
169175
Assert-Throws { New-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroupName } $message
170176

171-
$createdZone | Remove-AzureRmDnsZone -PassThru -Force
177+
$createdZone | Remove-AzureRmDnsZone -PassThru -Confirm:$false
172178
}
173179

174180
<#
@@ -190,7 +196,7 @@ function Test-ZoneSetEtagMismatch
190196
Assert-AreNotEqual "gibberish" $updatedZone.Etag
191197
Assert-AreNotEqual $createdZone.Etag $updatedZone.Etag
192198

193-
$updatedZone | Remove-AzureRmDnsZone -PassThru -Force
199+
$updatedZone | Remove-AzureRmDnsZone -PassThru -Confirm:$false
194200
}
195201

196202
<#
@@ -218,9 +224,9 @@ function Test-ZoneRemoveEtagMismatch
218224
$createdZone.Etag = "gibberish"
219225

220226
$message = [System.String]::Format("The Zone {0} has been modified (etag mismatch).", $zoneName);
221-
Assert-Throws { $createdZone | Remove-AzureRmDnsZone -Force } $message
227+
Assert-Throws { $createdZone | Remove-AzureRmDnsZone -Confirm:$false } $message
222228

223-
$removed = $createdZone | Remove-AzureRmDnsZone -Overwrite -Force -PassThru
229+
$removed = $createdZone | Remove-AzureRmDnsZone -Overwrite -Confirm:$false -PassThru
224230

225231
Assert-True { $removed }
226232
}
@@ -234,7 +240,7 @@ function Test-ZoneRemoveNonExisting
234240
$zoneName = Get-RandomZoneName
235241
$resourceGroup = TestSetup-CreateResourceGroup
236242

237-
$removed = Remove-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -Force -PassThru
243+
$removed = Remove-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -Confirm:$false -PassThru
238244
}
239245

240246
<#
@@ -263,7 +269,7 @@ function Test-ZoneList
263269
Assert-NotNull $resourceGroup.ResourceGroupName $result[1].ResourceGroupName
264270
Assert-AreEqual 0 $result[1].Tags.Count
265271

266-
$result | Remove-AzureRmDnsZone -PassThru -Force
272+
$result | Remove-AzureRmDnsZone -PassThru -Confirm:$false
267273
}
268274

269275
function Test-ZoneListSubscription
@@ -278,8 +284,8 @@ function Test-ZoneListSubscription
278284

279285
Assert-True { $result.Count -ge 2 }
280286

281-
$createdZone1 | Remove-AzureRmDnsZone -PassThru -Force
282-
$createdZone2 | Remove-AzureRmDnsZone -PassThru -Force
287+
$createdZone1 | Remove-AzureRmDnsZone -PassThru -Confirm:$false
288+
$createdZone2 | Remove-AzureRmDnsZone -PassThru -Confirm:$false
283289
}
284290

285291
<#
@@ -303,6 +309,27 @@ function Test-ZoneListWithEndsWith
303309
Assert-AreEqual $createdZone2.Etag $result[0].Etag
304310
Assert-AreEqual $createdZone2.Name $result[0].Name
305311
Assert-NotNull $resourceGroup.ResourceGroupName $result[0].ResourceGroupName
312+
$result | Remove-AzureRmDnsZone -PassThru -Confirm:$false
313+
}
314+
315+
<#
316+
.SYNOPSIS
317+
Add and Remove RecordSet from Zone and test NumberOfRecordSets
318+
#>
319+
function Test-AddRemoveRecordSet
320+
{
321+
$zoneName = Get-RandomZoneName
322+
$recordName = getAssetname
323+
$resourceGroup = TestSetup-CreateResourceGroup
324+
$createdZone = New-AzureRmDnsZone -Name $zoneName -ResourceGroupName $resourceGroup.ResourceGroupName -Tags @{Name="tag1";Value="value1"}
325+
326+
$record = $createdZone | New-AzureRmDnsRecordSet -Name $recordName -Ttl 100 -RecordType A -DnsRecords @() | Add-AzureRmDnsRecordConfig -Ipv4Address 1.1.1.1 | Set-AzureRmDnsRecordSet
327+
$updatedZone = Get-AzureRmDnsZone -ResourceGroupName $resourceGroup.ResourceGroupName -Name $zoneName
328+
Assert-AreEqual 3 $updatedZone.NumberOfRecordSets
329+
330+
$removeRecord = $updatedZone | Get-AzureRmDnsRecordSet -Name $recordName -RecordType A | Remove-AzureRmDnsRecordSet -Name $recordName -RecordType A -PassThru -Confirm:$false
331+
$finalZone = Get-AzureRmDnsZone -ResourceGroupName $resourceGroup.ResourceGroupName -Name $zoneName
332+
Assert-AreEqual 2 $finalZone.NumberOfRecordSets
306333

307-
$result | Remove-AzureRmDnsZone -PassThru -Force
334+
$finalZone | Remove-AzureRmDnsZone -PassThru -Confirm:$false
308335
}

0 commit comments

Comments
 (0)