Skip to content

Commit

Permalink
Fix test pipeline for rooms with ppe connectionstr (#23583)
Browse files Browse the repository at this point in the history
* Fix test pipeline for rooms with ppe connectionstr

* Update tests.yml for Azure Pipelines

* Use Static connection string instead of Dynamic

* Fix lint issues and samples

* Update Karma.conf

* Reset string

* Use COMMUNICATION_SAMPLES_CONNECTION_STRING

* Add new string to common secrets

* Use rooms secrect for sample string

* Undo node version change
  • Loading branch information
anujissarMS committed Nov 22, 2022
1 parent 7881072 commit 088fc61
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 32 deletions.
4 changes: 2 additions & 2 deletions sdk/communication/communication-rooms/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ module.exports = function (config) {
// https://www.npmjs.com/package/karma-env-preprocessor
envPreprocessor: [
"TEST_MODE",
"COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING",
"COMMUNICATION_CONNECTION_STRING_ROOMS",
"COMMUNICATION_SAMPLES_CONNECTION_STRING",
"BASE_URL",
"COMMUNICATION_ENDPOINT",
"COMMUNICATION_CONNECTION_STRING",
"RECORDINGS_RELATIVE_PATH",
],

Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/communication-rooms/sample.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Used in most samples. Retrieve these values from a Communication Services resource
# in the Azure Portal.
COMMUNICATION_CONNECTION_STRING="endpoint=https://<resource name>.communication.azure.net/;accessKey=<key>"
COMMUNICATION_SAMPLES_CONNECTION_STRING="endpoint=https://<resource name>.communication.azure.net/;accessKey=<key>"
COMMUNICATION_ENDPOINT="https://<resource name>.communication.azure.com"
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dotenv.config();

export async function main() {
const connectionString =
process.env["COMMUNICATION_CONNECTION_STRING"] ||
process.env["COMMUNICATION_SAMPLES_CONNECTION_STRING"] ||
"endpoint=https://<resource-name>.communication.azure.com/;<access-key>";

const identityClient = new CommunicationIdentityClient(connectionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dotenv.config();

export async function main() {
const connectionString =
process.env["COMMUNICATION_CONNECTION_STRING"] ||
process.env["COMMUNICATION_SAMPLES_CONNECTION_STRING"] ||
"endpoint=https://<resource-name>.communication.azure.com/;<access-key>";

const identityClient = new CommunicationIdentityClient(connectionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ node participantOperations.js
Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform):

```bash
npx cross-env COMMUNICATION_CONNECTION_STRING="<communication connection string>" node participantOperations.js
npx cross-env COMMUNICATION_SAMPLES_CONNECTION_STRING="<communication samples connection string>" node participantOperations.js
```

## Next Steps

Take a look at our [API Documentation] for more information about the APIs that are available in the clients.
Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients.

[participantoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/communication/communication-rooms/samples/v1-beta/javascript/participantOperations.js
[roomoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/communication/communication-rooms/samples/v1-beta/javascript/roomOperations.js
[apiref]: https://docs.microsoft.com/javascript/api/@azure/communication-rooms
[freesub]: https://azure.microsoft.com/free/
[createinstance_azurecommunicationservicesaccount]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-rooms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require("dotenv").config();

async function main() {
const connectionString =
process.env["COMMUNICATION_CONNECTION_STRING"] ||
process.env["COMMUNICATION_SAMPLES_CONNECTION_STRING"] ||
"endpoint=https://<resource-name>.communication.azure.com/;<access-key>";

const identityClient = new CommunicationIdentityClient(connectionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require("dotenv").config();

async function main() {
const connectionString =
process.env["COMMUNICATION_CONNECTION_STRING"] ||
process.env["COMMUNICATION_SAMPLES_CONNECTION_STRING"] ||
"endpoint=https://<resource-name>.communication.azure.com/;<access-key>";

const identityClient = new CommunicationIdentityClient(connectionString);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Used in most samples. Retrieve these values from a Communication Services resource
# in the Azure Portal.
COMMUNICATION_CONNECTION_STRING="endpoint=https://<resource name>.communication.azure.net/;accessKey=<key>"
COMMUNICATION_SAMPLES_CONNECTION_STRING="endpoint=https://<resource name>.communication.azure.net/;accessKey=<key>"
COMMUNICATION_ENDPOINT="https://<resource name>.communication.azure.com"
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ node dist/participantOperations.js
Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform):

```bash
npx cross-env COMMUNICATION_CONNECTION_STRING="<communication connection string>" node dist/participantOperations.js
npx cross-env COMMUNICATION_SAMPLES_CONNECTION_STRING="<communication samples connection string>" node dist/participantOperations.js
```

## Next Steps

Take a look at our [API Documentation] for more information about the APIs that are available in the clients.
Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients.

[participantoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/communication/communication-rooms/samples/v1-beta/typescript/src/participantOperations.ts
[roomoperations]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/communication/communication-rooms/samples/v1-beta/typescript/src/roomOperations.ts
[apiref]: https://docs.microsoft.com/javascript/api/@azure/communication-rooms
[freesub]: https://azure.microsoft.com/free/
[createinstance_azurecommunicationservicesaccount]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-rooms/README.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"devDependencies": {
"@types/node": "^14.0.0",
"typescript": "~4.6.0",
"typescript": "~4.8.0",
"rimraf": "latest"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Used in most samples. Retrieve these values from a Communication Services resource
# in the Azure Portal.
COMMUNICATION_CONNECTION_STRING="endpoint=https://<resource name>.communication.azure.net/;accessKey=<key>"
COMMUNICATION_SAMPLES_CONNECTION_STRING="endpoint=https://<resource name>.communication.azure.net/;accessKey=<key>"
COMMUNICATION_ENDPOINT="https://<resource name>.communication.azure.com"
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
* @summary Perform participant operations using the RoomsClient.
*/

import {
RoomsClient,
RoomParticipant,
CreateRoomOptions,
} from "@azure/communication-rooms";
import { RoomsClient, RoomParticipant, CreateRoomOptions } from "@azure/communication-rooms";
import { CommunicationIdentityClient } from "@azure/communication-identity";
import { getIdentifierRawId } from "@azure/communication-common";

Expand All @@ -19,7 +15,7 @@ dotenv.config();

export async function main() {
const connectionString =
process.env["COMMUNICATION_CONNECTION_STRING"] ||
process.env["COMMUNICATION_SAMPLES_CONNECTION_STRING"] ||
"endpoint=https://<resource-name>.communication.azure.com/;<access-key>";

const identityClient = new CommunicationIdentityClient(connectionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dotenv.config();

export async function main() {
const connectionString =
process.env["COMMUNICATION_CONNECTION_STRING"] ||
process.env["COMMUNICATION_SAMPLES_CONNECTION_STRING"] ||
"endpoint=https://<resource-name>.communication.azure.com/;<access-key>";

const identityClient = new CommunicationIdentityClient(connectionString);
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/communication-rooms/test.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Used in most samples. Retrieve these values from a Communication Services instance
# in the Azure Portal.
COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING="endpoint=https://<resource name>.communication.azure.net/;accessKey=<key>"
COMMUNICATION_CONNECTION_STRING_ROOMS="endpoint=https://<resource name>.communication.azure.net/;accessKey=<key>"

# Our tests assume that TEST_MODE is "playback" by default. You can
# change it to "record" to generate new recordings, or "live" to bypass the recorder entirely.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
createRoomsClient,
generateHttpClient,
mockCreateRoomsResult,
mockUpdateRoomsResult,
mockSdkModelParticipant,
mockUpdateRoomsResult,
} from "./utils/mockedClient";

describe("[Mocked] RoomsClient", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export interface RecordedClient<T> {
}

const envSetupForPlayback: { [k: string]: string } = {
COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING: "endpoint=https://endpoint/;accesskey=banana",
COMMUNICATION_CONNECTION_STRING_ROOMS: "endpoint=https://endpoint/;accesskey=banana",
};

const fakeToken = generateToken();
const sanitizerOptions: SanitizerOptions = {
connectionStringSanitizers: [
{
actualConnString: env["COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING"] || undefined,
fakeConnString: envSetupForPlayback["COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING"],
actualConnString: env["COMMUNICATION_CONNECTION_STRING_ROOMS"] || undefined,
fakeConnString: envSetupForPlayback["COMMUNICATION_CONNECTION_STRING_ROOMS"],
},
],
bodyKeySanitizers: [
Expand Down Expand Up @@ -75,7 +75,7 @@ export async function createRecordedRoomsClient(
const recorder = await createRecorder(context.currentTest);

const client = new RoomsClient(
env.COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING ?? "",
env.COMMUNICATION_CONNECTION_STRING_ROOMS ?? "",
recorder.configureClientOptions({})
);
return {
Expand All @@ -90,9 +90,7 @@ export async function createRecordedRoomsClientWithToken(
const recorder = await createRecorder(context.currentTest);

let credential: TokenCredential;
const endpoint = parseConnectionString(
env.COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING ?? ""
).endpoint;
const endpoint = parseConnectionString(env.COMMUNICATION_CONNECTION_STRING_ROOMS ?? "").endpoint;

if (isPlaybackMode()) {
credential = {
Expand All @@ -113,7 +111,7 @@ export async function createRecordedRoomsClientWithToken(

export async function createTestUser(recorder: Recorder): Promise<CommunicationUserToken> {
const identityClient = new CommunicationIdentityClient(
assertEnvironmentVariable("COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING"),
assertEnvironmentVariable("COMMUNICATION_CONNECTION_STRING_ROOMS"),
recorder.configureClientOptions({})
);
return identityClient.createUserAndToken(["voip"]);
Expand All @@ -122,7 +120,7 @@ export async function createTestUser(recorder: Recorder): Promise<CommunicationU
export async function deleteTestUser(testUser: CommunicationUserIdentifier): Promise<void> {
if (testUser) {
const identityClient = new CommunicationIdentityClient(
assertEnvironmentVariable("COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING")
assertEnvironmentVariable("COMMUNICATION_CONNECTION_STRING_ROOMS")
);
await identityClient.deleteUser(testUser);
}
Expand Down
1 change: 1 addition & 0 deletions sdk/communication/communication-rooms/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ stages:
SubscriptionConfigurations:
- $(sub-config-communication-int-test-resources-common)
- $(sub-config-communication-int-test-resources-js)
- $(communication-livetest-rooms-int)
MatrixFilters:
- TestType=^(?!browser).*
Clouds: Public,Int

0 comments on commit 088fc61

Please sign in to comment.