-
Notifications
You must be signed in to change notification settings - Fork 548
feat(pubsub/azure/servicebus/queues): add certification tests #4150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jmfloreszazo
wants to merge
9
commits into
dapr:main
Choose a base branch
from
jmfloreszazo:test/asb-queues-certification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,719
−0
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a98d53c
feat: add Azure Service Bus Queues certification tests and components
jmfloreszazo 738b380
test: enhance Azure Service Bus Queues certification tests with messa…
jmfloreszazo 8c81481
Adds wait time for sidecar readiness
jmfloreszazo b723960
docs: update README for Azure Service Bus Queues certification tests …
jmfloreszazo 3f00e57
test: use unique queue names in reconnection and minimal messages tes…
jmfloreszazo 314a191
test: enhance README with detailed steps for reconnection and empty m…
jmfloreszazo 743f733
Adds GPG key for secure verification
jmfloreszazo d6a719e
remove: delete unused GPG key file
jmfloreszazo 329a596
Merge branch 'main' into test/asb-queues-certification
jmfloreszazo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
206 changes: 206 additions & 0 deletions
206
tests/certification/pubsub/azure/servicebus/queues/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,206 @@ | ||
| # Azure Service Bus Queues Pubsub Certification | ||
|
|
||
| The purpose of this module is to provide tests that certify the Azure Service Bus Queues Pubsub as a stable component. | ||
|
|
||
| ## Important: Queue vs Topic Semantics | ||
|
|
||
| Unlike topics (publish-subscribe), queues use **competing consumer** semantics: | ||
| - Each message is delivered to **only ONE** consumer | ||
| - Multiple subscribers compete for messages (load balancing) | ||
| - Messages are NOT broadcast to all subscribers | ||
|
|
||
| ## Test Plan | ||
|
|
||
| ### Certification Tests | ||
|
|
||
| 1. **TestServicebusQueues** - Basic pub/sub functionality | ||
| - Run dapr application with 1 publisher and 2 subscribers | ||
| - Publisher publishes to 1 queue | ||
| - Both subscribers compete for messages (each message goes to only ONE subscriber) | ||
| - Verify that all expected messages were received (distributed among consumers) | ||
|
|
||
| 2. **TestServicebusQueuesMultipleSubsSameApp** - Multiple subscriptions in same app | ||
| - Run dapr application with 1 publisher and 1 subscriber app with multiple handlers | ||
| - Publisher publishes to 2 queues | ||
| - Verify messages are received on correct queues | ||
|
|
||
| 3. **TestServicebusQueuesNonexistingQueue** - Auto-creation of queues | ||
| - Run dapr application with 1 publisher and 1 subscriber | ||
| - Verify the creation of queue on first publish | ||
| - Send messages to the queue created | ||
| - Verify that subscriber received all the messages | ||
|
|
||
| 4. **TestServicebusQueuesNetworkInterruption** - Network resilience | ||
| - Run dapr application with 1 publisher and 1 subscriber | ||
| - Publisher publishes to 1 queue | ||
| - Simulate network interruptions using tc (traffic control) | ||
| - Verify that the component recovers and all messages are received | ||
| - **Note**: Requires root/sudo privileges | ||
|
|
||
| 5. **TestServicebusQueuesEntityManagement** - Disabled entity management | ||
| - Run dapr application with 1 publisher | ||
| - Publisher tries to publish to a queue that does not exist | ||
| - Verify that the queue does NOT get auto-created | ||
| - Verify that an error is returned | ||
|
|
||
| 6. **TestServicebusQueuesDefaultTtl** - Message TTL (Time-To-Live) | ||
| - Run dapr application with 1 publisher and 1 subscriber | ||
| - Publisher publishes to 1 queue, wait for TTL to expire | ||
| - Verify the message is deleted/expired before subscriber starts | ||
|
|
||
| 7. **TestServicebusQueuesAuthentication** - Azure AD authentication | ||
| - Run dapr application with 1 publisher and 1 subscriber | ||
| - Uses Service Principal authentication instead of connection string | ||
| - Publisher publishes to 1 queue | ||
| - Verify that all expected messages were received | ||
|
|
||
| 8. **TestServicebusQueuesMessageMetadata** - Message metadata handling | ||
| - Verify that custom metadata (partition key) is correctly passed | ||
|
|
||
| 9. **TestServicebusQueuesMultipleQueues** - Multiple queues | ||
| - Verify publishing to multiple queues simultaneously | ||
|
|
||
| 10. **TestServicebusQueuesLargeMessages** - Large message payloads | ||
| - Verify handling of larger message payloads (1KB+) | ||
|
|
||
| 11. **TestServicebusQueuesSequentialPublish** - Sequential batches | ||
| - Verify multiple sequential batch publishes | ||
|
|
||
| 12. **TestServicebusQueuesReconnection** - Sidecar restart recovery | ||
| - Run dapr application with 1 publisher and 1 subscriber | ||
| - Publish initial messages and verify receipt | ||
| - Stop and restart the sidecar | ||
| - Publish new messages after reconnection | ||
| - Verify component reconnects and new messages are received | ||
| - Uses unique queue per test run to avoid interference | ||
|
|
||
| 13. **TestServicebusQueuesEmptyMessages** - Minimal messages | ||
| - Verify handling of minimal/edge-case message payloads | ||
| - Uses unique queue per test run to avoid interference | ||
|
|
||
| 14. **TestServicebusQueuesConcurrentPublishers** - Multiple publishers | ||
| - Verify multiple sidecars publishing to the same queue | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| ### Azure Resources | ||
| - Azure Service Bus namespace (Standard or Premium tier) | ||
| - Queues will be auto-created by tests (unless testing disabled entity management) | ||
|
|
||
| ### Required Queues | ||
| The following queues should exist or will be auto-created: | ||
| - `certification-pubsub-queue-active` | ||
| - `certification-pubsub-queue-passive` | ||
| - `certification-queue-per-test-run` | ||
|
|
||
| **Note**: Some tests (Reconnection, EmptyMessages, EntityManagement) create unique queues with UUID suffixes to avoid interference between test runs. | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| ### Required for Basic Tests (Connection String Authentication) | ||
|
|
||
| ```bash | ||
| # Azure Service Bus connection string (from Azure Portal > Service Bus > Shared access policies) | ||
| export AzureServiceBusConnectionString="Endpoint=sb://<namespace>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<key>" | ||
| ``` | ||
|
|
||
| ### Required for Authentication Test (Service Principal / Azure AD) | ||
|
|
||
| ```bash | ||
| # Service Bus namespace (full FQDN) | ||
| export AzureServiceBusNamespace="<namespace>.servicebus.windows.net" | ||
|
|
||
| # Azure AD Tenant ID | ||
| export AzureCertificationTenantId="<tenant-id>" | ||
|
|
||
| # Service Principal Client ID (App ID) | ||
| export AzureCertificationServicePrincipalClientId="<client-id>" | ||
|
|
||
| # Service Principal Client Secret | ||
| export AzureCertificationServicePrincipalClientSecret="<client-secret>" | ||
| ``` | ||
|
|
||
| ### Creating a Service Principal for Authentication Test | ||
|
|
||
| ```bash | ||
| # Create Service Principal with Contributor role on the Service Bus namespace | ||
| az ad sp create-for-rbac --name "dapr-cert-sp" \ | ||
| --role Contributor \ | ||
| --scopes /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ServiceBus/namespaces/<namespace> \ | ||
| -o json | ||
|
|
||
| # IMPORTANT: Also assign the Data Owner role for sending/receiving messages | ||
| az role assignment create \ | ||
| --assignee "<service-principal-client-id>" \ | ||
| --role "Azure Service Bus Data Owner" \ | ||
| --scope "/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ServiceBus/namespaces/<namespace>" | ||
| ``` | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ### Run All Tests | ||
| ```bash | ||
| # Set environment variables first | ||
| export AzureServiceBusConnectionString="..." | ||
|
|
||
| cd tests/certification/pubsub/azure/servicebus/queues | ||
| go test -v -timeout 30m | ||
| ``` | ||
|
|
||
| ### Run Specific Test | ||
| ```bash | ||
| go test -v -timeout 5m -run "TestServicebusQueues$" | ||
| go test -v -timeout 5m -run "TestServicebusQueuesMultipleSubsSameApp$" | ||
| go test -v -timeout 5m -run "TestServicebusQueuesAuthentication$" | ||
| ``` | ||
|
|
||
| ### Run Network Interruption Test (requires sudo) | ||
| ```bash | ||
| # Clean any residual tc rules first | ||
| sudo tc qdisc del dev eth0 root 2>/dev/null || true | ||
|
|
||
| # Run the test with sudo | ||
| sudo -E go test -v -timeout 5m -run "TestServicebusQueuesNetworkInterruption$" | ||
| ``` | ||
|
|
||
| ### Run All Tests with All Variables | ||
| ```bash | ||
| export AzureServiceBusConnectionString="Endpoint=sb://<namespace>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<key>" | ||
| export AzureServiceBusNamespace="<namespace>.servicebus.windows.net" | ||
| export AzureCertificationTenantId="<tenant-id>" | ||
| export AzureCertificationServicePrincipalClientId="<client-id>" | ||
| export AzureCertificationServicePrincipalClientSecret="<client-secret>" | ||
|
|
||
| go test -v -timeout 30m | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### "pubsub messagebus is not found" | ||
| - Check that environment variables are set correctly | ||
| - Verify the connection string format is correct | ||
|
|
||
| ### Network Interruption Test Fails with "packet rules already setup" | ||
| ```bash | ||
| # Clean residual tc rules | ||
| sudo tc qdisc del dev eth0 root | ||
| ``` | ||
|
|
||
| ### Authentication Test Times Out | ||
| - Ensure the Service Principal has the "Azure Service Bus Data Owner" role | ||
| - Wait a few minutes after role assignment for propagation | ||
| - The namespace name must be the full FQDN (e.g., `myns.servicebus.windows.net`) | ||
|
|
||
| ### Tests Hang or Timeout | ||
| - Check Azure Service Bus connectivity | ||
| - Verify the namespace is accessible from your network | ||
| - Check for any firewall rules blocking ports 5671/5672 (AMQP) | ||
|
|
||
| ### Tests Fail with "elements differ" or Unexpected Messages | ||
| - Some tests use shared queues that may have residual messages from previous runs | ||
| - Wait a few minutes for messages to expire or manually purge the queue | ||
| - Tests like Reconnection and EmptyMessages use unique queues to avoid this issue | ||
|
|
||
| ### Entity Management Test Fails | ||
| - Ensure the queue name used doesn't already exist in the namespace | ||
| - The test uses a unique UUID-based queue name to avoid conflicts |
9 changes: 9 additions & 0 deletions
9
.../certification/pubsub/azure/servicebus/queues/components/authentication/localsecrets.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: envvar-secret-store | ||
| namespace: default | ||
| spec: | ||
| type: secretstores.local.env | ||
| version: v1 | ||
| metadata: |
27 changes: 27 additions & 0 deletions
27
...s/certification/pubsub/azure/servicebus/queues/components/authentication/service_bus.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: messagebus | ||
| namespace: default | ||
| spec: | ||
| type: pubsub.azure.servicebus.queues | ||
| version: v1 | ||
| metadata: | ||
| - name: namespaceName | ||
| secretKeyRef: | ||
| name: AzureServiceBusNamespace | ||
| key: AzureServiceBusNamespace | ||
| - name: azureTenantId | ||
| secretKeyRef: | ||
| name: AzureCertificationTenantId | ||
| key: AzureCertificationTenantId | ||
| - name: azureClientId | ||
| secretKeyRef: | ||
| name: AzureCertificationServicePrincipalClientId | ||
| key: AzureCertificationServicePrincipalClientId | ||
| - name: azureClientSecret | ||
| secretKeyRef: | ||
| name: AzureCertificationServicePrincipalClientSecret | ||
| key: AzureCertificationServicePrincipalClientSecret | ||
| auth: | ||
| secretstore: envvar-secret-store |
9 changes: 9 additions & 0 deletions
9
tests/certification/pubsub/azure/servicebus/queues/components/consumer_one/localsecrets.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: envvar-secret-store | ||
| namespace: default | ||
| spec: | ||
| type: secretstores.local.env | ||
| version: v1 | ||
| metadata: |
17 changes: 17 additions & 0 deletions
17
tests/certification/pubsub/azure/servicebus/queues/components/consumer_one/service_bus.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: messagebus | ||
| namespace: default | ||
| spec: | ||
| type: pubsub.azure.servicebus.queues | ||
| version: v1 | ||
| metadata: | ||
| - name: connectionString | ||
| secretKeyRef: | ||
| name: AzureServiceBusConnectionString | ||
| key: AzureServiceBusConnectionString | ||
| - name: disableEntityManagement | ||
| value: "false" | ||
| auth: | ||
| secretstore: envvar-secret-store |
9 changes: 9 additions & 0 deletions
9
tests/certification/pubsub/azure/servicebus/queues/components/consumer_two/localsecrets.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: envvar-secret-store | ||
| namespace: default | ||
| spec: | ||
| type: secretstores.local.env | ||
| version: v1 | ||
| metadata: |
17 changes: 17 additions & 0 deletions
17
tests/certification/pubsub/azure/servicebus/queues/components/consumer_two/service_bus.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: messagebus | ||
| namespace: default | ||
| spec: | ||
| type: pubsub.azure.servicebus.queues | ||
| version: v1 | ||
| metadata: | ||
| - name: connectionString | ||
| secretKeyRef: | ||
| name: AzureServiceBusConnectionString | ||
| key: AzureServiceBusConnectionString | ||
| - name: disableEntityManagement | ||
| value: "false" | ||
| auth: | ||
| secretstore: envvar-secret-store |
9 changes: 9 additions & 0 deletions
9
tests/certification/pubsub/azure/servicebus/queues/components/default_ttl/localsecrets.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: envvar-secret-store | ||
| namespace: default | ||
| spec: | ||
| type: secretstores.local.env | ||
| version: v1 | ||
| metadata: |
19 changes: 19 additions & 0 deletions
19
tests/certification/pubsub/azure/servicebus/queues/components/default_ttl/service_bus.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: messagebus | ||
| namespace: default | ||
| spec: | ||
| type: pubsub.azure.servicebus.queues | ||
| version: v1 | ||
| metadata: | ||
| - name: connectionString | ||
| secretKeyRef: | ||
| name: AzureServiceBusConnectionString | ||
| key: AzureServiceBusConnectionString | ||
| - name: disableEntityManagement | ||
| value: "false" | ||
| - name: ttlInSeconds | ||
| value: "10" | ||
| auth: | ||
| secretstore: envvar-secret-store |
9 changes: 9 additions & 0 deletions
9
tests/certification/pubsub/azure/servicebus/queues/components/entity_mgmt/localsecrets.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: envvar-secret-store | ||
| namespace: default | ||
| spec: | ||
| type: secretstores.local.env | ||
| version: v1 | ||
| metadata: |
17 changes: 17 additions & 0 deletions
17
tests/certification/pubsub/azure/servicebus/queues/components/entity_mgmt/service_bus.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| apiVersion: dapr.io/v1alpha1 | ||
| kind: Component | ||
| metadata: | ||
| name: messagebus | ||
| namespace: default | ||
| spec: | ||
| type: pubsub.azure.servicebus.queues | ||
| version: v1 | ||
| metadata: | ||
| - name: connectionString | ||
| secretKeyRef: | ||
| name: AzureServiceBusConnectionString | ||
| key: AzureServiceBusConnectionString | ||
| - name: disableEntityManagement | ||
| value: "true" | ||
| auth: | ||
| secretstore: envvar-secret-store |
2 changes: 2 additions & 0 deletions
2
tests/certification/pubsub/azure/servicebus/queues/config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| componentType: pubsub | ||
| componentName: azure.servicebus.queues |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.