Addressing feedback at #14098

Harsha Nalluru 2021-03-04 17:55:43 -08:00
Родитель 9826dab20c
Коммит 6745f96480
1 изменённых файлов: 63 добавлений и 58 удалений

@ -17,52 +17,69 @@
To add perf tests for the `sdk/<service>/<service-sdk>` package, follow the steps below.
1. Create a new folder for the perf tests.
1. Create a new folder for the perf tests.
Path- `sdk/<service>/perf-tests/<service-sdk>`
Path- `sdk/<service>/perf-tests/<service-sdk>`
(Create the `perf-tests` folder if that doesn't exist)
(Create the `perf-tests` folder if that doesn't exist)
2. This new perf test project will be managed by the rush infrastructure in the repository, with the package name `@azure-tests/<service-sdk>`. To allow rush to manage the project, add the following entry in `rush.json`
2. This new perf test project will be managed by the rush infrastructure in the repository, with the package name `@azure-tests/<service-sdk>`. To allow rush to manage the project, add the following entry in `rush.json`
```
{
"packageName": "@azure-tests/<service-sdk>",
"projectFolder": "sdk/<service>/perf-tests/<service-sdk>",
"versionPolicyName": "test"
```
{
"packageName": "@azure-tests/perf-<service-sdk>",
"projectFolder": "sdk/<service>/perf-tests/<service-sdk>",
"versionPolicyName": "test"
}
```
3. Tests will live under `sdk/<service>/perf-tests/<service-sdk>/test`
4. Add a `package.json` such as [example-perf-package.json](https://github.com/Azure/azure-sdk-for-js/blob/fe9b1e5a50946f53b6491d7f67b2420d8ee1b229/sdk/storage/perf-tests/storage-file-datalake/package.json) at `sdk/<service>/perf-tests/<service-sdk>` folder.
Make sure to import your `<service-sdk>` and the `test-utils-perfstress` project.
```json
"dependencies": {
"@azure/<service-sdk>": "^<version-in-master-branch>",
"@azure/test-utils-perfstress": "^1.0.0"
}
```
```
_Note: `"@azure/test-utils-perfstress"` is not a published npm package._
3. Tests will live under `sdk/<service>/perf-tests/<service-sdk>/test`
4. Add a `package.json` such as [example-perf-package.json](https://github.com/Azure/azure-sdk-for-js/blob/fe9b1e5a50946f53b6491d7f67b2420d8ee1b229/sdk/storage/perf-tests/storage-file-datalake/package.json) at `sdk/<service>/perf-tests/<service-sdk>` folder.
Set the name of the package and mark it as private.
Make sure to import your `<service-sdk>` and the `test-utils-perfstress` project.
```json
"name": "@azure-tests/perf-<service-sdk>",
"private": true,
```
```json
"devDependencies": {
"@azure/<service-sdk>": "^<version-in-master-branch>",
"@azure/test-utils-perfstress": "^1.0.0"
}
```
5. Run `rush update` and commit the changes to the `pnpm-lock` file.
6. Copy the `tsconfig.json`, `sample.env`(and `.env`) files that are present at the `sdk/<service>/<service-sdk>` to `sdk/<service>/perf-tests/<service-sdk>`.
_Note: `"@azure/test-utils-perfstress"` is not a published npm package._
TSCONFIG
Set the name of the package and mark it as private.
- Modify the "extends" string in the copied tsconfig by adding ".." since the perf tests project is located a level below the actual SDK.
- Set the `compilerOptions.module` to `commonjs` in the `tsconfig` to allow running the tests with `ts-node`.
```json
"name": "@azure-tests/perf-<service-sdk>",
"private": true,
```
In the end, your tsconfig may look something like below.
5. Run `rush update` and commit the changes to the `pnpm-lock` file.
6. Copy the `tsconfig.json`, `sample.env`(and `.env`) files that are present at the `sdk/<service>/<service-sdk>` to `sdk/<service>/perf-tests/<service-sdk>`.
Set the `compilerOptions.module` to `commonjs` in the `tsconfig` to allow running the tests with `ts-node`.
```json
"module": "commonjs"
```
```
{
"extends": "../../../../tsconfig.package",
"compilerOptions": {
"module": "CommonJS",
"target": "ES2015",
"declarationDir": "./typings/latest",
"lib": ["ES6", "ESNext.AsyncIterable"],
"noEmit": true
},
"compileOnSave": true,
"exclude": ["node_modules"],
"include": ["./test/**/*.ts"]
}
```
### [For perf-testing track 1 version of the same package](#For-perf-testing-track-1-version-of-the-same-package)
@ -77,7 +94,7 @@ To add perf tests for the `sdk/<service>/<service-sdk>` package, follow the step
Make sure to import your `<service-sdk>` and the `test-utils-perfstress` project.
```json
"devDependencies": {
"dependencies": {
"@azure/<service-sdk>": "^<latest-track-1-version>",
"@azure/test-utils-perfstress": "file:../../../test-utils/perfstress/azure-test-utils-perfstress-1.0.0.tgz",
}
@ -112,8 +129,12 @@ Add an `index.spec.ts` at `sdk/<service>/perf-tests/<service-sdk>/test/`.
```js
import { PerfStressProgram, selectPerfStressTest } from "@azure/test-utils-perfstress";
import { `ServiceNameAPIName`Test } from "./api-name.spec";
import { `ServiceNameAPIName2`Test } from "./api-name2.spec";
import { `ServiceNameAPI1Name`Test } from "./api1-name.spec";
import { `ServiceNameAPI2Name`Test } from "./api2-name.spec";
// Expects the .env file at the same level
import * as dotenv from "dotenv";
dotenv.config();
console.log("=== Starting the perfStress test ===");
@ -134,11 +155,7 @@ import {
ServiceNameClient
} from "@azure/<service-sdk>";
// Expects the .env file at the same level
import * as dotenv from "dotenv";
dotenv.config();
export abstract class `ServiceName`Test<TOptions> extends PerfStressTest<TOptions> {
export abstract class `ServiceName`Test<TOptions = {}> extends PerfStressTest<TOptions> {
serviceNameClient: ServiceNameClient;
constructor() {
@ -165,21 +182,9 @@ import { ServiceNameClient } from "@azure/<service-sdk>";
import { PerfStressOptionDictionary, drainStream } from "@azure/test-utils-perfstress";
import { `ServiceName`Test } from "./serviceNameTest.spec";
interface `ServiceNameAPIName`TestOptions {
newOption: number;
}
export class `ServiceNameAPIName`Test extends ServiceNameTest<`ServiceNameAPIName`TestOptions> {
// More details regarding the options in the next section
public options: PerfStressOptionDictionary<`ServiceNameAPIName`TestOptions> = {
newOption: {
required: true,
description: "A new option",
shortName: "sz",
longName: "newOption",
defaultValue: 10240
}
};
export class `ServiceNameAPIName`Test extends ServiceNameTest {
// The next section talks about the custom options that you can provide for a test
public options: PerfStressOptionDictionary = {};
serviceNameClient: `ServiceName`Client;
@ -237,7 +242,7 @@ export class `ServiceNameAPIName`Test extends ServiceNameTest<`ServiceNameAPINam
To run a particular test, use `npm run perf-test:node` - takes the test class name as the argument along with the command line arguments you may provide.
- Run `npm run perf-test:node -- TestClassName --warmup 2 --duration 7 --iterations 2 --parallel 2`
- Run `npm run perf-test:node -- TestClassName --warmup 2 --duration 7 --iterations 2 --parallel 50`
### [Adding Readme/Instructions](#Adding-Readme/Instructions)
@ -253,4 +258,4 @@ Example: Currently `@azure/<service-sdk>` is at 12.4.0 on master and you want to
- `rush update` (generates a new pnpm-lock file)
- Navigate to `sdk\storage\perf-tests\<service-sdk>`
- `rush build -t perf-test-<service-sdk>`
- Run the tests as suggested before, example `npm run perf-test:node -- TestClassName --warmup 2 --duration 7 --iterations 2 --parallel 2`
- Run the tests as suggested before, example `npm run perf-test:node -- TestClassName --warmup 2 --duration 7 --iterations 2 --parallel 50`