Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion common/config/rush/common-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
"@types/node": ["^10.0.0", "^10.12.0"],
// @azure/test-utils-perfstress should depend on lowest version of @azure/core-http for maximum compatibility, allowing test
// projects to choose a higher version if desired.
"@azure/core-http": ["^1.0.0"]
"@azure/core-http": ["^1.0.0"],
// Idenity is moving from v1 to v2. Moving all packages to v2 is going to take a bit of time, in the mean time we could use v2 on the perf-identity tests.
"@azure/identity": ["^2.0.0-beta.1"]
}
}
18 changes: 18 additions & 0 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,11 @@
"projectFolder": "sdk/keyvault/perf-tests/keyvault-secrets",
"versionPolicyName": "test"
},
{
"packageName": "@azure-tests/perf-identity",
"projectFolder": "sdk/identity/perf-tests/identity",
"versionPolicyName": "test"
},
{
"packageName": "@azure/mixedreality-authentication",
"projectFolder": "sdk/mixedreality/mixedreality-authentication",
Expand Down
5 changes: 5 additions & 0 deletions sdk/identity/perf-tests/identity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release History

## 1.0.0-beta.1 (Unreleased)

- Added a first performance test that does silent authentication with persistence enabled with `ClientSecretCredential`.
13 changes: 13 additions & 0 deletions sdk/identity/perf-tests/identity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Guide

**Important:**
These tests won't work on Node 8 nor Node 15.

1. Install `@azure/msal-node-extensions@1.0.0-alpha.6` globally with `npm i -g @azure/msal-node-extensions@1.0.0-alpha.6`.
Copy link
Copy Markdown
Contributor

@HarshaNalluru HarshaNalluru Apr 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why global?.. Is it not enough to add it as a dependency in the package.json?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't have this dependency in our package.json since this means developers need to have Visual Studio or build-essential installed, and in some Node versions this dependency doesn't compile. We're working on it with the MSAL team.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant.. dependency of the perf-test identity project, where you're mentioning @azure/identity.

2. Build the Identity perf tests package `rush build -t perf-identity`.
3. Copy the `sample.env` file and name it as `.env`.
4. Populate the `.env` file with your Azure Credentials.
5. Refer to the [rate limits](https://docs.microsoft.com/azure/active-directory/enterprise-users/directory-service-limits-restrictions) and then run the tests as follows:

- `ClientSecretCredential` test for the `tokenCachePersistenceOptions`.
- `npm run perf-test:node -- ClientSecretCredentialPersistenceTest --warmup 1 --iterations 1 --parallel 5`
47 changes: 47 additions & 0 deletions sdk/identity/perf-tests/identity/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@azure-tests/perf-identity",
"version": "1.0.0-beta.1",
"description": "",
"main": "",
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@azure/identity": "^2.0.0-beta.1",
"@azure/test-utils-perfstress": "^1.0.0",
"dotenv": "^8.2.0"
},
"devDependencies": {
"@types/uuid": "^8.0.0",
"eslint": "^7.15.0",
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"ts-node": "^9.0.0",
"tslib": "^2.0.0",
"typescript": "~4.2.0"
},
"private": true,
"scripts": {
"perf-test:node": "ts-node test/index.spec.ts",
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build": "tsc -p .",
"build:samples": "echo skipped",
"build:test": "echo skipped",
"check-format": "prettier --list-different --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-esm test-dist typings *.tgz *.log",
"format": "prettier --write --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"integration-test": "echo skipped",
"lint:fix": "eslint --no-eslintrc -c ../../../.eslintrc.internal.json package.json test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint --no-eslintrc -c ../../../.eslintrc.internal.json package.json test --ext .ts",
"pack": "npm pack 2>&1",
"prebuild": "npm run clean",
"unit-test:browser": "echo skipped",
"unit-test:node": "echo skipped",
"unit-test": "echo skipped",
"test:browser": "echo skipped",
"test:node": "echo skipped",
"test": "echo skipped"
}
}
3 changes: 3 additions & 0 deletions sdk/identity/perf-tests/identity/sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AZURE_TENANT_ID=<AD tenant id or name>
AZURE_CLIENT_ID=<ID of the user/service principal to authenticate as>
AZURE_CLIENT_SECRET=<client secret used to authenticate to Azure AD>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { PerfStressTest, getEnvVar } from "@azure/test-utils-perfstress";
import { ClientSecretCredential } from "@azure/identity";

const scope = `https://servicebus.azure.net/.default`;

/**
* This test does silent authentication with persistence enabled.
*/
export class ClientSecretCredentialPersistenceTest extends PerfStressTest {
options = {};
static credential: ClientSecretCredential;

async globalSetup(): Promise<void> {
const tenantId = getEnvVar("AZURE_TENANT_ID");
const clientId = getEnvVar("AZURE_CLIENT_ID");
const clientSecret = getEnvVar("AZURE_CLIENT_SECRET");

// We want this credential to be initialized only if this test is executed.
// Other tests should not be required to set up this credential.
const credential = new ClientSecretCredential(tenantId, clientId, clientSecret, {
tokenCachePersistenceOptions: {
name: "nodeTestSilent",
allowUnencryptedStorage: true
}
});

// This getToken call will cache the token.
await credential.getToken(scope);

ClientSecretCredentialPersistenceTest.credential = credential;
}

async runAsync(): Promise<void> {
await ClientSecretCredentialPersistenceTest.credential.getToken(scope);
}
}
12 changes: 12 additions & 0 deletions sdk/identity/perf-tests/identity/test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PerfStressProgram, selectPerfStressTest } from "@azure/test-utils-perfstress";
import { ClientSecretCredentialPersistenceTest } from "./ClientSecretCredential/persistence.spec";
import * as dotenv from "dotenv";
dotenv.config();

console.log("=== Starting the perfStress test ===");

const perfStressProgram = new PerfStressProgram(
selectPerfStressTest([ClientSecretCredentialPersistenceTest])
);

perfStressProgram.run();
12 changes: 12 additions & 0 deletions sdk/identity/perf-tests/identity/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../../tsconfig.package",
"compilerOptions": {
"module": "CommonJS",
"target": "ES2015",
"lib": ["ES6", "ESNext.AsyncIterable"],
"noEmit": true
},
"compileOnSave": true,
"exclude": ["node_modules"],
"include": ["./test/**/*.ts"]
}