Skip to content

Commit

Permalink
test: run read write splitting performance test
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc-bq committed Oct 25, 2024
1 parent 737571e commit cb12907
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/aurora_performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Aurora Performance Tests

on:
workflow_dispatch:
push:
branches:
- test/rwperf

jobs:
run-integration-tests:
Expand Down
1 change: 0 additions & 1 deletion common/lib/driver_connection_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { logger } from "../logutils";
import { maskProperties } from "./utils/utils";
import { ClientWrapper } from "./client_wrapper";
import { RoundRobinHostSelector } from "./round_robin_host_selector";
import { DatabaseDialect } from "./database_dialect/database_dialect";

export class DriverConnectionProvider implements ConnectionProvider {
private static readonly acceptedStrategies: Map<string, HostSelector> = new Map([
Expand Down
4 changes: 3 additions & 1 deletion common/lib/plugins/stale_dns/stale_dns_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ export class StaleDnsHelper {
}
return targetClient;
} catch (error: any) {
await this.pluginService.tryClosingTargetClient(targetClient);
if (targetClient) {
await this.pluginService.tryClosingTargetClient(targetClient);
}
}
}
return currentTargetClient;
Expand Down
1 change: 0 additions & 1 deletion mysql/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { ClientUtils } from "../../common/lib/utils/client_utils";
import { RdsMultiAZMySQLDatabaseDialect } from "./dialect/rds_multi_az_mysql_database_dialect";
import { HostInfo } from "../../common/lib/host_info";
import { TelemetryTraceLevel } from "../../common/lib/utils/telemetry/telemetry_trace_level";
import { ConnectionProviderManager } from "../../common/lib/connection_provider_manager";

export class AwsMySQLClient extends AwsClient {
private static readonly knownDialectsByCode: Map<string, DatabaseDialect> = new Map([
Expand Down
2 changes: 1 addition & 1 deletion mysql/lib/dialect/mysql_database_dialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,6 @@ export class MySQLDatabaseDialect implements DatabaseDialect {
}

async end(clientWrapper: ClientWrapper): Promise<void> {
return await clientWrapper.client.end();
return await clientWrapper.client?.end();
}
}
2 changes: 1 addition & 1 deletion pg/lib/dialect/pg_database_dialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,6 @@ export class PgDatabaseDialect implements DatabaseDialect {
}

async end(clientWrapper: ClientWrapper): Promise<void> {
return await clientWrapper.client.end();
return await clientWrapper.client?.end();
}
}
72 changes: 25 additions & 47 deletions tests/integration/container/tests/performance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import { DriverHelper } from "./utils/driver_helper";
import { ProxyHelper } from "./utils/proxy_helper";
import { AuroraTestUtility } from "./utils/aurora_test_utility";
import { TestEnvironmentFeatures } from "./utils/test_environment_features";
import * as XLSX from "xlsx";
import { anything } from "ts-mockito";
import { WrapperProperties } from "../../../../common/lib/wrapper_property";
import { features } from "./config";
import { MonitorServiceImpl } from "../../../../common/lib/plugins/efm/monitor_service";
import { PerfStat } from "./utils/perf_stat";
import { PerfTestUtility } from "./utils/perf_util";

const itIf =
features.includes(TestEnvironmentFeatures.FAILOVER_SUPPORTED) &&
Expand Down Expand Up @@ -68,7 +69,7 @@ let initClientFunc: (props: any) => any;
let auroraTestUtility: AuroraTestUtility;
let enhancedFailureMonitoringPerfDataList: PerfStatMonitoring[] = [];

async function initDefaultConfig(host: string, port: number): Promise<any> {
function initDefaultConfig(host: string, port: number): any {
let config: any = {
user: env.databaseInfo.username,
host: host,
Expand Down Expand Up @@ -109,7 +110,11 @@ async function testFailureDetectionTimeEfmEnabled() {
);
}
} finally {
doWritePerfDataToFile(`EnhancedMonitoringOnly_Db_${env.engine}_Instances_${env.instances.length}_Plugins_efm.xlsx`, "EfmOnly");
PerfTestUtility.writePerfDataToFile(
enhancedFailureMonitoringPerfDataList,
`EnhancedMonitoringOnly_Db_${env.engine}_Instances_${env.instances.length}_Plugins_efm.xlsx`,
"EfmOnly"
);
}
}

Expand All @@ -124,20 +129,12 @@ async function testFailureDetectionTimeFailoverAndEfmEnabled() {
);
}
} finally {
doWritePerfDataToFile(`FailoverWithEnhancedMonitoring_Db_${env.engine}_Instances_${env.instances.length}_Plugins_efm.xlsx`, "FailoverWithEfm");
}
}

