Skip to content

Commit c929fc5

Browse files
authored
[monitor-ingestion] Add perf tests (Azure#23056)
1 parent b6249f6 commit c929fc5

File tree

9 files changed

+250
-15
lines changed

9 files changed

+250
-15
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 84 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rush.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,11 @@
891891
"projectFolder": "sdk/monitor/perf-tests/monitor-query",
892892
"versionPolicyName": "test"
893893
},
894+
{
895+
"packageName": "@azure-tests/perf-monitor-ingestion",
896+
"projectFolder": "sdk/monitor/perf-tests/monitor-ingestion",
897+
"versionPolicyName": "test"
898+
},
894899
{
895900
"packageName": "@azure-tests/perf-template",
896901
"projectFolder": "sdk/template/perf-tests/template",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Perf tests for `monitor-ingestion`
2+
3+
### Guide
4+
5+
1. Build the monitor-ingestion perf tests package `rush build -t perf-monitor-ingestion`.
6+
2. Copy the `sample.env` file and name it as `.env`.
7+
3. Create the necessary test resources (either using the `New-TestResources.ps1` script or by following [this guide])
8+
4. Run the tests as follows:
9+
10+
- upload logs
11+
- `npm run perf-test:node -- UploadLogsTest --warmup 1 --iterations 1 --parallel 50 --duration 15`
12+
- The option `--logsCount` can be used to specify the number of logs to upload.
13+
- The option `--maxConcurrency` can be used to specify the maximum number of concurrent upload requests in the case that the
14+
upload is split into multiple requests due to the size of the logs being uploaded exceeding 1MB.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "@azure-tests/perf-monitor-ingestion",
3+
"sdk-type": "perf-test",
4+
"version": "1.0.0",
5+
"description": "",
6+
"main": "",
7+
"keywords": [],
8+
"author": "",
9+
"license": "ISC",
10+
"dependencies": {
11+
"@azure/monitor-ingestion": "1.0.0-beta.2",
12+
"@azure/test-utils-perf": "^1.0.0",
13+
"dotenv": "^8.2.0",
14+
"@azure/identity": "^2.0.1"
15+
},
16+
"devDependencies": {
17+
"@types/node": "^12.0.0",
18+
"eslint": "^8.0.0",
19+
"prettier": "^2.5.1",
20+
"rimraf": "^3.0.0",
21+
"tslib": "^2.2.0",
22+
"ts-node": "^10.0.0",
23+
"typescript": "~4.6.0"
24+
},
25+
"private": true,
26+
"scripts": {
27+
"perf-test:node": "npm run build && node dist-esm/index.spec.js",
28+
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
29+
"build": "npm run clean && tsc -p .",
30+
"build:samples": "echo skipped",
31+
"build:test": "echo skipped",
32+
"check-format": "prettier --list-different --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"test/**/*.ts\" \"*.{js,json}\"",
33+
"clean": "rimraf dist dist-esm test-dist types *.tgz *.log",
34+
"format": "prettier --write --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"test/**/*.ts\" \"*.{js,json}\"",
35+
"integration-test:browser": "echo skipped",
36+
"integration-test:node": "echo skipped",
37+
"integration-test": "echo skipped",
38+
"lint:fix": "eslint --no-eslintrc -c ../../../.eslintrc.internal.json package.json test --ext .ts --fix --fix-type [problem,suggestion]",
39+
"lint": "eslint --no-eslintrc -c ../../../.eslintrc.internal.json package.json test --ext .ts",
40+
"pack": "npm pack 2>&1",
41+
"unit-test:browser": "echo skipped",
42+
"unit-test:node": "echo skipped",
43+
"unit-test": "echo skipped",
44+
"test:browser": "echo skipped",
45+
"test:node": "echo skipped",
46+
"test": "echo skipped"
47+
}
48+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Used to authenticate using Azure AD as a service principal for role-based authentication.
2+
#
3+
# See the documentation for `EnvironmentCredential` at the following link:
4+
# https://docs.microsoft.com/javascript/api/@azure/identity/environmentcredential
5+
AZURE_TENANT_ID=<AD tenant id or name>
6+
AZURE_CLIENT_ID=<ID of the user/service principal to authenticate as>
7+
AZURE_CLIENT_SECRET=<client secret used to authenticate to Azure AD>
8+
9+
DATA_COLLECTION_RULE_ID=<The ID of the data collection rule>
10+
LOGS_INGESTION_ENDPOINT=<The logs ingestion endpoint to upload logs to>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
import { UploadLogsTest } from "./uploadLogs.spec";
5+
import { createPerfProgram } from "@azure/test-utils-perf";
6+
7+
const perfProgram = createPerfProgram(UploadLogsTest);
8+
perfProgram.run();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
import { PerfTest, getEnvVar } from "@azure/test-utils-perf";
5+
import { LogsIngestionClient } from "@azure/monitor-ingestion";
6+
import { DefaultAzureCredential } from "@azure/identity";
7+
8+
// Expects the .env file at the same level
9+
import * as dotenv from "dotenv";
10+
dotenv.config();
11+
12+
export abstract class MonitorIngestionPerfTest<TOptions> extends PerfTest<TOptions> {
13+
client: LogsIngestionClient;
14+
15+
constructor() {
16+
super();
17+
const tokenCredential = new DefaultAzureCredential();
18+
this.client = new LogsIngestionClient(getEnvVar("LOGS_INGESTION_ENDPOINT"), tokenCredential);
19+
}
20+
}

0 commit comments

Comments
 (0)