Skip to content

Commit

Permalink
configureClientOptions core-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshaNalluru authored Jan 31, 2022
1 parent ed6718a commit 725c2d9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
6 changes: 3 additions & 3 deletions sdk/tables/perf-tests/data-tables/test/tables.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export abstract class TablesTest<TOptions = Record<string, unknown>> extends Per
constructor(tableName: string) {
super();
const connectionString = getEnvVar("SAS_CONNECTION_STRING");
this.client = this.configureClient(
TableClient.fromConnectionString(connectionString, tableName)
);
this.client =
TableClient.fromConnectionString(connectionString, tableName, this.configureClientOptions({}))

}

public async globalSetup() {
Expand Down
29 changes: 28 additions & 1 deletion sdk/test-utils/perf/src/batchPerfTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import { HttpClient } from "@azure/core-http";
import { Pipeline } from "@azure/core-rest-pipeline";
import { PerfTestBase } from "./perfTestBase";
import { PerfParallel } from "./parallel";
import { AdditionalPolicyConfig } from "@azure/core-client";

/**
* Enables writing perf tests where the number of operations are dynamic for the method/call being tested.
*/
export abstract class BatchPerfTest<
TOptions = Record<string, unknown>
> extends PerfTestBase<TOptions> {
> extends PerfTestBase<TOptions> {
private readonly testProxy!: string;
public testProxyHttpClient!: TestProxyHttpClient;
public testProxyHttpClientV1!: TestProxyHttpClientV1;
Expand Down Expand Up @@ -77,6 +78,32 @@ export abstract class BatchPerfTest<
return client;
}

/**
* configureClientOptions
*
* For core-v2 - libraries depending on core-rest-pipeline
* Apply this method on the client to get the proxy tool support.
*
* Note: Client Options must have "additionalPolicies" as part of the options.
*/
public configureClientOptions<T extends { additionalPolicies?: AdditionalPolicyConfig[] }>(options: T): T {
if (this.testProxy) {
this.testProxyHttpClient = new TestProxyHttpClient(
this.testProxy,
this.parsedOptions["insecure"].value ?? false
);
if (!options.additionalPolicies) options.additionalPolicies = [];
options.additionalPolicies.push({
policy: testProxyHttpPolicy(
this.testProxyHttpClient,
this.testProxy.startsWith("https"),
this.parsedOptions["insecure"].value ?? false
), position: "perRetry"
})
}
return options;
}

/**
* Runs the test in scope repeatedly, without waiting for any promises to finish,
* as many times as possible until durationMilliseconds is reached.
Expand Down

0 comments on commit 725c2d9

Please sign in to comment.