Skip to content

Commit 35739ab

Browse files
[App config] Perf tests (Azure#15763)
Adds the list test Closes Azure#13981
1 parent c6b82ee commit 35739ab

File tree

9 files changed

+185
-0
lines changed

9 files changed

+185
-0
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 17 additions & 0 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
@@ -784,6 +784,11 @@
784784
"packageName": "@azure-tests/perf-core-rest-pipeline",
785785
"projectFolder": "sdk/core/perf-tests/core-rest-pipeline",
786786
"versionPolicyName": "test"
787+
},
788+
{
789+
"packageName": "@azure-tests/perf-app-configuration",
790+
"projectFolder": "sdk/appconfiguration/perf-tests/app-configuration",
791+
"versionPolicyName": "test"
787792
}
788793
]
789794
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Guide
2+
3+
1. Build the app-config perf tests package `rush build -t perf-app-configuration`.
4+
2. Copy the `sample.env` file and name it as `.env`.
5+
3. Create a App Configuration resource and populate the `.env` file with `APPCONFIG_CONNECTION_STRING` variable.
6+
4. Run the tests as follows
7+
8+
- list configuration settings
9+
- `npm run perf-test:node -- ListSettingsTest --warmup 2 --duration 7 --iterations 2 --parallel 2`
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "@azure-tests/perf-app-configuration",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "",
6+
"keywords": [],
7+
"author": "",
8+
"license": "ISC",
9+
"dependencies": {
10+
"@azure/app-configuration": "^1.2.0-beta.2",
11+
"@azure/core-http": "^2.0.0",
12+
"@azure/test-utils-perfstress": "^1.0.0",
13+
"dotenv": "^8.2.0"
14+
},
15+
"devDependencies": {
16+
"@types/uuid": "^8.0.0",
17+
"@types/node": "^8.0.0",
18+
"uuid": "^8.3.0",
19+
"tslib": "^2.2.0",
20+
"ts-node": "^9.0.0",
21+
"typescript": "~4.2.0"
22+
},
23+
"private": true,
24+
"scripts": {
25+
"perf-test:node": "ts-node test/index.spec.ts",
26+
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
27+
"build": "tsc -p .",
28+
"build:samples": "echo skipped",
29+
"build:test": "echo skipped",
30+
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
31+
"clean": "rimraf dist dist-esm test-dist typings *.tgz *.log",
32+
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
33+
"integration-test:browser": "echo skipped",
34+
"integration-test:node": "echo skipped",
35+
"integration-test": "echo skipped",
36+
"lint:fix": "eslint package.json src test --ext .ts --fix --fix-type [problem,suggestion]",
37+
"lint": "eslint package.json src test --ext .ts -f html -o app-config-perf-test-lintReport.html || exit 0",
38+
"pack": "npm pack 2>&1",
39+
"prebuild": "npm run clean",
40+
"unit-test:browser": "echo skipped",
41+
"unit-test:node": "echo skipped",
42+
"unit-test": "echo skipped",
43+
"test:browser": "echo skipped",
44+
"test:node": "echo skipped",
45+
"test": "echo skipped"
46+
}
47+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This is the connection string for your app-configuration resource
2+
# You can get this from the Azure portal.
3+
APPCONFIG_CONNECTION_STRING=<app-configuration connection string goes here>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { PerfStressTest, getEnvVar } from "@azure/test-utils-perfstress";
2+
import { AppConfigurationClient } from "@azure/app-configuration";
3+
// Expects the .env file at the same level
4+
import * as dotenv from "dotenv";
5+
dotenv.config();
6+
7+
export abstract class AppConfigTest<TOptions> extends PerfStressTest<TOptions> {
8+
client: AppConfigurationClient;
9+
10+
constructor() {
11+
super();
12+
const connectionString = getEnvVar("APPCONFIG_CONNECTION_STRING");
13+
this.client = new AppConfigurationClient(connectionString);
14+
}
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { PerfStressProgram, selectPerfStressTest } from "@azure/test-utils-perfstress";
2+
import { ListSettingsTest } from "./listSettings.spec";
3+
4+
console.log("=== Starting the perfStress test ===");
5+
6+
const perfStressProgram = new PerfStressProgram(selectPerfStressTest([ListSettingsTest]));
7+
8+
perfStressProgram.run();
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
import { generateUuid } from "@azure/core-http";
5+
import { PerfStressOptionDictionary, executeParallel } from "@azure/test-utils-perfstress";
6+
import { AppConfigTest } from "./appConfigBase.spec";
7+
8+
interface ListTestOptions {
9+
/**
10+
* Number of settings to be created/listed in the test
11+
*/
12+
count: number;
13+
}
14+
15+
export class ListSettingsTest extends AppConfigTest<ListTestOptions> {
16+
static prefix = generateUuid();
17+
public options: PerfStressOptionDictionary<ListTestOptions> = {
18+
count: {
19+
required: true,
20+
description: "Number of settings to be listed",
21+
longName: "count",
22+
defaultValue: 10
23+
}
24+
};
25+
26+
public async globalSetup() {
27+
await executeParallel(
28+
async (_count: number, _index: number) => {
29+
await this.client.addConfigurationSetting({
30+
key: ListSettingsTest.prefix + generateUuid(),
31+
value: "random"
32+
});
33+
},
34+
this.parsedOptions.count.value!,
35+
32
36+
);
37+
}
38+
39+
async runAsync(): Promise<void> {
40+
for await (const response of this.client
41+
.listConfigurationSettings({ keyFilter: ListSettingsTest.prefix + "*" })
42+
.byPage()) {
43+
for (const _ of response.items) {
44+
}
45+
}
46+
}
47+
48+
public async globalCleanup() {
49+
const keys: string[] = [];
50+
for await (const response of this.client
51+
.listConfigurationSettings({ keyFilter: ListSettingsTest.prefix + "*" })
52+
.byPage()) {
53+
for (const setting of response.items) {
54+
keys.push(setting.key);
55+
}
56+
}
57+
await executeParallel(
58+
async (count: number, _: number) => {
59+
await this.client.deleteConfigurationSetting({ key: keys[count] });
60+
},
61+
this.parsedOptions.count.value!,
62+
32
63+
);
64+
}
65+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../../../../tsconfig.package",
3+
"compilerOptions": {
4+
"module": "CommonJS",
5+
"declarationDir": "./typings/latest",
6+
"lib": [
7+
"ES6",
8+
"ESNext.AsyncIterable"
9+
],
10+
"noEmit": true
11+
},
12+
"compileOnSave": true,
13+
"include": [
14+
"./test/**/*.ts"
15+
]
16+
}

0 commit comments

Comments
 (0)