Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Service Bus] Update perf tests to use a single sender for all instances #14460

Merged
4 commits merged into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/servicebus/service-bus/test/perf/track-1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"license": "ISC",
"dependencies": {
"@azure/service-bus": "^1.1.10",
"@azure/service-bus-v7": "npm:@azure/service-bus@^7.0.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, did not know you could do this!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Learned it yesterday! :)

All hail npm! All hail SOF!!!

"@azure/test-utils-perfstress": "file:../../../../../test-utils/perfstress/azure-test-utils-perfstress-1.0.0.tgz"
},
"scripts": {
Expand Down
17 changes: 11 additions & 6 deletions sdk/servicebus/service-bus/test/perf/track-1/sbBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@

import { PerfStressTest, getEnvVar } from "@azure/test-utils-perfstress";
import { ServiceBusClient } from "@azure/service-bus";
import { ServiceBusAdministrationClient } from "@azure/service-bus-v7";

// 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");
static sbClient: ServiceBusClient = ServiceBusClient.createFromConnectionString(connectionString);
static sbAdminClient = new ServiceBusAdministrationClient(connectionString);
static queueName = `newqueue-${Math.ceil(Math.random() * 1000)}`;

constructor() {
super();
this.sbClient = sbClient;
}

public async globalCleanup() {
await this.sbClient.close();
public async globalSetup(): Promise<void> {
await ServiceBusTest.sbAdminClient.createQueue(ServiceBusTest.queueName);
}

public async globalCleanup(): Promise<void> {
await ServiceBusTest.sbClient.close();
await ServiceBusTest.sbAdminClient.deleteQueue(ServiceBusTest.queueName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface SendTestOptions {
}

export class BatchSendTest extends ServiceBusTest<SendTestOptions> {
sender: Sender;
static sender = ServiceBusTest.sbClient.createQueueClient(BatchSendTest.queueName).createSender();
batch: SendableMessageInfo[];
public options: PerfStressOptionDictionary<SendTestOptions> = {
messageBodySize: {
Expand All @@ -32,14 +32,13 @@ export class BatchSendTest extends ServiceBusTest<SendTestOptions> {

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);
await BatchSendTest.sender.sendBatch(this.batch);
}
}
3 changes: 1 addition & 2 deletions sdk/servicebus/service-bus/test/perf/track-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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`
- `npm run perf-test:node -- BatchSendTest --warmup 1 --duration 25 --iterations 2 --parallel 32 --messageBodySize 10240 --numberOfMessages 10`
6 changes: 2 additions & 4 deletions sdk/servicebus/service-bus/test/perf/track-2/sbBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,22 @@ 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 sbClient: ServiceBusClient = new ServiceBusClient(connectionString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to do this in globalSetup()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't matter. It would work the same way.

In my mind.. I've kept globalSteup for creating the resources and the initialization of clients at the static variable declaration itself.

static sbAdminClient = new ServiceBusAdministrationClient(connectionString);
static queueName = `newqueue-${Math.ceil(Math.random() * 1000)}`;

constructor() {
super();
this.sbClient = sbClient;
}

public async globalSetup(): Promise<void> {
await ServiceBusTest.sbAdminClient.createQueue(ServiceBusTest.queueName);
}

public async globalCleanup(): Promise<void> {
await ServiceBusTest.sbClient.close();
await ServiceBusTest.sbAdminClient.deleteQueue(ServiceBusTest.queueName);
await this.sbClient.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface SendTestOptions {
}

export class BatchSendTest extends ServiceBusTest<SendTestOptions> {
sender: ServiceBusSender;
static sender: ServiceBusSender = ServiceBusTest.sbClient.createSender(BatchSendTest.queueName);
batch: ServiceBusMessage[];
public options: PerfStressOptionDictionary<SendTestOptions> = {
messageBodySize: {
Expand All @@ -32,14 +32,13 @@ export class BatchSendTest extends ServiceBusTest<SendTestOptions> {

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);
await BatchSendTest.sender.sendMessages(this.batch);
}
}