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

[Schema Registry Avro] Add a serialize performance test #21057

Merged
merged 3 commits into from
Mar 28, 2022
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
23 changes: 23 additions & 0 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,11 @@
"projectFolder": "sdk/template/perf-tests/template",
"versionPolicyName": "test"
},
{
"packageName": "@azure-tests/perf-schema-registry-avro",
"projectFolder": "sdk/schemaregistry/perf-tests/schema-registry-avro",
"versionPolicyName": "test"
},
{
"packageName": "@azure/mixed-reality-remote-rendering",
"projectFolder": "sdk/remoterendering/mixed-reality-remote-rendering",
Expand Down
11 changes: 11 additions & 0 deletions sdk/schemaregistry/perf-tests/schema-registry-avro/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Performance Testing for Avro Serializer

## Instructions

1. Build the schema-registry perf tests package `rush build -t perf-schema-registry-avro`.
2. Copy the `sample.env` file and name it as `.env`.
3. Create an Event Hubs account and populate the `.env` file with the relevant credentials.
4. Run the tests as follows

- detect language
- `npm run perf-test:node -- SerializeTest --warmup 1 --iterations 10 --parallel 100 --duration 15 --items-count 1000`
49 changes: 49 additions & 0 deletions sdk/schemaregistry/perf-tests/schema-registry-avro/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@azure-tests/perf-schema-registry-avro",
"sdk-type": "perf-test",
"version": "1.0.0",
"description": "",
"main": "",
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@azure/schema-registry": "^1.0.0",
"@azure/schema-registry-avro": "^1.0.0-beta.7",
"@azure/identity": "^2.0.1",
"@azure/test-utils-perf": "^1.0.0",
"dotenv": "^8.2.0"
},
"devDependencies": {
"@types/node": "^12.0.0",
"eslint": "^7.15.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.0",
"tslib": "^2.2.0",
"ts-node": "^10.0.0",
"typescript": "~4.2.0"
},
"private": true,
"scripts": {
"perf-test:node": "ts-node test/index.spec.ts",
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build": "npm run clean && tsc -p .",
"build:samples": "echo skipped",
"build:test": "echo skipped",
"check-format": "prettier --list-different --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-* types *.tgz *.log",
"format": "prettier --write --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"test/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"integration-test": "echo skipped",
"lint:fix": "eslint --no-eslintrc -c ../../../.eslintrc.internal.json package.json test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint --no-eslintrc -c ../../../.eslintrc.internal.json package.json test --ext .ts",
"pack": "npm pack 2>&1",
"unit-test:browser": "echo skipped",
"unit-test:node": "echo skipped",
"unit-test": "echo skipped",
"test:browser": "echo skipped",
"test:node": "echo skipped",
"test": "echo skipped"
}
}
11 changes: 11 additions & 0 deletions sdk/schemaregistry/perf-tests/schema-registry-avro/sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SCHEMA_REGISTRY_ENDPOINT=<Endpoint URL>
SCHEMA_REGISTRY_GROUP=<Group name for schemas in registry>

deyaaeldeen marked this conversation as resolved.
Show resolved Hide resolved
# Used to authenticate using Azure AD as a service principal for role-based authentication
# in the tokenAuth sample.
#
# See the documentation for `EnvironmentCredential` at the following link:
# https://docs.microsoft.com/javascript/api/@azure/identity/environmentcredential
AZURE_TENANT_ID=<AD tenant id or name>
AZURE_CLIENT_ID=<ID of the user/service principal to authenticate as>
AZURE_CLIENT_SECRET=<client secret used to authenticate to Azure AD>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { PerfTest, getEnvVar } from "@azure/test-utils-perf";
import { AvroSerializer } from "@azure/schema-registry-avro";
import { SchemaRegistryClient } from "@azure/schema-registry";

// Expects the .env file at the same level
import * as dotenv from "dotenv";
import { DefaultAzureCredential } from "@azure/identity";
dotenv.config();

export abstract class AvroSerializerTest<TOptions> extends PerfTest<TOptions> {
static schema = JSON.stringify({
type: "record",
name: "AvroPerf",
namespace: "performance",
fields: [
{
name: "name",
type: "string",
},
{
name: "favoriteNumbers",
type: {
type: "array",
items: "int",
},
},
],
});

client: SchemaRegistryClient;
serializer: AvroSerializer;
groupName: string;

constructor() {
super();

const credential = new DefaultAzureCredential();

const fullyQualifiedNamespace = getEnvVar("SCHEMA_REGISTRY_ENDPOINT");
this.groupName = getEnvVar("SCHEMA_REGISTRY_GROUP");

this.client = new SchemaRegistryClient(fullyQualifiedNamespace, credential);
this.serializer = new AvroSerializer(this.client, {
groupName: this.groupName,
});
}

public async globalSetup(): Promise<void> {
const schemaObject = JSON.parse(AvroSerializerTest.schema);
await this.client.registerSchema({
definition: AvroSerializerTest.schema,
format: "Avro",
groupName: this.groupName,
name: `${schemaObject.namespace}.${schemaObject.name}`,
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { PerfProgram, selectPerfTest } from "@azure/test-utils-perf";
import { SerializeTest } from "./serialize.spec";

import dotenv from "dotenv";
dotenv.config();

console.log("=== Starting the perf test ===");

const perfProgram = new PerfProgram(selectPerfTest([SerializeTest]));

perfProgram.run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { AvroSerializerTest } from "./avroSerializerTest.spec";
import { PerfOptionDictionary } from "@azure/test-utils-perf";

interface SerializePerfTestOptions {
"items-count": number;
}

export class SerializeTest extends AvroSerializerTest<SerializePerfTestOptions> {
options: PerfOptionDictionary<SerializePerfTestOptions> = {
"items-count": {
required: false,
description: "Number of array items",
shortName: "n",
longName: "items-count",
defaultValue: 1000,
},
};
array: number[];

constructor() {
super();
this.options = this.parsedOptions;
this.array = [...Array(this.options["items-count"].value).keys()];
}

async run(): Promise<void> {
await this.serializer.serializeMessageData(
{
name: "test",
favoriteNumbers: this.array,
},
AvroSerializerTest.schema
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../../../tsconfig.package",
"compilerOptions": {
"module": "CommonJS",
"declarationDir": "./typings/latest",
"lib": ["ES6", "ESNext.AsyncIterable"],
"noEmit": true
},
"compileOnSave": true,
"include": ["./test/**/*.ts"]
}