Skip to content

Commit

Permalink
Clean up README file for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramya Raja committed Jan 15, 2020
1 parent d5b3eb0 commit 51af115
Showing 1 changed file with 15 additions and 54 deletions.
69 changes: 15 additions & 54 deletions sdk/servicebus/service-bus/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.

Expand All @@ -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
Expand All @@ -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**
Expand All @@ -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
Expand Down

0 comments on commit 51af115

Please sign in to comment.