-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Refactor node and browser tests #3017
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
798e4f2
Rename to use sbClient for instances of ServiceBusClient
5a27e6d
Refactor out loading of environment variables
741e15d
Merge branch 'master' into issue-2859
ramya0820 d217886
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-js in…
71eb034
Simplify if-else checks
360f24a
Merge branch 'issue-2859' of https://github.com/ramya0820/azure-sdk-f…
dd56447
Rename utility function to getNamespace
96b0b83
Simplify env variable access and error handling
3dc2806
Merge branch 'master' into issue-2859
ramya0820 1bd14a6
Merge branch 'master' into issue-2859
ramya0820 69e3928
Address comments
27899e9
Merge branch 'issue-2859' of https://github.com/ramya0820/azure-sdk-f…
5f00bdd
Refactor all tests
3a1c9e0
Address comments
290511b
Merge branch 'master' into issue-2859
ramya0820 0d8701d
nom -> npm
173d399
Merge fix from issue-2861 and update isNode references
b2e36a0
Revert isNode import from amqp-common
536d527
Update isNode computation
a256dfc
Update isNode check in utils and add header
2d465a0
Update reference to version usage in browser mode
34ae808
Update version usage references
6711f91
Make dependency exclusion test specific
09c7cb2
Refactor rollup test config
11abcf8
Revert changes that fix version not defined on CI
1eb1857
Minor edit to get around linter
a234736
Cleanup external module reference
ec96ec0
Make ms-rest-nodeauth external for browser
789357d
Bypass rush
7e49a35
Bypass rush
2abfef3
Revert bypassing rush
f4adf22
Merge branch 'master' into issue-2859
ramya0820 cfe3249
Add missing browser dependencies
471919b
Dedupe test:browser script content
2906726
Run only a single live test at a time
e324063
Merge branch 'master' into issue-2859
ramya0820 d3b8846
Use package.json approach
bb33fe6
Merge branch 'issue-2859' of https://github.com/ramya0820/azure-sdk-f…
6c5c53c
Skip browser tests on CI
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
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
216 changes: 216 additions & 0 deletions
216
sdk/servicebus/service-bus/test/common/environmentVariables.ts
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,216 @@ | ||
| const isNode = !!process && !!process.version && !!process.versions && !!process.versions.node; | ||
|
|
||
| export enum Constants { | ||
| SERVICEBUS_CONNECTION_STRING = "SERVICEBUS_CONNECTION_STRING", | ||
| QUEUE_NAME = "QUEUE_NAME", | ||
| QUEUE_NAME_NO_PARTITION = "QUEUE_NAME_NO_PARTITION", | ||
| QUEUE_NAME_SESSION = "QUEUE_NAME_SESSION", | ||
| QUEUE_NAME_NO_PARTITION_SESSION = "QUEUE_NAME_NO_PARTITION_SESSION", | ||
| TOPIC_NAME = "TOPIC_NAME", | ||
| TOPIC_NAME_NO_PARTITION = "TOPIC_NAME_NO_PARTITION", | ||
| TOPIC_NAME_SESSION = "TOPIC_NAME_SESSION", | ||
| TOPIC_NAME_NO_PARTITION_SESSION = "TOPIC_NAME_NO_PARTITION_SESSION", | ||
| SUBSCRIPTION_NAME = "SUBSCRIPTION_NAME", | ||
| SUBSCRIPTION_NAME_NO_PARTITION = "SUBSCRIPTION_NAME_NO_PARTITION", | ||
| SUBSCRIPTION_NAME_SESSION = "SUBSCRIPTION_NAME_SESSION", | ||
| SUBSCRIPTION_NAME_NO_PARTITION_SESSION = "SUBSCRIPTION_NAME_NO_PARTITION_SESSION", | ||
| TOPIC_FILTER_NAME = "TOPIC_FILTER_NAME", | ||
| TOPIC_FILTER_SUBSCRIPTION_NAME = "TOPIC_FILTER_SUBSCRIPTION_NAME", | ||
| TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME = "TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME", | ||
| AAD_CLIENT_ID = "AAD_CLIENT_ID", | ||
| AAD_CLIENT_SECRET = "AAD_CLIENT_SECRET", | ||
| AAD_TENANT_ID = "AAD_TENANT_ID", | ||
| RESOURCE_GROUP = "RESOURCE_GROUP", | ||
| AZURE_SUBSCRIPTION_ID = "AZURE_SUBSCRIPTION_ID", | ||
| CLEAN_NAMESPACE = "CLEAN_NAMESPACE" | ||
| } | ||
|
|
||
| export enum ErrorCode { | ||
| MISSING_ENV_VAR = "MISSING_ENV_VAR" | ||
| } | ||
|
|
||
| const ErrorMessage = { | ||
| [ErrorCode.MISSING_ENV_VAR]: (envVar: any) => | ||
| `Define ${envVar} in your environment before running integration tests.` | ||
| }; | ||
|
|
||
| function getError(errorCode: ErrorCode, options: any[]): Error { | ||
|
ramya-rao-a marked this conversation as resolved.
Outdated
|
||
| let errorMessage; | ||
|
|
||
| switch (errorCode) { | ||
| case ErrorCode.MISSING_ENV_VAR: | ||
| errorMessage = ErrorMessage[ErrorCode.MISSING_ENV_VAR](options[0]); | ||
| break; | ||
| default: | ||
| throw new Error("Invalid error code"); | ||
| } | ||
| return new Error(errorMessage); | ||
| } | ||
|
|
||
| export function getEnvVars(): { [key in Constants]: string } { | ||
| // AAD related | ||
|
|
||
| // @ts-ignore | ||
| let AAD_CLIENT_ID = isNode ? process.env.AAD_CLIENT_ID : window.__env__[Constants.AAD_CLIENT_ID]; | ||
| if (!AAD_CLIENT_ID) { | ||
| throw getError(ErrorCode.MISSING_ENV_VAR, [Constants.AAD_CLIENT_ID]); | ||
| } | ||
|
|
||
| let AAD_CLIENT_SECRET = isNode | ||
| ? process.env.AAD_CLIENT_SECRET | ||
| // @ts-ignore | ||
| : window.__env__[Constants.AAD_CLIENT_SECRET]; | ||
| if (!AAD_CLIENT_SECRET) { | ||
| throw getError(ErrorCode.MISSING_ENV_VAR, [Constants.AAD_CLIENT_SECRET]); | ||
| } | ||
|
|
||
|
|
||
| let AAD_TENANT_ID = isNode | ||
| ? process.env.AAD_TENANT_ID | ||
| // @ts-ignore | ||
| : window.__env__[Constants.AAD_TENANT_ID]; | ||
| if (!AAD_TENANT_ID) { | ||
| throw getError(ErrorCode.MISSING_ENV_VAR, [Constants.AAD_TENANT_ID]); | ||
| } | ||
|
|
||
| let AZURE_SUBSCRIPTION_ID = isNode | ||
| ? process.env.AZURE_SUBSCRIPTION_ID | ||
| // @ts-ignore | ||
| : window.__env__[Constants.AZURE_SUBSCRIPTION_ID]; | ||
| if (!AZURE_SUBSCRIPTION_ID) { | ||
| throw getError(ErrorCode.MISSING_ENV_VAR, [Constants.AZURE_SUBSCRIPTION_ID]); | ||
| } | ||
|
|
||
| let RESOURCE_GROUP = isNode | ||
| ? process.env.RESOURCE_GROUP | ||
| // @ts-ignore | ||
| : window.__env__[Constants.RESOURCE_GROUP]; | ||
| if (!RESOURCE_GROUP) { | ||
| throw getError(ErrorCode.MISSING_ENV_VAR, [Constants.RESOURCE_GROUP]); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| // Entity related | ||
|
|
||
| let SERVICEBUS_CONNECTION_STRING = isNode | ||
| ? process.env.SERVICEBUS_CONNECTION_STRING | ||
| // @ts-ignore | ||
| : window.__env__[Constants.SERVICEBUS_CONNECTION_STRING]; | ||
| if (!SERVICEBUS_CONNECTION_STRING) { | ||
| throw getError(ErrorCode.MISSING_ENV_VAR, [Constants.SERVICEBUS_CONNECTION_STRING]); | ||
| } | ||
|
|
||
| let CLEAN_NAMESPACE = isNode | ||
| ? process.env.CLEAN_NAMESPACE | ||
| // @ts-ignore | ||
| : window.__env__[Constants.CLEAN_NAMESPACE]; | ||
|
|
||
| let TOPIC_FILTER_NAME = isNode | ||
| ? process.env.TOPIC_FILTER_NAME | ||
| // @ts-ignore | ||
| : window.__env__[Constants.TOPIC_FILTER_NAME]; | ||
|
|
||
| let TOPIC_FILTER_SUBSCRIPTION_NAME = isNode | ||
| ? process.env.TOPIC_FILTER_SUBSCRIPTION_NAME | ||
| // @ts-ignore | ||
| : window.__env__[Constants.TOPIC_FILTER_SUBSCRIPTION_NAME]; | ||
|
|
||
| let TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME = isNode | ||
| ? process.env.TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME | ||
| // @ts-ignore | ||
| : window.__env__[Constants.TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME]; | ||
|
|
||
| let QUEUE_NAME = isNode | ||
| ? process.env.QUEUE_NAME | ||
| // @ts-ignore | ||
| : window.__env__[Constants.QUEUE_NAME]; | ||
|
|
||
| let TOPIC_NAME = isNode | ||
| ? process.env.TOPIC_NAME | ||
| // @ts-ignore | ||
| : window.__env__[Constants.TOPIC_NAME]; | ||
|
|
||
| let SUBSCRIPTION_NAME = isNode | ||
| ? process.env.SUBSCRIPTION_NAME | ||
| // @ts-ignore | ||
| : window.__env__[Constants.SUBSCRIPTION_NAME]; | ||
|
|
||
| let QUEUE_NAME_NO_PARTITION = isNode | ||
| ? process.env.QUEUE_NAME_NO_PARTITION | ||
| // @ts-ignore | ||
| : window.__env__[Constants.QUEUE_NAME_NO_PARTITION]; | ||
|
|
||
| let QUEUE_NAME_SESSION = isNode | ||
| ? process.env.QUEUE_NAME_SESSION | ||
| // @ts-ignore | ||
| : window.__env__[Constants.QUEUE_NAME_SESSION]; | ||
|
|
||
| let QUEUE_NAME_NO_PARTITION_SESSION = isNode | ||
| ? process.env.QUEUE_NAME_NO_PARTITION_SESSION | ||
| // @ts-ignore | ||
| : window.__env__[Constants.QUEUE_NAME_NO_PARTITION_SESSION]; | ||
|
|
||
| let TOPIC_NAME_NO_PARTITION = isNode | ||
| ? process.env.TOPIC_NAME_NO_PARTITION | ||
| // @ts-ignore | ||
| : window.__env__[Constants.TOPIC_NAME_NO_PARTITION]; | ||
|
|
||
| let TOPIC_NAME_SESSION = isNode | ||
| ? process.env.TOPIC_NAME_SESSION | ||
| // @ts-ignore | ||
| : window.__env__[Constants.TOPIC_NAME_SESSION]; | ||
|
|
||
| let TOPIC_NAME_NO_PARTITION_SESSION = isNode | ||
| ? process.env.TOPIC_NAME_NO_PARTITION_SESSION | ||
| // @ts-ignore | ||
| : window.__env__[Constants.TOPIC_NAME_NO_PARTITION_SESSION]; | ||
|
|
||
| let SUBSCRIPTION_NAME_NO_PARTITION = isNode | ||
| ? process.env.SUBSCRIPTION_NAME_NO_PARTITION | ||
| // @ts-ignore | ||
| : window.__env__[Constants.SUBSCRIPTION_NAME_NO_PARTITION]; | ||
|
|
||
| let SUBSCRIPTION_NAME_SESSION = isNode | ||
| ? process.env.SUBSCRIPTION_NAME_SESSION | ||
| // @ts-ignore | ||
| : window.__env__[Constants.SUBSCRIPTION_NAME_SESSION]; | ||
|
|
||
| let SUBSCRIPTION_NAME_NO_PARTITION_SESSION = isNode | ||
| ? process.env.SUBSCRIPTION_NAME_NO_PARTITION_SESSION | ||
| // @ts-ignore | ||
| : window.__env__[Constants.SUBSCRIPTION_NAME_NO_PARTITION_SESSION]; | ||
|
sadasant marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| return { | ||
| [Constants.SERVICEBUS_CONNECTION_STRING]: SERVICEBUS_CONNECTION_STRING, | ||
| [Constants.QUEUE_NAME]: QUEUE_NAME || "partitioned-queue", | ||
| [Constants.QUEUE_NAME_NO_PARTITION]: QUEUE_NAME_NO_PARTITION || "unpartitioned-queue", | ||
| [Constants.QUEUE_NAME_SESSION]: QUEUE_NAME_SESSION || "partitioned-queue-sessions", | ||
| [Constants.QUEUE_NAME_NO_PARTITION_SESSION]: | ||
| QUEUE_NAME_NO_PARTITION_SESSION || "unpartitioned-queue-sessions", | ||
| [Constants.TOPIC_NAME]: TOPIC_NAME || "partitioned-topic", | ||
| [Constants.TOPIC_NAME_NO_PARTITION]: TOPIC_NAME_NO_PARTITION || "unpartitioned-topic", | ||
| [Constants.TOPIC_NAME_SESSION]: TOPIC_NAME_SESSION || "partitioned-topic-sessions", | ||
| [Constants.TOPIC_NAME_NO_PARTITION_SESSION]: | ||
| TOPIC_NAME_NO_PARTITION_SESSION || "unpartitioned-topic-sessions", | ||
| [Constants.SUBSCRIPTION_NAME]: SUBSCRIPTION_NAME || "partitioned-topic-subscription", | ||
| [Constants.SUBSCRIPTION_NAME_NO_PARTITION]: | ||
| SUBSCRIPTION_NAME_NO_PARTITION || "unpartitioned-topic-subscription", | ||
| [Constants.SUBSCRIPTION_NAME_SESSION]: | ||
| SUBSCRIPTION_NAME_SESSION || "partitioned-topic-sessions-subscription", | ||
| [Constants.SUBSCRIPTION_NAME_NO_PARTITION_SESSION]: | ||
| SUBSCRIPTION_NAME_NO_PARTITION_SESSION || "unpartitioned-topic-sessions-subscription", | ||
| [Constants.TOPIC_FILTER_NAME]: TOPIC_FILTER_NAME || "topic-filter", | ||
| [Constants.TOPIC_FILTER_SUBSCRIPTION_NAME]: | ||
| TOPIC_FILTER_SUBSCRIPTION_NAME || "topic-filter-subscription", | ||
| [Constants.TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME]: | ||
| TOPIC_FILTER_DEFAULT_SUBSCRIPTION_NAME || "topic-filter-default-subscription", | ||
| [Constants.AAD_CLIENT_ID]: AAD_CLIENT_ID, | ||
| [Constants.AAD_CLIENT_SECRET]: AAD_CLIENT_SECRET, | ||
| [Constants.AAD_TENANT_ID]: AAD_TENANT_ID, | ||
| [Constants.RESOURCE_GROUP]: RESOURCE_GROUP, | ||
| [Constants.AZURE_SUBSCRIPTION_ID]: AZURE_SUBSCRIPTION_ID, | ||
| [Constants.CLEAN_NAMESPACE]: CLEAN_NAMESPACE || false | ||
| }; | ||
| } | ||
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.