зеркало из https://github.com/Azure/benchpress.git
add event hub confirm resource examples
This commit is contained in:
Родитель
930d150fe3
Коммит
ea8186149e
|
@ -197,7 +197,7 @@ function Get-ResourceByType {
|
||||||
return Confirm-EventHubConsumerGroup @params
|
return Confirm-EventHubConsumerGroup @params
|
||||||
}
|
}
|
||||||
"EventHubNamespace" {
|
"EventHubNamespace" {
|
||||||
return Confirm-EventHubNamespace -NamespaceName $NamespaceName -ResourceGroupName $ResourceGroupName
|
return Confirm-EventHubNamespace -NamespaceName $ResourceName -ResourceGroupName $ResourceGroupName
|
||||||
}
|
}
|
||||||
"KeyVault" {
|
"KeyVault" {
|
||||||
return Confirm-KeyVault -Name $ResourceName -ResourceGroupName $ResourceGroupName
|
return Confirm-KeyVault -Name $ResourceName -ResourceGroupName $ResourceGroupName
|
||||||
|
|
|
@ -1,14 +1,57 @@
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
Import-Module Az.InfrastructureTesting
|
Import-Module Az.InfrastructureTesting
|
||||||
|
|
||||||
|
$Script:rgName = 'rg-test'
|
||||||
|
$Script:nameSpace = 'eventhubnamespace'
|
||||||
|
$Script:eventHubName = 'eventhub'
|
||||||
|
$Script:location = 'westus3'
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe 'Verify EventHub' {
|
Describe 'Verify EventHub' {
|
||||||
|
BeforeAll {
|
||||||
|
$Script:noEventHub = 'noeventhub'
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'Should contain an eventhub with the given name - Confirm-AzBPResource' {
|
||||||
|
#arrange
|
||||||
|
$params = @{
|
||||||
|
ResourceType = "EventHub"
|
||||||
|
ResourceGroupName = $rgName
|
||||||
|
ResourceName = $eventHubName
|
||||||
|
NamespaceName = $nameSpace
|
||||||
|
}
|
||||||
|
|
||||||
|
#act
|
||||||
|
$result = Confirm-AzBPResource @params
|
||||||
|
|
||||||
|
#assert
|
||||||
|
$result.Success | Should -Be $true
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'Should contain an eventhub with the expected property name - Confirm-AzBPResource' {
|
||||||
|
#arrange
|
||||||
|
$params = @{
|
||||||
|
ResourceType = "EventHub"
|
||||||
|
ResourceGroupName = $rgName
|
||||||
|
ResourceName = $eventHubName
|
||||||
|
NamespaceName = $nameSpace
|
||||||
|
PropertyKey = 'Name'
|
||||||
|
PropertyValue = $eventHubName
|
||||||
|
}
|
||||||
|
|
||||||
|
#act
|
||||||
|
$result = Confirm-AzBPResource @params
|
||||||
|
|
||||||
|
#assert
|
||||||
|
$result.Success | Should -Be $true
|
||||||
|
}
|
||||||
|
|
||||||
it 'Should contain an eventhub with the given name' {
|
it 'Should contain an eventhub with the given name' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
Name = 'eventhubtest'
|
Name = $eventHubName
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
|
@ -21,9 +64,9 @@ Describe 'Verify EventHub' {
|
||||||
it 'Should not contain an eventhub with the given name' {
|
it 'Should not contain an eventhub with the given name' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
Name = 'eventhubtest2'
|
Name = $noEventHub
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
|
@ -39,9 +82,9 @@ Describe 'Verify EventHub' {
|
||||||
it 'Should contain an EventHub named eventhubtest' {
|
it 'Should contain an EventHub named eventhubtest' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
Name = 'eventhubtest'
|
Name = $eventHubName
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
|
@ -54,39 +97,75 @@ Describe 'Verify EventHub' {
|
||||||
it 'Should contain an EventHub named eventhubtest in westus3' {
|
it 'Should contain an EventHub named eventhubtest in westus3' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
Name = 'eventhubtest'
|
Name = $eventHubName
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
$result = Confirm-AzBPEventHub @params
|
$result = Confirm-AzBPEventHub @params
|
||||||
|
|
||||||
#assert
|
#assert
|
||||||
$result | Should -BeInLocation 'westus3'
|
$result | Should -BeInLocation $location
|
||||||
}
|
}
|
||||||
|
|
||||||
it 'Should be in a resource group named rg-test' {
|
it 'Should be in a resource group named $rgName' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
Name = 'eventhubtest'
|
Name = $eventHubName
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
$result = Confirm-AzBPEventHub @params
|
$result = Confirm-AzBPEventHub @params
|
||||||
|
|
||||||
#assert
|
#assert
|
||||||
$result | Should -BeInResourceGroup 'rg-test'
|
$result | Should -BeInResourceGroup $rgName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe 'Verify EventHub Namespace' {
|
Describe 'Verify EventHub Namespace' {
|
||||||
|
BeforeAll {
|
||||||
|
$Script:noNameSpace = 'nosamplenamespace'
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'Should contain an eventhub namespace with the given name - Confirm-AzBPResource' {
|
||||||
|
#arrange
|
||||||
|
$params = @{
|
||||||
|
ResourceType = "EventHubNamespace"
|
||||||
|
ResourceGroupName = $rgName
|
||||||
|
ResourceName = $nameSpace
|
||||||
|
}
|
||||||
|
|
||||||
|
#act
|
||||||
|
$result = Confirm-AzBPResource @params
|
||||||
|
|
||||||
|
#assert
|
||||||
|
$result.Success | Should -Be $true
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'Should contain an eventhub namespace with the expected property name - Confirm-AzBPResource' {
|
||||||
|
#arrange
|
||||||
|
$params = @{
|
||||||
|
ResourceType = "EventHubNamespace"
|
||||||
|
ResourceGroupName = $rgName
|
||||||
|
ResourceName = $nameSpace
|
||||||
|
PropertyKey = 'Name'
|
||||||
|
PropertyValue = $nameSpace
|
||||||
|
}
|
||||||
|
|
||||||
|
#act
|
||||||
|
$result = Confirm-AzBPResource @params
|
||||||
|
|
||||||
|
#assert
|
||||||
|
$result.Success | Should -Be $true
|
||||||
|
}
|
||||||
|
|
||||||
it 'Should contain an eventhub namespace with the given name' {
|
it 'Should contain an eventhub namespace with the given name' {
|
||||||
#arrange
|
#arrange
|
||||||
$rgName = 'rg-test'
|
$rgName = $rgName
|
||||||
$namespaceName = 'samplenamespace'
|
$namespaceName = $nameSpace
|
||||||
|
|
||||||
#act
|
#act
|
||||||
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
|
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
|
||||||
|
@ -97,8 +176,8 @@ Describe 'Verify EventHub Namespace' {
|
||||||
|
|
||||||
it 'Should not contain an eventhub namespace with the given name' {
|
it 'Should not contain an eventhub namespace with the given name' {
|
||||||
#arrange
|
#arrange
|
||||||
$rgName = 'rg-test'
|
$rgName = $rgName
|
||||||
$namespaceName = 'samplenamespace2'
|
$namespaceName = $noNameSpace
|
||||||
|
|
||||||
#act
|
#act
|
||||||
# The '-ErrorAction SilentlyContinue' command suppresses all errors.
|
# The '-ErrorAction SilentlyContinue' command suppresses all errors.
|
||||||
|
@ -112,8 +191,8 @@ Describe 'Verify EventHub Namespace' {
|
||||||
|
|
||||||
it 'Should contain an EventHub Namespace named samplenamespace' {
|
it 'Should contain an EventHub Namespace named samplenamespace' {
|
||||||
#arrange
|
#arrange
|
||||||
$rgName = 'rg-test'
|
$rgName = $rgName
|
||||||
$namespaceName = 'samplenamespace'
|
$namespaceName = $nameSpace
|
||||||
|
|
||||||
#act
|
#act
|
||||||
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
|
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
|
||||||
|
@ -124,37 +203,78 @@ Describe 'Verify EventHub Namespace' {
|
||||||
|
|
||||||
it 'Should contain an EventHub Namespace named samplenamespace in westus3' {
|
it 'Should contain an EventHub Namespace named samplenamespace in westus3' {
|
||||||
#arrange
|
#arrange
|
||||||
$rgName = 'rg-test'
|
$rgName = $rgName
|
||||||
$namespaceName = 'samplenamespace'
|
$namespaceName = $nameSpace
|
||||||
|
|
||||||
#act
|
#act
|
||||||
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
|
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
|
||||||
|
|
||||||
#assert
|
#assert
|
||||||
$result | Should -BeInLocation 'westus3'
|
$result | Should -BeInLocation $location
|
||||||
}
|
}
|
||||||
|
|
||||||
it 'Should be in a resource group named rg-test' {
|
it 'Should be in a resource group named $rgName' {
|
||||||
#arrange
|
#arrange
|
||||||
$rgName = 'rg-test'
|
$rgName = $rgName
|
||||||
$namespaceName = 'samplenamespace'
|
$namespaceName = $nameSpace
|
||||||
|
|
||||||
#act
|
#act
|
||||||
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
|
$result = Confirm-AzBPEventHubNamespace -NamespaceName $namespaceName -ResourceGroupName $rgName
|
||||||
|
|
||||||
#assert
|
#assert
|
||||||
$result | Should -BeInResourceGroup 'rg-test'
|
$result | Should -BeInResourceGroup $rgName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe 'Verify EventHub Consumer Group' {
|
Describe 'Verify EventHub Consumer Group' {
|
||||||
|
BeforeAll {
|
||||||
|
$Script:consumerGroup = 'eventhubconsumergroup'
|
||||||
|
$Script:noConsumerGroup = 'noeventhubconsumergroup'
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'Should contain an eventhub consumer group with the given name - Confirm-AzBPResource' {
|
||||||
|
#arrange
|
||||||
|
$params = @{
|
||||||
|
ResourceType = "EventHubConsumerGroup"
|
||||||
|
ResourceGroupName = $rgName
|
||||||
|
ResourceName = $consumerGroup
|
||||||
|
NamespaceName = $nameSpace
|
||||||
|
EventHubName = $eventHubName
|
||||||
|
}
|
||||||
|
|
||||||
|
#act
|
||||||
|
$result = Confirm-AzBPResource @params
|
||||||
|
|
||||||
|
#assert
|
||||||
|
$result.Success | Should -Be $true
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'Should contain an eventhub consumer group with the expected property name - Confirm-AzBPResource' {
|
||||||
|
#arrange
|
||||||
|
$params = @{
|
||||||
|
ResourceType = "EventHubConsumerGroup"
|
||||||
|
ResourceGroupName = $rgName
|
||||||
|
ResourceName = $consumerGroup
|
||||||
|
NamespaceName = $nameSpace
|
||||||
|
EventHubName = $eventHubName
|
||||||
|
PropertyKey = 'Name'
|
||||||
|
PropertyValue = $consumerGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
#act
|
||||||
|
$result = Confirm-AzBPResource @params
|
||||||
|
|
||||||
|
#assert
|
||||||
|
$result.Success | Should -Be $true
|
||||||
|
}
|
||||||
|
|
||||||
it 'Should contain an eventhub consumer group with the given name' {
|
it 'Should contain an eventhub consumer group with the given name' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
EventHubName = 'eventhubtest'
|
EventHubName = $eventHubName
|
||||||
Name = 'eventhubconsumergrouptest'
|
Name = $consumerGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
|
@ -167,10 +287,10 @@ Describe 'Verify EventHub Consumer Group' {
|
||||||
it 'Should not contain an eventhub consumer group with the given name' {
|
it 'Should not contain an eventhub consumer group with the given name' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
EventHubName = 'eventhubtest'
|
EventHubName = $eventHubName
|
||||||
Name = 'eventhubconsumergrouptest2'
|
Name = $noConsumerGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
|
@ -186,10 +306,10 @@ Describe 'Verify EventHub Consumer Group' {
|
||||||
it 'Should contain an EventHub consumer group named consumergrouptest' {
|
it 'Should contain an EventHub consumer group named consumergrouptest' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
EventHubName = 'eventhubtest'
|
EventHubName = $eventHubName
|
||||||
Name = 'eventhubconsumergrouptest'
|
Name = $consumerGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
|
@ -202,32 +322,32 @@ Describe 'Verify EventHub Consumer Group' {
|
||||||
it 'Should contain an EventHub consumer group named consumergrouptest in westus3' {
|
it 'Should contain an EventHub consumer group named consumergrouptest in westus3' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
EventHubName = 'eventhubtest'
|
EventHubName = $eventHubName
|
||||||
Name = 'eventhubconsumergrouptest'
|
Name = $consumerGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
$result = Confirm-AzBPEventHubConsumerGroup @params
|
$result = Confirm-AzBPEventHubConsumerGroup @params
|
||||||
|
|
||||||
#assert
|
#assert
|
||||||
$result | Should -BeInLocation 'westus3'
|
$result | Should -BeInLocation $location
|
||||||
}
|
}
|
||||||
|
|
||||||
it 'Should be in a resource group named rg-test' {
|
it 'Should be in a resource group named $rgName' {
|
||||||
#arrange
|
#arrange
|
||||||
$params = @{
|
$params = @{
|
||||||
ResourceGroupName = 'rg-test'
|
ResourceGroupName = $rgName
|
||||||
NamespaceName = 'samplenamespace'
|
NamespaceName = $nameSpace
|
||||||
EventHubName = 'eventhubtest'
|
EventHubName = $eventHubName
|
||||||
Name = 'eventhubconsumergrouptest'
|
Name = $consumerGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
#act
|
#act
|
||||||
$result = Confirm-AzBPEventHubConsumerGroup @params
|
$result = Confirm-AzBPEventHubConsumerGroup @params
|
||||||
|
|
||||||
#assert
|
#assert
|
||||||
$result | Should -BeInResourceGroup 'rg-test'
|
$result | Should -BeInResourceGroup $rgName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ and `Confirm-AzBPEventHubNamespace` cmdlet.
|
||||||
1. Update `EventHub.Tests.ps1` variables to point to your expected resources:
|
1. Update `EventHub.Tests.ps1` variables to point to your expected resources:
|
||||||
|
|
||||||
- `rg-test` -> `your-resource-group-name`
|
- `rg-test` -> `your-resource-group-name`
|
||||||
- `eventhubtest` -> `your-eventhub-name`
|
- `eventhub` -> `your-eventhub-name`
|
||||||
- `samplenamespace` -> `your-eventhub-namespace-name`
|
- `eventhubamespace` -> `your-eventhub-namespace-name`
|
||||||
- `eventhubconsumergrouptest` -> `your-eventhub-consumer-group-name`
|
- `eventhubconsumergroup` -> `your-eventhub-consumer-group-name`
|
||||||
|
|
||||||
1. If using a local copy of `Az.InfrastructureTesting`, replace `Import-Module Az.InfrastructureTesting` with
|
1. If using a local copy of `Az.InfrastructureTesting`, replace `Import-Module Az.InfrastructureTesting` with
|
||||||
`Import-Module "../../bin/BenchPress.Azure.psd1"`.
|
`Import-Module "../../bin/BenchPress.Azure.psd1"`.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче