Skip to content

Commit f8a3be7

Browse files
authored
[Perf Framework] Print dependencies on perf test start (#18366)
Resolves #13825.
1 parent 31e9c3a commit f8a3be7

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

sdk/test-utils/perf/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## 1.0.0 (Unreleased)
44

5+
### 2021-10-27
6+
7+
- Log dependencies (`@azure` packages only) on perf test start. Extended output of transitive dependencies can be enabled using the new `--list-transitive-dependencies` flag.
8+
[#18366](https://github.com/Azure/azure-sdk-for-js/pull/18366)
9+
510
### 2021-10-20
611

712
- Clean up some naming: `PerfStress` to `Perf` everywhere; also rename the `runAsync` method to `run`.

sdk/test-utils/perf/src/options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export interface DefaultPerfOptions {
6868
"milliseconds-to-log": number;
6969
"test-proxies": string;
7070
insecure: boolean;
71+
"list-transitive-dependencies": boolean;
7172
}
7273

7374
/**
@@ -115,6 +116,11 @@ export const defaultPerfOptions: PerfOptionDictionary<DefaultPerfOptions> = {
115116
description: "Log frequency in milliseconds",
116117
shortName: "mtl",
117118
defaultValue: 1000
119+
},
120+
"list-transitive-dependencies": {
121+
description: "List all dependencies, instead of only direct ones, before test run",
122+
shortName: "ltd",
123+
defaultValue: false
118124
}
119125
};
120126

sdk/test-utils/perf/src/program.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from "./options";
1212
import { PerfParallel } from "./parallel";
1313
import { TestProxyHttpClientV1, TestProxyHttpClient } from "./testProxyHttpClient";
14+
import { exec } from "child_process";
1415

1516
export type TestType = "";
1617

@@ -239,6 +240,18 @@ export class PerfProgram {
239240
this.logResults(parallels);
240241
}
241242

243+
private async logPackageVersions(listTransitiveDeps: boolean): Promise<void> {
244+
return new Promise((resolve) => {
245+
console.log("=== Versions ===");
246+
exec(`npm list --prod ${listTransitiveDeps ? "" : "--depth=0"}`, (_error, stdout) => {
247+
for (const dependency of stdout.split("\n").filter((line) => line.includes("@azure"))) {
248+
console.log(dependency);
249+
}
250+
resolve();
251+
});
252+
});
253+
}
254+
242255
/**
243256
* The run() public method lets developers specify when to begin running the selected test
244257
* under the conditions provided by the command line options.
@@ -267,6 +280,10 @@ export class PerfProgram {
267280
return;
268281
}
269282

283+
await this.logPackageVersions(
284+
this.parsedDefaultOptions["list-transitive-dependencies"].value ?? false
285+
);
286+
270287
const options = this.tests[0].parsedOptions;
271288
console.log("=== Parsed options ===");
272289
console.table(options);

0 commit comments

Comments
 (0)