Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/EventGrid/EventGrid.Test/EventGrid.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.EventGrid" Version="7.0.0" />
<PackageReference Include="Microsoft.Azure.Management.EventHub" Version="4.0.0" />
<PackageReference Include="Microsoft.Azure.Management.EventHub" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Relay" Version="2.0.2" />
<PackageReference Include="Microsoft.Azure.Management.ServiceBus" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="24.0.0" />
Expand Down
6 changes: 5 additions & 1 deletion src/EventHub/EventHub.Test/EventHub.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5" />
<PackageReference Include="Microsoft.Azure.Management.EventHub" Version="4.0.0" />
<PackageReference Include="Microsoft.Azure.Management.EventHub" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="4.0.0-preview.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EventHub\EventHub.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="SessionRecords\Microsoft.Azure.Commands.EventHub.Test.ScenarioTests.NamespaceBYOKTests\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function DRConfigurationTests

# Assert
Assert-AreEqual $createdServiceBusDRConfigList_delete.Count 0 "DR Config List: after delete the DRCoinfig was listed"
# Wait till the Namespace Provisioning state changes to succeeded
# Wait till the Namespace Provisioning state changes to succeeded
WaitforStatetoBeSucceded_namespace $resourceGroupName $namespaceName1

Write-Debug " Delete namespaces"
Expand Down Expand Up @@ -403,7 +403,7 @@ function DRConfigurationTestsAlternateName

# Remove the Alias created
Remove-AzEventHubGeoDRConfiguration -ResourceGroupName $resourceGroupName -Namespace $namespaceName2 -Name $drConfigName
Wait-Seconds 120
Wait-Seconds 180

# Get the Created GeoDRConfiguration
Write-Debug " Get all the created GeoDRConfiguration"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected EventHubTestRunner(ITestOutputHelper output)
{"Microsoft.Resources", null},
{"Microsoft.Features", null},
{"Microsoft.Authorization", null},
{"Microsoft.EventHub", null},
{"Microsoft.Storage", null},
{"Microsoft.KeyVault", null},
{"Microsoft.ManagedServiceIdentity", null}
}
Expand Down
7 changes: 7 additions & 0 deletions src/EventHub/EventHub.Test/ScenarioTests/Namespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,12 @@ public void SchemaRegistry()
{
TestRunner.RunTestScript("SchemaRegistryTest");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ApplicationGroupTest()
{
TestRunner.RunTestScript("ApplicationGroupTest");
}
}
}
185 changes: 185 additions & 0 deletions src/EventHub/EventHub.Test/ScenarioTests/NamespaceTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,188 @@ function EncryptionTest{
Remove-AzEventHubNamespace -ResourceGroupName $resourceGroupName -Name $namespace1
}
}


function ApplicationGroupTest{
$location = "eastus"
$resourceGroupName = getAssetName "PSSDKTesting-RG"
$namespaceName = getAssetName "PSSDKTesting-NS"
$appGroupName = getAssetName "appGroupName"
$appGroupName2 = getAssetName "appGroupName2"
$appGroupName3 = getAssetName "appGroupName3"
$appGroupName4 = getAssetName "appGroupName3"
$throttlingPolicy1 = "ThrottlingPolicy1"
$throttlingPolicy2 = "ThrottlingPolicy2"
$throttlingPolicy3 = "ThrottlingPolicy3"
$throttlingPolicy4 = "ThrottlingPolicy4"
$clientGroupId = getAssetName "SASKeyName=authkey"
$clientGroupId2 = getAssetName "SASKeyName=authkey"
$clientGroupId3 = getAssetName "SASKeyName=authkey"
$clientGroupId4 = getAssetName "SASKeyName=authkey"

try{
# Create Resource Group
Write-Debug "Create resource group"
Write-Debug " Resource Group Name : $resourceGroupName"
New-AzResourceGroup -Name $resourceGroupName -Location $location -Force


# Create EventHub Namespace
Write-Debug " Create new eventhub namespace"
Write-Debug " Namespace name : $namespaceName"
$result = New-AzEventHubNamespace -ResourceGroup $resourceGroupName -Name $namespaceName -Location $location -SkuName Premium

$t1 = New-AzEventHubThrottlingPolicyConfig -Name $throttlingPolicy1 -MetricId IncomingMessages -RateLimitThreshold 1032
$t2 = New-AzEventHubThrottlingPolicyConfig -Name $throttlingPolicy2 -MetricId OutgoingBytes -RateLimitThreshold 10567
$t3 = New-AzEventHubThrottlingPolicyConfig -Name $throttlingPolicy3 -MetricId OutgoingMessages -RateLimitThreshold 9058
$t4 = New-AzEventHubThrottlingPolicyConfig -Name $throttlingPolicy4 -MetricId IncomingBytes -RateLimitThreshold 1896

$appGroup1 = New-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName -Name $appGroupName -IsEnabled -ThrottlingPolicyConfig $t1, $t2 -ClientAppGroupIdentifier $clientGroupId

Assert-AreEqual $appGroup1.ClientAppGroupIdentifier $clientGroupId
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig.Count 2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].Name $throttlingPolicy1
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].MetricId "IncomingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].RateLimitThreshold 1032
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].Name $throttlingPolicy2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].MetricId "OutgoingBytes"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].RateLimitThreshold 10567
Assert-True { $appGroup1.IsEnabled }

