-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Service Bus] Update constructors to add overloads and use Azure Identity #5436
Changes from 23 commits
2d4f970
fa13083
b7c5198
afc8689
3bcb540
99d2d57
2b00a70
1c8760a
9883ac9
ced6b23
e164436
8d8abbe
2a7868e
22c5103
115b53f
9d0597b
865b0d8
c4a2267
33ce753
a749abd
d5b3eb0
51af115
d0dcec0
e05a944
e9d9dfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,7 @@ export class BatchingReceiver extends MessageReceiver { | |
const sessionError = context.session && context.session.error; | ||
let error: Error | MessagingError; | ||
if (sessionError) { | ||
error = translate(sessionError); | ||
error = translate(sessionError) as MessagingError; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This casting is not required. Same for a few lines below. |
||
log.error( | ||
"[%s] 'session_close' event occurred for Receiver '%s' received an error:\n%O", | ||
this._context.namespace.connectionId, | ||
|
@@ -265,7 +265,7 @@ export class BatchingReceiver extends MessageReceiver { | |
const receiverError = context.receiver && context.receiver.error; | ||
let error: Error | MessagingError; | ||
if (receiverError) { | ||
error = translate(receiverError); | ||
error = translate(receiverError) as MessagingError; | ||
log.error( | ||
"[%s] Receiver '%s' received an error:\n%O", | ||
this._context.namespace.connectionId, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,7 +2,9 @@ | |||||
|
||||||
- Run `npm i` to install all the dependencies of this project. This is a one time task. | ||||||
- The tests expect a series of queues, topics and subscriptions to exist in a single Service Bus instance. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After merging the
Suggested change
|
||||||
The connection string for the service bus should be in the environment variable `SERVICEBUS_CONNECTION_STRING`. | ||||||
For Node environment, the connection string for the service bus should be in the environment variable `SERVICEBUS_CONNECTION_STRING`. | ||||||
|
||||||
For browser environment, the connection string for the service bus should be in the environment variable `SERVICEBUS_CONNECTION_STRING_BROWSER`. | ||||||
|
||||||
Note that the tests will empty the messages in these entities to get a clean start before running each test. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After merging the Similarly the sample content for the .env file should be cleaned up as well |
||||||
|
||||||
|
@@ -20,39 +22,19 @@ | |||||
unpartitioned-topic | Topic with partitions disabled, meant for testing subscriptions with sessions disabled | TOPIC_NAME_NO_PARTITION | ||||||
partitioned-topic-sessions | Topic with partitions enabled, meant for testing subscriptions with sessions enabled | TOPIC_NAME_SESSION | ||||||
unpartitioned-topic-sessions | Topic with partitions disabled, meant for testing subscriptions with sessions enabled | TOPIC_NAME_NO_PARTITION_SESSION | ||||||
partitioned-topic-subscription | Subscription with sessions disabled in the Topic, `partitioned-topic` | SUBSCRIPTION_NAME | ||||||
unpartitioned-topic-subscription | Subscription with sessions disabled in the Topic, `unpartitioned-topic` | SUBSCRIPTION_NAME_NO_PARTITION | ||||||
partitioned-topic-sessions-subscription | Subscription with sessions enabled in the Topic, `partitioned-topic-sessions` | SUBSCRIPTION_NAME_SESSION | ||||||
unpartitioned-topic-sessions-subscription | Subscription with sessions enabled in the Topic, `unpartitioned-topic-sessions` | SUBSCRIPTION_NAME_NO_PARTITION_SESSION | ||||||
partitioned-topic-subscription | Subscription with sessions disabled in the partitioned topic | SUBSCRIPTION_NAME | ||||||
unpartitioned-topic-subscription | Subscription with sessions disabled in the unpartitioned topic | SUBSCRIPTION_NAME_NO_PARTITION | ||||||
partitioned-topic-sessions-subscription | Subscription with sessions enabled in the sessions enabled partitioned topic | SUBSCRIPTION_NAME_SESSION | ||||||
unpartitioned-topic-sessions-subscription | Subscription with sessions enabled in the sessions enabled unpartitioned topic | SUBSCRIPTION_NAME_NO_PARTITION_SESSION | ||||||
topic-filter | Topic for testing topic filters | TOPIC_FILTER_NAME | ||||||
topic-filter-subscription | Subscription in the Topic `topic-filter` | TOPIC_FILTER_SUBSCRIPTION_NAME | ||||||
topic-filter-default-subscription | Subscription in the Topic `topic-filter` | TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME | ||||||
|
||||||
Following are additional environment variables that will need to be defined in order to be able to run the tests in browser | ||||||
|
||||||
Entitiy Name | Entity Description | Environment Variable if not using default names | ||||||
------------- | ------------------|---------- | ||||||
partitioned-queue-browser | Queue with partitions enabled and sessions disabled | QUEUE_NAME_BROWSER | ||||||
unpartitioned-queue-browser | Queue with partitions and sessions, both disabled | QUEUE_NAME_NO_PARTITION_BROWSER | ||||||
partitioned-queue-sessions-browser | Queue with partitions and sessions, both enabled | QUEUE_NAME_SESSION_BROWSER | ||||||
unpartitioned-queue-sessions-browser | Queue with partitions disabled and sessions enabled | QUEUE_NAME_NO_PARTITION_SESSION_BROWSER | ||||||
partitioned-topic-browser | Topic with partitions enabled, meant for testing subscriptions with sessions disabled | TOPIC_NAME_BROWSER | ||||||
unpartitioned-topic-browser | Topic with partitions disabled, meant for testing subscriptions with sessions disabled | TOPIC_NAME_NO_PARTITION_BROWSER | ||||||
partitioned-topic-sessions-browser | Topic with partitions enabled, meant for testing subscriptions with sessions enabled | TOPIC_NAME_SESSION_BROWSER | ||||||
unpartitioned-topic-sessions-browser | Topic with partitions disabled, meant for testing subscriptions with sessions enabled | TOPIC_NAME_NO_PARTITION_SESSION_BROWSER | ||||||
partitioned-topic-subscription-browser | Subscription with sessions disabled in the Topic, `partitioned-topic-browser` | SUBSCRIPTION_NAME_BROWSER | ||||||
unpartitioned-topic-subscription-browser | Subscription with sessions disabled in the Topic, `unpartitioned-topic-browser` | SUBSCRIPTION_NAME_NO_PARTITION_BROWSER | ||||||
partitioned-topic-sessions-subscription-browser | Subscription with sessions enabled in the Topic, `partitioned-topic-sessions-browser` | SUBSCRIPTION_NAME_SESSION_BROWSER | ||||||
unpartitioned-topic-sessions-subscription-browser | Subscription with sessions enabled in the Topic, `unpartitioned-topic-sessions-browser` | SUBSCRIPTION_NAME_NO_PARTITION_SESSION_BROWSER | ||||||
topic-filter-browser | Topic for testing topic filters | TOPIC_FILTER_NAME_BROWSER | ||||||
topic-filter-subscription-browser | Subscription in the Topic `topic-filter-browser` | TOPIC_FILTER_SUBSCRIPTION_NAME_BROWSER | ||||||
topic-filter-default-subscription-browser | Subscription in the Topic `topic-filter-browser` | TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME_BROWSER | ||||||
|
||||||
|
||||||
The environment variables can be set by adding a file by the name `.env` in the root folder of this project. | ||||||
Following is a sample .env file template that can be re-used for your environment: | ||||||
``` | ||||||
SERVICEBUS_CONNECTION_STRING= | ||||||
SERVICEBUS_CONNECTION_STRING_BROWSER= | ||||||
|
||||||
QUEUE_NAME=partitioned-queue | ||||||
QUEUE_NAME_NO_PARTITION=unpartitioned-queue | ||||||
|
@@ -72,30 +54,10 @@ | |||||
TOPIC_FILTER_SUBSCRIPTION_NAME=topic-filter-subscription | ||||||
TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME=topic-filter-default-subscription | ||||||
|
||||||
# Resources for use by browser tests | ||||||
QUEUE_NAME_BROWSER=partitioned-queue-browser | ||||||
QUEUE_NAME_NO_PARTITION_BROWSER=unpartitioned-queue-browser | ||||||
QUEUE_NAME_SESSION_BROWSER=partitioned-sessions-queue-browser | ||||||
QUEUE_NAME_NO_PARTITION_SESSION_BROWSER=unpartitioned-sessions-queue-browser | ||||||
|
||||||
TOPIC_NAME_BROWSER=partitioned-topic-browser | ||||||
TOPIC_NAME_NO_PARTITION_BROWSER=unpartitioned-topic-browser | ||||||
TOPIC_NAME_SESSION_BROWSER=partitioned-sessions-topic-browser | ||||||
TOPIC_NAME_NO_PARTITION_SESSION_BROWSER=unpartitioned-sessions-topic-browser | ||||||
|
||||||
SUBSCRIPTION_NAME_BROWSER=partitioned-subscription-browser | ||||||
SUBSCRIPTION_NAME_NO_PARTITION_BROWSER=unpartitioned-subscription-browser | ||||||
SUBSCRIPTION_NAME_SESSION_BROWSER=partitioned-sessions-subscription-browser | ||||||
SUBSCRIPTION_NAME_NO_PARTITION_SESSION_BROWSER=unpartitioned-sessions-subscription-browser | ||||||
|
||||||
TOPIC_FILTER_NAME_BROWSER=topic-filter-browser | ||||||
TOPIC_FILTER_SUBSCRIPTION_NAME_BROWSER=topic-subscription-browser | ||||||
TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME_BROWSER=topic-subscription-default-browser | ||||||
|
||||||
``` | ||||||
|
||||||
## Setup | ||||||
Go through the following setup in order to delete and create the required servicebus-entities(just before running each test). This would need authenticating to Service Bus using `AadTokenCredentials` instead of `ConnectionString`. The below setup is also needed to run the tests that specifically uses `AadTokenCredentials` to authenticate. | ||||||
Go through the following setup in order to delete and create the required servicebus-entities(just before running each test). This would need authenticating to Service Bus using AAD `TokenCredential` instead of `ConnectionString`. The below setup is also needed to run the tests that specifically uses AAD `TokenCredential` to authenticate. | ||||||
|
||||||
**Register a new application in AAD** | ||||||
|
||||||
|
@@ -114,31 +76,30 @@ Go through the following setup in order to delete and create the required servic | |||||
|
||||||
Populate the following variables along with the above mentioned environment variables in the `.env`. | ||||||
``` | ||||||
AAD_CLIENT_ID="" | ||||||
AAD_CLIENT_SECRET="" | ||||||
AAD_TENANT_ID="" | ||||||
AZURE_CLIENT_ID="" | ||||||
AZURE_CLIENT_SECRET="" | ||||||
AZURE_TENANT_ID="" | ||||||
``` | ||||||
|
||||||
**Note:** | ||||||
* `RESOURCE_GROUP` and `AZURE_SUBSCRIPTION_ID` can be found at your servicebus-namespace in the azure-portal. | ||||||
|
||||||
_By default the deletion/creation of the required servicebus-entities(for each test) will take place in order to not reuse resources across testcases._ | ||||||
|
||||||
## Run all tests | ||||||
|
||||||
Run `npm run unit` from your terminal to run all the tests under the `./test` folder | ||||||
Run `npm run test:node` or `npm run test:browser` from your terminal to run all the tests under the `./test` folder | ||||||
|
||||||
## Run all tests in a single test suite | ||||||
|
||||||
Append the `.only` on the `describe` method corresponding to the test suite. | ||||||
|
||||||
Then run `npm run unit` from your terminal. | ||||||
Then run `npm run test:node` or `npm run test:browser` from your terminal. | ||||||
|
||||||
## Run a single test | ||||||
|
||||||
Append the `.only` on the `it` method corresponding to the test. | ||||||
|
||||||
Then run `npm run unit` from your terminal. | ||||||
Then run `npm run test:node` or `npm run test:browser` from your terminal. | ||||||
|
||||||
## Debug tests using Visual Studio Code | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that aadutils.ts file is deleted, we don't need
@azure/ms-rest-nodeauth
in tests either right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, updated