function doWritePerfDataToFile(fileName: string, worksheetName: string) {
const rows = [];
for (let i = 0; i < enhancedFailureMonitoringPerfDataList.length; i++) {
rows.push(enhancedFailureMonitoringPerfDataList[i].writeData());
PerfTestUtility.writePerfDataToFile(
enhancedFailureMonitoringPerfDataList,
`FailoverWithEnhancedMonitoring_Db_${env.engine}_Instances_${env.instances.length}_Plugins_efm.xlsx`,
"FailoverWithEfm"
);
}
const workbook = XLSX.utils.book_new();
const worksheet = XLSX.utils.json_to_sheet(rows);
XLSX.utils.book_append_sheet(workbook, worksheet, worksheetName);
XLSX.utils.sheet_add_aoa(worksheet, enhancedFailureMonitoringPerfDataList[0].writeHeader(), { origin: "A1" });
XLSX.writeFile(workbook, __dirname + "/../reports/" + fileName);
}

async function executeFailureDetectionTimeEfmEnabled(
Expand Down Expand Up @@ -231,32 +228,23 @@ async function doMeasurePerformance(sleepDelayMillis: number, repeatTimes: numbe
}
}

let min;
let max;
let total = 0;
let iterations = 0;
for (let i = 0; i < repeatTimes; i++) {
if (!isNaN(elapsedTimeMillis[i])) {
iterations++;
total += elapsedTimeMillis[i];
if (!max || elapsedTimeMillis[i] > max) {
max = elapsedTimeMillis[i];
}
if (!min || elapsedTimeMillis[i] < min) {
min = elapsedTimeMillis[i];
}
}
}
const avg = Math.round(total / iterations);
logger.debug(`Calculated average failure detection time: ${total} / ${iterations} = ${avg}`);
const [min, max, total] = elapsedTimeMillis.reduce(
([min, max, sum], val) => {
return [Math.min(val, min), Math.max(val, max), sum + val];
},
[elapsedTimeMillis[0], elapsedTimeMillis[0], 0]
);

const avg = Math.round(total / elapsedTimeMillis.length);
logger.debug(`Calculated average failure detection time: ${total} / ${elapsedTimeMillis.length} = ${avg}`);

data.paramNetworkOutageDelayMillis = sleepDelayMillis;
data.minFailureDetectionTimeMillis = min;
data.maxFailureDetectionTimeMillis = max;
data.avgFailureDetectionTimeMillis = avg;
}

describe("performance", () => {
describe.skip("performance", () => {
beforeEach(async () => {
enhancedFailureMonitoringPerfDataList = [];
env = await TestEnvironment.getCurrent();
Expand Down Expand Up @@ -289,22 +277,12 @@ describe("performance", () => {
);
});

abstract class PerfStatBase {
class PerfStatMonitoring implements PerfStat {
paramNetworkOutageDelayMillis?: number;
minFailureDetectionTimeMillis?: number;
maxFailureDetectionTimeMillis?: number;
avgFailureDetectionTimeMillis?: number;

writeHeader(): string[][] {
return [];
}

writeData(): (number | undefined)[] {
return [];
}
}

class PerfStatMonitoring extends PerfStatBase {
paramDetectionTime?: number;
paramDetectionInterval?: number;
paramDetectionCount?: number;
Expand Down Expand Up @@ -343,7 +321,7 @@ class PerfStatMonitoring extends PerfStatBase {
`paramNetworkOutageDelayMillis=${this.paramNetworkOutageDelayMillis}, ` +
`minFailureDetectionTimeMillis=${this.minFailureDetectionTimeMillis}, ` +
`maxFailureDetectionTimeMillis=${this.maxFailureDetectionTimeMillis} ` +
`avgFailureDetectionTimeMillis=${this.avgFailureDetectionTimeMillis}`
`avgFailureDetectionTimeMillis=${this.avgFailureDetectionTimeMillis}]`
);
}
}
Loading

0 comments on commit cb12907

Please sign in to comment.