$appGroup1 = Get-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName -Name $appGroupName

Assert-AreEqual $appGroup1.ClientAppGroupIdentifier $clientGroupId
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig.Count 2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].Name $throttlingPolicy1
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].MetricId "IncomingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].RateLimitThreshold 1032
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].Name $throttlingPolicy2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].MetricId "OutgoingBytes"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].RateLimitThreshold 10567
Assert-True { $appGroup1.IsEnabled }

$appGroup1 = Set-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName -Name $appGroupName -IsEnabled:$false

Assert-AreEqual $appGroup1.ClientAppGroupIdentifier $clientGroupId
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig.Count 2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].Name $throttlingPolicy1
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].MetricId "IncomingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].RateLimitThreshold 1032
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].Name $throttlingPolicy2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].MetricId "OutgoingBytes"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].RateLimitThreshold 10567
Assert-False { $appGroup1.IsEnabled }

$appGroup1 = Set-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName -Name $appGroupName -IsEnabled

Assert-AreEqual $appGroup1.ClientAppGroupIdentifier $clientGroupId
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig.Count 2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].Name $throttlingPolicy1
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].MetricId "IncomingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].RateLimitThreshold 1032
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].Name $throttlingPolicy2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].MetricId "OutgoingBytes"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].RateLimitThreshold 10567
Assert-True { $appGroup1.IsEnabled }


#Testing INPUT OBJECT parameter set

$appGroup1.ThrottlingPolicyConfig += $t3

$appGroup1 = Set-AzEventHubApplicationGroup -InputObject $appGroup1

Assert-AreEqual $appGroup1.ClientAppGroupIdentifier $clientGroupId
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig.Count 3
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].Name $throttlingPolicy1
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].MetricId "IncomingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].RateLimitThreshold 1032
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].Name $throttlingPolicy2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].MetricId "OutgoingBytes"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].RateLimitThreshold 10567
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].Name $throttlingPolicy3
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].MetricId "OutgoingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].RateLimitThreshold 9058
Assert-True { $appGroup1.IsEnabled }

$appGroup1.IsEnabled = $false

$appGroup1 = Set-AzEventHubApplicationGroup -InputObject $appGroup1

Assert-AreEqual $appGroup1.ClientAppGroupIdentifier $clientGroupId
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig.Count 3
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].Name $throttlingPolicy1
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].MetricId "IncomingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].RateLimitThreshold 1032
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].Name $throttlingPolicy2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].MetricId "OutgoingBytes"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].RateLimitThreshold 10567
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].Name $throttlingPolicy3
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].MetricId "OutgoingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].RateLimitThreshold 9058
Assert-False { $appGroup1.IsEnabled }

#Testing RESOURCE ID

$appGroup1 = Set-AzEventHubApplicationGroup -ResourceId $appGroup1.Id -IsEnabled

Assert-AreEqual $appGroup1.ClientAppGroupIdentifier $clientGroupId
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig.Count 3
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].Name $throttlingPolicy1
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].MetricId "IncomingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].RateLimitThreshold 1032
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].Name $throttlingPolicy2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].MetricId "OutgoingBytes"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].RateLimitThreshold 10567
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].Name $throttlingPolicy3
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].MetricId "OutgoingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].RateLimitThreshold 9058
Assert-True { $appGroup1.IsEnabled }

