forked from Azure/azure-sdk-for-js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Service Bus] Perf tests with the framework (Azure#12993)
### New perf folder - The new "perf" folder uses the perf framework. - With the perf framework, only the send test can be written. - This PR adds the send test for track 1 and track 2. - This would be useful in comparing track 1 and track 2, as well as for the cross-language comparisons. - The track-2 tests depend on the current code on master and would require updates if the source code changes. #### To execute the track 2 tests 1. Build the service-bus package `rush build -t service-bus`. 2. Navigate to `service-bus` folder `cd sdk\servicebus\service-bus\`. 3. Create a service-bus namespace and populate the .env file at `servicebus\service-bus` folder with `SERVICEBUS_CONNECTION_STRING` variables. 4. Run the tests as follows - batch send - `npm run perf-test:node -- BatchSendTest --warmup 2 --duration 7 --parallel 2` #### To execture the track 1 tests 1. Navigate to `test-utils\perfstress` folder `cd sdk\test-utils\perfstress\` 2. Build the package `rush update && rush build -t test-utils-perfstress` 3. Pack the perf package `rushx pack` 4. Navigate to `service-bus\perf\track-1` folder `cd sdk\servicebus\service-bus\perf\track-1`. 5. Install the perf package `npm i ..\..\..\..\..\test-utils\perfstress\azure-test-utils-perfstress-1.0.0.tgz` 6. Run `npm install` to get `service-bus V1`. 7. Create a service-bus namespace and a queue with default options. Populate the .env file at `servicebus\service-bus` folder with `SERVICEBUS_CONNECTION_STRING` and `QUEUE_NAME` variables. 8. Run the tests as follows - batch send - `npm run perf-test:node -- BatchSendTest --warmup 2 --duration 7 --parallel 2` ### Existing perf tests - There is an existing "perf" folder with the tests for send and receive for `azure-sb`, `rhea-promise`, `service-bus-v1`, and `service-bus-v7` libraries. - These tests show the memory consumption too in the report. They do not use the perf framework. (And the perf framework isn't yet capable of handling the receive scenarios.) - Retaining the existing tests for the above reasons. - This PR renames the "perf" folder(with existing tests) to "perf-js-libs".
- Loading branch information
1 parent
230fd72
commit e15c042
Showing
27 changed files
with
225 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
### Guide | ||
|
||
1. Navigate to `test-utils\perfstress` folder `cd sdk\test-utils\perfstress\` | ||
2. Build the package `rush update && rush build -t test-utils-perfstress` | ||
3. Pack the perf package `rushx pack` | ||
4. Navigate to `service-bus\perf\track-1` folder `cd sdk\servicebus\service-bus\perf\track-1`. | ||
5. Install the perf package `npm i ..\..\..\..\..\test-utils\perfstress\azure-test-utils-perfstress-1.0.0.tgz` | ||
6. Run `npm install` to get `service-bus V1`. | ||
7. Create a service-bus namespace and populate the .env file at `servicebus\service-bus` folder with `SERVICEBUS_CONNECTION_STRING` and `QUEUE_NAME` variables. | ||
8. Run the tests as follows | ||
- batch send | ||
- `npm run perf-test:node -- BatchSendTest --warmup 2 --duration 7 --parallel 2` |
11 changes: 11 additions & 0 deletions
11
sdk/servicebus/service-bus/test/perf/track-1/index.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressProgram, selectPerfStressTest } from "@azure/test-utils-perfstress"; | ||
import { BatchSendTest } from "./sendBatch.spec"; | ||
|
||
console.log("=== Starting the perfStress test ==="); | ||
|
||
const perfStressProgram = new PerfStressProgram(selectPerfStressTest([BatchSendTest])); | ||
|
||
perfStressProgram.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "track-1", | ||
"version": "1.0.0", | ||
"description": "1. Build the service-bus package `rush build -t service-bus`. 2. Navigate to `service-bus` folder `cd sdk\\servicebus\\service-bus\\`. 3. Create a service-bus namespace and populate the .env file at `servicebus\\service-bus` folder with `SERVICEBUS_CONNECTION_STRING` variables. 4. Run the tests as follows", | ||
"main": "index.js", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@azure/service-bus": "^1.1.10", | ||
"@azure/test-utils-perfstress": "file:../../../../../test-utils/perfstress/azure-test-utils-perfstress-1.0.0.tgz" | ||
}, | ||
"scripts": { | ||
"perf-test:node": "ts-node index.spec.ts" | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
sdk/servicebus/service-bus/test/perf/track-1/sbBase.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressTest, getEnvVar } from "@azure/test-utils-perfstress"; | ||
import { ServiceBusClient } from "@azure/service-bus"; | ||
|
||
// Expects the .env file at the same level as the "test" folder | ||
import * as dotenv from "dotenv"; | ||
dotenv.config({ path: "../../../.env" }); | ||
|
||
const connectionString = getEnvVar("SERVICEBUS_CONNECTION_STRING"); | ||
const sbClient = ServiceBusClient.createFromConnectionString(connectionString); | ||
|
||
export abstract class ServiceBusTest<TOptions> extends PerfStressTest<TOptions> { | ||
sbClient: ServiceBusClient; | ||
static queueName = getEnvVar("QUEUE_NAME"); | ||
|
||
constructor() { | ||
super(); | ||
this.sbClient = sbClient; | ||
} | ||
|
||
public async globalCleanup() { | ||
await this.sbClient.close(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
sdk/servicebus/service-bus/test/perf/track-1/sendBatch.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressOptionDictionary } from "@azure/test-utils-perfstress"; | ||
import { SendableMessageInfo, Sender } from "@azure/service-bus"; | ||
import { ServiceBusTest } from "./sbBase.spec"; | ||
|
||
interface SendTestOptions { | ||
messageBodySize: number; | ||
numberOfMessages: number; | ||
} | ||
|
||
export class BatchSendTest extends ServiceBusTest<SendTestOptions> { | ||
sender: Sender; | ||
batch: SendableMessageInfo[]; | ||
public options: PerfStressOptionDictionary<SendTestOptions> = { | ||
messageBodySize: { | ||
required: true, | ||
description: "Size in bytes", | ||
shortName: "sz", | ||
longName: "size", | ||
defaultValue: 1024 | ||
}, | ||
numberOfMessages: { | ||
required: true, | ||
description: "Number of messages per send", | ||
shortName: "num", | ||
longName: "numberOfMessages", | ||
defaultValue: 10 | ||
} | ||
}; | ||
|
||
constructor() { | ||
super(); | ||
this.sender = this.sbClient.createQueueClient(BatchSendTest.queueName).createSender(); | ||
const sbMessage = { | ||
body: Buffer.alloc(this.parsedOptions.messageBodySize.value!) | ||
}; | ||
this.batch = new Array(this.parsedOptions.numberOfMessages.value!).fill(sbMessage); | ||
} | ||
|
||
async runAsync(): Promise<void> { | ||
await this.sender.sendBatch(this.batch); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
### Guide | ||
|
||
1. Build the service-bus package `rush build -t service-bus`. | ||
2. Navigate to `service-bus` folder `cd sdk\servicebus\service-bus\`. | ||
3. Create a service-bus namespace and populate the .env file at `servicebus\service-bus` folder with `SERVICEBUS_CONNECTION_STRING` variables. | ||
4. Run the tests as follows | ||
|
||
- simple send | ||
- `npm run perf-test:node -- SimpleSendTest --warmup 2 --duration 7 --iterations 2 --parallel 2` | ||
- batch send | ||
- `npm run perf-test:node -- BatchSendTest --warmup 2 --duration 7 --parallel 2` |
11 changes: 11 additions & 0 deletions
11
sdk/servicebus/service-bus/test/perf/track-2/index.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressProgram, selectPerfStressTest } from "@azure/test-utils-perfstress"; | ||
import { BatchSendTest } from "./sendBatch.spec"; | ||
|
||
console.log("=== Starting the perfStress test ==="); | ||
|
||
const perfStressProgram = new PerfStressProgram(selectPerfStressTest([BatchSendTest])); | ||
|
||
perfStressProgram.run(); |
32 changes: 32 additions & 0 deletions
32
sdk/servicebus/service-bus/test/perf/track-2/sbBase.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressTest, getEnvVar } from "@azure/test-utils-perfstress"; | ||
import { ServiceBusAdministrationClient, ServiceBusClient } from "../../../src"; | ||
|
||
// Expects the .env file at the same level as the "test" folder | ||
import * as dotenv from "dotenv"; | ||
dotenv.config(); | ||
|
||
const connectionString = getEnvVar("SERVICEBUS_CONNECTION_STRING"); | ||
const sbClient = new ServiceBusClient(connectionString); | ||
|
||
export abstract class ServiceBusTest<TOptions> extends PerfStressTest<TOptions> { | ||
sbClient: ServiceBusClient; | ||
static sbAdminClient = new ServiceBusAdministrationClient(connectionString); | ||
static queueName = `newqueue-${Math.ceil(Math.random() * 1000)}`; | ||
|
||
constructor() { | ||
super(); | ||
this.sbClient = sbClient; | ||
} | ||
|
||
public async globalSetup() { | ||
await ServiceBusTest.sbAdminClient.createQueue(ServiceBusTest.queueName); | ||
} | ||
|
||
public async globalCleanup() { | ||
await ServiceBusTest.sbAdminClient.deleteQueue(ServiceBusTest.queueName); | ||
await this.sbClient.close(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
sdk/servicebus/service-bus/test/perf/track-2/sendBatch.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressOptionDictionary } from "@azure/test-utils-perfstress"; | ||
import { ServiceBusMessage, ServiceBusSender } from "../../../src"; | ||
import { ServiceBusTest } from "./sbBase.spec"; | ||
|
||
interface SendTestOptions { | ||
messageBodySize: number; | ||
numberOfMessages: number; | ||
} | ||
|
||
export class BatchSendTest extends ServiceBusTest<SendTestOptions> { | ||
sender: ServiceBusSender; | ||
batch: ServiceBusMessage[]; | ||
public options: PerfStressOptionDictionary<SendTestOptions> = { | ||
messageBodySize: { | ||
required: true, | ||
description: "Size in bytes", | ||
shortName: "sz", | ||
longName: "size", | ||
defaultValue: 1024 | ||
}, | ||
numberOfMessages: { | ||
required: true, | ||
description: "Number of messages per send", | ||
shortName: "num", | ||
longName: "numberOfMessages", | ||
defaultValue: 10 | ||
} | ||
}; | ||
|
||
constructor() { | ||
super(); | ||
this.sender = this.sbClient.createSender(BatchSendTest.queueName); | ||
const sbMessage = { | ||
body: Buffer.alloc(this.parsedOptions.messageBodySize.value!) | ||
}; | ||
this.batch = new Array(this.parsedOptions.numberOfMessages.value!).fill(sbMessage); | ||
} | ||
|
||
async runAsync(): Promise<void> { | ||
await this.sender.sendMessages(this.batch); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters