Skip to content

Commit

Permalink
pr-add: az service bus namespace to deployment component
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnmoreels committed Dec 20, 2024
1 parent adc7467 commit 7d6075b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 7 deletions.
1 change: 1 addition & 0 deletions build/deploy-test-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ stages:
--parameters cosmosDb_mongoDb_databaseName=${{ variables['Arcus.Testing.Cosmos.MongoDb.DatabaseName'] }} `
--parameters cosmosDb_noSql_name=${{ variables['Arcus.Testing.Cosmos.NoSql.Name'] }} `
--parameters cosmosDb_noSql_databaseName=${{ variables['Arcus.Testing.Cosmos.NoSql.DatabaseName'] }} `
--parameters serviceBusNamespaceName=${{ variables['Arcus.Testing.ServiceBus.Namespace'] }} `
--parameters keyVaultName=${{ parameters.keyVaultName }} `
--parameters servicePrincipal_objectId=$objectId
Expand Down
40 changes: 34 additions & 6 deletions build/templates/smoke-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Describe 'Storage account' {
-DatabaseName $env:ARCUS_TESTING_COSMOS_MONGODB_DATABASENAME `
-Name $collectionName
}
catch {
finally {
Remove-AzCosmosDBMongoDBCollection `
-ResourceGroupName $env:ARCUS_TESTING_RESOURCEGROUP_NAME `
-AccountName $env:ARCUS_TESTING_COSMOS_MONGODB_NAME `
Expand All @@ -46,12 +46,40 @@ Describe 'Storage account' {
-Name $containerName `
-PartitionKeyPath '/pk'
}
catch {
finally {
Remove-AzCosmosDBSqlContainer `
-ResourceGroupName $env:ARCUS_TESTING_RESOURCEGROUP_NAME `
-AccountName $env:ARCUS_TESTING_COSMOS_NOSQL_NAME `
-DatabaseName $env:ARCUS_TESTING_COSMOS_NOSQL_DATABASENAME `
-Name $containerName
-ResourceGroupName $env:ARCUS_TESTING_RESOURCEGROUP_NAME `
-AccountName $env:ARCUS_TESTING_COSMOS_NOSQL_NAME `
-DatabaseName $env:ARCUS_TESTING_COSMOS_NOSQL_DATABASENAME `
-Name $containerName
}
}
It "Service principal can create Service bus queue" {
$queueName = 'test-queue'
try {
New-AzServiceBusQueue `
-ResourceGroupName $env:ARCUS_TESTING_RESOURCEGROUP_NAME `
-NamespaceName $env:ARCUS_TESTING_SERVICEBUS_NAMESPACE `
-Name $queueName
} finally {
Remove-AzServiceBusQueue `
-ResourceGroupName $env:ARCUS_TESTING_RESOURCEGROUP_NAME `
-NamespaceName $env:ARCUS_TESTING_SERVICEBUS_NAMESPACE `
-Name $queueName
}
}
It "Service principal can create Service bus topic" {
$topicName = 'test-topic'
try {
New-AzServiceBusTopic `
-ResourceGroupName $env:ARCUS_TESTING_RESOURCEGROUP_NAME `
-NamespaceName $env:ARCUS_TESTING_SERVICEBUS_NAMESPACE `
-Name $topicName
} finally {
Remove-AzServiceBusTopic `
-ResourceGroupName $env:ARCUS_TESTING_RESOURCEGROUP_NAME `
-NamespaceName $env:ARCUS_TESTING_SERVICEBUS_NAMESPACE `
-Name $topicName
}
}
}
22 changes: 22 additions & 0 deletions build/templates/test-resources.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ param cosmosDb_noSql_name string
// Define the name of the CosmosDb NoSql database that will be created.
param cosmosDb_noSql_databaseName string

// Define the name of the Service bus namespace resource that will be created.
param serviceBusNamespaceName string

// Define the name of the key vault where the necessary secrets will be stored to access the deployed test resources.
param keyVaultName string

Expand Down Expand Up @@ -125,6 +128,25 @@ module cosmosDb_noSql 'br/public:avm/res/document-db/database-account:0.6.0' = {
}
}

module serviceBusNamespace 'br/public:avm/res/service-bus/namespace:0.10.1' = {
name: 'serviceBusNamespaceDeployment'
params: {
name: serviceBusNamespaceName
location: location
enableTelemetry: false
publicNetworkAccess: 'Enabled'
skuObject: {
name: 'Standard'
}
roleAssignments: [
{
principalId: servicePrincipal_objectId
roleDefinitionIdOrName: 'Azure Service Bus Data Owner'
}
]
}
}

module vault 'br/public:avm/res/key-vault/vault:0.6.1' = {
name: 'vaultDeployment'
params: {
Expand Down
2 changes: 1 addition & 1 deletion build/variables/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ variables:
Arcus.Testing.Cosmos.NoSql.Name: 'arcus-testing-cosmos-nosql'
Arcus.Testing.Cosmos.NoSql.DatabaseName: 'arcus-testing-cosmos-nosql-db'
Arcus.Testing.KeyVault.Name: 'arcus-testing-kv'
Arcus.Testing.ServiceBus.Namespace: 'arcus-messaging-servicebus'
Arcus.Testing.ServiceBus.Namespace: 'arcus-testing-servicebus'
Arcus.Testing.StorageAccount.Name: 'arcustestingstorage'
Arcus.Testing.StorageAccount.Key.SecretName: 'Arcus-Testing-StorageAccount-Key'

0 comments on commit 7d6075b

Please sign in to comment.