$appGroup1.ThrottlingPolicyConfig += $t4

$appGroup1 = Set-AzEventHubApplicationGroup -ResourceId $appGroup1.Id -ThrottlingPolicyConfig $appGroup1.ThrottlingPolicyConfig

Assert-AreEqual $appGroup1.ClientAppGroupIdentifier $clientGroupId
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig.Count 4
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].Name $throttlingPolicy1
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].MetricId "IncomingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[0].RateLimitThreshold 1032
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].Name $throttlingPolicy2
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].MetricId "OutgoingBytes"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[1].RateLimitThreshold 10567
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].Name $throttlingPolicy3
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].MetricId "OutgoingMessages"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[2].RateLimitThreshold 9058
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[3].Name $throttlingPolicy4
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[3].MetricId "IncomingBytes"
Assert-AreEqual $appGroup1.ThrottlingPolicyConfig[3].RateLimitThreshold 1896
Assert-True { $appGroup1.IsEnabled }

$appGroup2 = New-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName -Name $appGroupName2 -ClientAppGroupIdentifier $clientGroupId2 -ThrottlingPolicyConfig $t3
$appGroup3 = New-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName -Name $appGroupName3 -ClientAppGroupIdentifier $clientGroupId3 -ThrottlingPolicyConfig $t1
$appGroup4 = New-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName -Name $appGroupName4 -ClientAppGroupIdentifier $clientGroupId4 -ThrottlingPolicyConfig $t2

$listOfAppGroups = Get-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName
Assert-AreEqual $listOfAppGroups.Count 4

Remove-AzEventHubApplicationGroup -ResourceGroup $resourceGroupName -NamespaceName $namespaceName -Name $appGroupName

$listOfAppGroups = Get-AzEventHubApplicationGroup -ResourceId $result.Id
Assert-AreEqual $listOfAppGroups.Count 3

Remove-AzEventHubApplicationGroup -ResourceId $appGroup2.Id
Get-AzEventHubApplicationGroup -ResourceId $appGroup3.Id | Remove-AzEventHubApplicationGroup
Remove-AzEventHubApplicationGroup -InputObject $appGroup4

Start-Sleep -Seconds 10

$listOfAppGroups = Get-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName
Assert-AreEqual $listOfAppGroups.Count 0
}

finally{
Write-Debug " Delete resourcegroup"
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}
34 changes: 34 additions & 0 deletions src/EventHub/EventHub.Test/ScenarioTests/PaginationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.EventHub.Test.ScenarioTests
{
public class PaginationTests : EventHubTestRunner
{

public PaginationTests(Xunit.Abstractions.ITestOutputHelper output)
: base(output)
{
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ApplicationGroupPaginationTests()
{
TestRunner.RunTestScript("ApplicationGroupPagination");
}
}
}
41 changes: 41 additions & 0 deletions src/EventHub/EventHub.Test/ScenarioTests/PaginationTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Tests pagination of various resources
#>

function ApplicationGroupPagination{
# Max allowed application groups in a namespace is 100
# Pagination does not really come into picture
# But for any list call that gives a ListNext function we have to take pagination into account in the code
# This is because if tommorrow, the server allows more than 100 app groups
# We do not need any effort here to keep the code updated

$resourceGroupName = "ps-testing"
$namespaceName = "ps-pagination-testing"

$listOfAppGroups = Get-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName
Assert-AreEqual 100 $listOfAppGroups.Count

$namespaceId = Get-AzEventHubNamespace -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName

$listOfAppGroups = Get-AzEventHubApplicationGroup -ResourceId $namespaceId.Id
Assert-AreEqual 100 $listOfAppGroups.Count

$t1 = New-AzEventHubThrottlingPolicyConfig -Name t1 -MetricId IncomingMessages -RateLimitThreshold 10000

Assert-ThrowsContains { New-AzEventHubApplicationGroup -ResourceGroupName $resourceGroupName -NamespaceName $namespaceName -Name test -ClientAppGroupIdentifier SASKeyName=test -ThrottlingPolicyConfig $t1 } "Operation returned an invalid status code 'BadRequest'"
}
Loading