Skip to content

Commit ea38ff2

Browse files
authored
Merge pull request #5866 from v-Ajnava/preview_local
EventHub: Fixed AlternameName in New-AzureRmEventHubGeoDRConfiguration
2 parents 2f815b8 + 470a5e0 commit ea38ff2

File tree

7 files changed

+7228
-1730
lines changed

7 files changed

+7228
-1730
lines changed

src/ResourceManager/EventHub/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Fixed AlternameName in New-AzureRmEventHubGeoDRConfiguration
2122
* Updated to the latest version of the Azure ClientRuntime
2223

2324
## Version 0.6.2

src/ResourceManager/EventHub/Commands.EventHub.Test/Commands.EventHubs.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@
173173
<None Include="SessionRecords\Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.DRConfigurationTests\DRConfigurationsCURD.json">
174174
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
175175
</None>
176+
<None Include="SessionRecords\Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.DRConfigurationTests\DRConfigurationsCURDAlternateName.json">
177+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
178+
</None>
176179
<None Include="SessionRecords\Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.EventHubsTests\EventHubsAuthorizationRulesCRUD.json">
177180
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
178181
</None>

src/ResourceManager/EventHub/Commands.EventHub.Test/ScenarioTests/DRConfigurationTests.ps1

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,153 @@ function DRConfigurationTests
238238
# Wait till the Namespace Provisioning state changes to succeeded\
239239
WaitforStatetoBeSucceded_namespace $resourceGroupName $namespaceName2
240240

241+
Write-Debug " Delete namespaces"
242+
Remove-AzureRmEventHubNamespace -ResourceGroupName $resourceGroupName -Name $namespaceName2
243+
244+
Write-Debug " Delete resourcegroup"
245+
Remove-AzureRmResourceGroup -Name $resourceGroupName -Force
246+
}
247+
248+
function DRConfigurationTestsAlternateName
249+
{
250+
# Setup
251+
$location_south = Get-Location "Microsoft.ServiceBus" "namespaces" "South Central US"
252+
$location_north = Get-Location "Microsoft.ServiceBus" "namespaces" "North Central US"
253+
$resourceGroupName = getAssetName
254+
$namespaceName1 = getAssetName "Eventhub-Namespace-"
255+
$namespaceName2 = getAssetName "Eventhub-Namespace-"
256+
$drConfigName = $namespaceName1
257+
$authRuleName = getAssetName "Eventhub-Namespace-AuthorizationRule"
258+
$AlternateName = getAssetName "AlternateName"
259+
260+
# Create Resource Group
261+
Write-Debug "Create resource group"
262+
Write-Debug " Resource Group Name : $resourceGroupName"
263+
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location_south -Force
264+
265+
266+
# Create EventHub Namespace - 1
267+
Write-Debug " Create new eventhub namespace 1"
268+
Write-Debug " Namespace 1 name : $namespaceName1"
269+
$result1 = New-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName1 -Location $location_south
270+
271+
# Assert
272+
Assert-AreEqual $result1.Name $namespaceName1
273+
274+
275+
# Create EventHub Namespace - 2
276+
Write-Debug " Create new eventhub namespace 2"
277+
Write-Debug " Namespace 2 name : $namespaceName2"
278+
$result2 = New-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName2 -Location $location_north
279+
280+
# Assert
281+
Assert-AreEqual $result2.Name $namespaceName2
282+
283+
# get the created Eventhub Namespace 1
284+
Write-Debug " Get the created namespace within the resource group"
285+
$createdNamespace1 = Get-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName1
286+
287+
Assert-AreEqual $createdNamespace1.Name $namespaceName1 "Namespace created earlier is not found."
288+
289+
# get the created Eventhub Namespace 2
290+
Write-Debug " Get the created namespace within the resource group"
291+
$createdNamespace2 = Get-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -NamespaceName $namespaceName2
292+
293+
Assert-AreEqual $createdNamespace2.Name $namespaceName2 "Namespace created earlier is not found."
294+
295+
# Create AuthorizationRule
296+
Write-Debug "Create a Namespace Authorization Rule"
297+
Write-Debug "Auth Rule name : $authRuleName"
298+
$result = New-AzureRmEventHubAuthorizationRule -ResourceGroup $resourceGroupName -Namespace $namespaceName1 -Name $authRuleName -Rights @("Listen","Send")
299+
300+
Assert-AreEqual $authRuleName $result.Name
301+
Assert-AreEqual 2 $result.Rights.Count
302+
Assert-True { $result.Rights -Contains "Listen" }
303+
Assert-True { $result.Rights -Contains "Send" }
304+
305+
# Check DR Configuration Name Availability
306+
307+
$checkNameResult = Test-AzureRmEventHubName -ResourceGroup $resourceGroupName -Namespace $namespaceName1 -AliasName $drConfigName
308+
Assert-True { $checkNameResult.NameAvailable}
309+
310+
# Create a DRConfiguration
311+
Write-Debug " Create new DRConfiguration"
312+
$result = New-AzureRmEventHubGeoDRConfiguration -ResourceGroupName $resourceGroupName -Namespace $namespaceName1 -Name $drConfigName -PartnerNamespace $createdNamespace2.Id -AlternateName $AlternateName
313+
314+
# Wait till the Alias Provisioning state changes to succeeded
315+
$newDRConfig = WaitforStatetoBeSucceded $resourceGroupName $namespaceName1 $drConfigName
316+
Assert-AreEqual $newDRConfig.Role "Primary"
317+
318+
# Get AuthorizationRule through DRConfiguration
319+
Write-Debug "Get Namespace Authorization Rule details"
320+
Write-Debug "Auth Rule name : $authRuleName"
321+
$resultAuthRuleDR = Get-AzureRmEventHubAuthorizationRule -ResourceGroupName $resourceGroupName -Namespace $namespaceName1 -AliasName $drConfigName -Name $authRuleName
322+
323+
Assert-AreEqual $authRuleName $resultAuthRuleDR.Name
324+
Assert-AreEqual 2 $resultAuthRuleDR.Rights.Count
325+
Assert-True { $resultAuthRuleDR.Rights -Contains "Listen" }
326+
Assert-True { $resultAuthRuleDR.Rights -Contains "Send" }
327+
328+
# Get the connectionStrings for DRConfiguration
329+
330+
Write-Debug "Get namespace authorizationRules connectionStrings using DRConfiguration"
331+
$DRnamespaceListKeys = Get-AzureRmEventHubKey -ResourceGroupName $resourceGroupName -Namespace $namespaceName1 -AliasName $drConfigName -Name $authRuleName
332+
333+
Write-Debug " Get the created DRConfiguration"
334+
$createdDRConfig = Get-AzureRmEventHubGeoDRConfiguration -ResourceGroupName $resourceGroupName -Namespace $namespaceName1 -Name $drConfigName
335+
# Assert
336+
Assert-AreEqual $createdDRConfig.PartnerNamespace $createdNamespace2.Id "DRConfig created earlier is not found."
337+
338+
Write-Debug " Get the created DRConfiguration for Secondary Namespace"
339+
$createdDRConfigSecondary = Get-AzureRmEventHubGeoDRConfiguration -ResourceId $createdNamespace2.Id -Name $drConfigName
340+
Assert-AreEqual $createdDRConfigSecondary.Role "Secondary"
341+
342+
343+
# BreakPairing on Primary Namespace - Parameters
344+
Write-Debug "BreakPairing on Primary Namespace"
345+
Set-AzureRmEventHubGeoDRConfigurationBreakPair -ResourceGroupName $resourceGroupName -Namespace $namespaceName1 -Name $drConfigName
346+
347+
# Wait till the Alias Provisioning state changes to succeeded
348+
$breakPairingDRConfig = WaitforStatetoBeSucceded $resourceGroupName $namespaceName1 $drConfigName
349+
Assert-AreEqual $breakPairingDRConfig.Role "PrimaryNotReplicating"
350+
351+
# Create a DRConfiguration
352+
Write-Debug " Create new DRConfiguration"
353+
$DRBreakPair_withInputObject = New-AzureRmEventHubGeoDRConfiguration -ResourceGroupName $resourceGroupName -Namespace $namespaceName1 -Name $drConfigName -PartnerNamespace $createdNamespace2.Id -AlternateName $AlternateName
354+
355+
# Wait till the Alias Provisioning state changes to succeeded
356+
$UpdateDRConfig = WaitforStatetoBeSucceded $resourceGroupName $namespaceName1 $drConfigName
357+
Assert-AreEqual $UpdateDRConfig.Role "Primary"
358+
359+
# FailOver on Secondary Namespace - Parameters
360+
Write-Debug "FailOver on Secondary Namespace"
361+
Set-AzureRmEventHubGeoDRConfigurationFailOver -ResourceGroupName $resourceGroupName -Namespace $namespaceName2 -Name $drConfigName
362+
363+
# Wait till the Alias Provisioning state changes to succeeded
364+
$failoverDrConfiguration = WaitforStatetoBeSucceded $resourceGroupName $namespaceName2 $drConfigName
365+
Assert-AreEqual $failoverDrConfiguration.Role "PrimaryNotReplicating"
366+
Assert-AreEqual $failoverDrConfiguration.PartnerNamespace "" "FaileOver: PartnerNamespace exists"
367+
368+
# Remove the Alias created
369+
Remove-AzureRmEventHubGeoDRConfiguration -ResourceGroupName $resourceGroupName -Namespace $namespaceName2 -Name $drConfigName
370+
Wait-Seconds 120
371+
372+
# Get the Created GeoDRConfiguration
373+
Write-Debug " Get all the created GeoDRConfiguration"
374+
$createdServiceBusDRConfigList_delete = Get-AzureRmEventHubGeoDRConfiguration -ResourceGroup $resourceGroupName -Namespace $namespaceName1
375+
376+
# Assert
377+
Assert-AreEqual $createdServiceBusDRConfigList_delete.Count 0 "DR Config List: after delete the DRCoinfig was listed"
378+
379+
# Wait till the Namespace Provisioning state changes to succeeded
380+
WaitforStatetoBeSucceded_namespace $resourceGroupName $namespaceName1
381+
382+
Write-Debug " Delete namespaces"
383+
Remove-AzureRmEventHubNamespace -ResourceGroupName $resourceGroupName -Name $namespaceName1
384+
385+
# Wait till the Namespace Provisioning state changes to succeeded\
386+
WaitforStatetoBeSucceded_namespace $resourceGroupName $namespaceName2
387+
241388
Write-Debug " Delete namespaces"
242389
Remove-AzureRmEventHubNamespace -ResourceGroupName $resourceGroupName -Name $namespaceName2
243390

src/ResourceManager/EventHub/Commands.EventHub.Test/ScenarioTests/DRConfigurations.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@ public DRConfigurationTests(ITestOutputHelper output)
2626
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
2727
}
2828

29-
[Fact(Skip = "Need service team to re-record test after changes to the ClientRuntime.")]
29+
[Fact]
3030
[Trait(Category.AcceptanceType, Category.CheckIn)]
31-
[Trait("Re-record", "ClientRuntime changes")]
3231
public void DRConfigurationsCURD()
3332
{
3433
EventHubsController.NewInstance.RunPsTest("DRConfigurationTests");
3534
}
35+
36+
[Fact]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
38+
public void DRConfigurationsCURDAlternateName()
39+
{
40+
EventHubsController.NewInstance.RunPsTest("DRConfigurationTestsAlternateName");
41+
}
3642
}
3743
}

0 commit comments

Comments
 (0)