Skip to content

Commit

Permalink
[perf] Migrate @azure-tests/perf-keyvault-secrets to ESM (#32251)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR

- @azure-tests/perf-keyvault-secrets

### Issues associated with this PR

- #31338

### Describe the problem that is addressed by this PR

Migrates @azure-tests/perf-keyvault-secrets to ESM via automation.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
  • Loading branch information
mpodwysocki authored Dec 17, 2024
1 parent fe8d0b5 commit 29b642d
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 36 deletions.
57 changes: 43 additions & 14 deletions sdk/keyvault/perf-tests/keyvault-secrets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,76 @@
"sdk-type": "perf-test",
"version": "1.0.0",
"description": "",
"main": "",
"main": "./dist/commonjs/index.js",
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@azure-tools/test-perf": "^1.0.0",
"@azure/identity": "^4.0.1",
"@azure/keyvault-secrets": "^4.4.0-beta.2",
"@azure/identity": "^4.5.0",
"@azure/keyvault-secrets": "^4.9.0",
"dotenv": "^16.0.0",
"uuid": "^8.3.0"
"tslib": "^2.2.0"
},
"devDependencies": {
"@azure/dev-tool": "^1.0.0",
"@types/node": "^18.0.0",
"@types/uuid": "^8.0.0",
"eslint": "^9.9.0",
"ts-node": "^10.0.0",
"tslib": "^2.2.0",
"typescript": "~5.6.2"
},
"private": true,
"scripts": {
"build": "npm run clean && tsc -p .",
"build": "npm run clean && dev-tool run build-package",
"build:samples": "echo skipped",
"build:test": "echo skipped",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"test/**/*.ts\" \"*.{js,json}\"",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\"",
"clean": "dev-tool run vendored rimraf --glob dist dist-* types *.tgz *.log",
"format": "dev-tool run vendored prettier --write --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"test/**/*.ts\" \"*.{js,json}\"",
"format": "dev-tool run vendored prettier --write --config ../../../../.prettierrc.json --ignore-path ../../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\"",
"integration-test": "echo skipped",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"lint": "eslint -c ../../../../common/tools/eslint-plugin-azure-sdk/eslint.perftests.config.mjs test",
"lint:fix": "eslint -c ../../../../common/tools/eslint-plugin-azure-sdk/eslint.perftests.config.mjs test --fix --fix-type [problem,suggestion]",
"lint": "dev-tool run vendored eslint -c ../../../../common/tools/eslint-plugin-azure-sdk/eslint.perftests.config.mjs src",
"lint:fix": "dev-tool run vendored eslint -c ../../../../common/tools/eslint-plugin-azure-sdk/eslint.perftests.config.mjs src --fix --fix-type [problem,suggestion]",
"pack": "npm pack 2>&1",
"perf-test:node": "npm run build && node dist-esm/index.spec.js",
"perf-test:node": "npm run build && node dist/esm/index.js",
"test": "echo skipped",
"test:browser": "echo skipped",
"test:node": "echo skipped",
"unit-test": "echo skipped",
"unit-test:browser": "echo skipped",
"unit-test:node": "echo skipped",
"update-snippets": "echo skipped"
}
},
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"selfLink": false
},
"files": [
"dist/",
"README.md",
"LICENSE"
],
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"types": "./dist/commonjs/index.d.ts",
"module": "./dist/esm/index.js"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { SecretTest } from "./secretTest";
import { v4 as uuid } from "uuid";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { SecretTest } from "./secretTest.js";
import { randomUUID } from "node:crypto";

export class GetSecretTest extends SecretTest {
static secretName = `s-${uuid()}`;
static secretName = `s-${randomUUID()}`;

public options = {};

Expand Down
10 changes: 10 additions & 0 deletions sdk/keyvault/perf-tests/keyvault-secrets/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { createPerfProgram } from "@azure-tools/test-perf";
import { GetSecretTest } from "./getSecret.spec.js";
import { ListSecretsTest } from "./listSecrets.spec.js";

const perfProgram = createPerfProgram(GetSecretTest, ListSecretsTest);

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

import { PerfOptionDictionary } from "@azure-tools/test-perf";
import { SecretTest } from "./secretTest";
import { v4 as uuid } from "uuid";
import { SecretTest } from "./secretTest.js";
import { randomUUID } from "node:crypto";

interface ListSecretPerfTestOptions {
count: number;
Expand Down Expand Up @@ -32,7 +35,7 @@ export class ListSecretsTest extends SecretTest<ListSecretPerfTestOptions> {
}

const secretToCreate = Array.from({ length: this.parsedOptions.count.value! }, (_x, i) => {
const name = `s${i}-${uuid()}`;
const name = `s${i}-${randomUUID()}`;
ListSecretsTest.secretsToDelete.push(name);
return this.secretClient.setSecret(name, "value");
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { SecretClient } from "@azure/keyvault-secrets";
import { PerfTest } from "@azure-tools/test-perf";
import { keyVaultUri, credential } from "./utils";
import { keyVaultUri, credential } from "./utils.js";

export abstract class SecretTest<TOptions = Record<string, unknown>> extends PerfTest<TOptions> {
secretClient: SecretClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { ClientSecretCredential } from "@azure/identity";
import { getEnvVar } from "@azure-tools/test-perf";
import * as dotenv from "dotenv";

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

export const credential = new ClientSecretCredential(
getEnvVar("AZURE_TENANT_ID"),
Expand Down
7 changes: 0 additions & 7 deletions sdk/keyvault/perf-tests/keyvault-secrets/test/index.spec.ts

This file was deleted.

20 changes: 15 additions & 5 deletions sdk/keyvault/perf-tests/keyvault-secrets/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
{
"extends": "../../../../tsconfig",
"compilerOptions": {
"module": "CommonJS",
"target": "ES2015",
"lib": ["ES6", "ESNext.AsyncIterable"],
"noEmit": true
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": ".",
"paths": {
"@azure-tests/perf-keyvault-secrets": ["./src/index"]
}
},
"compileOnSave": true,
"exclude": ["node_modules"],
"include": ["./test/**/*.ts"]
"include": [
"src/**/*.ts",
"src/**/*.mts",
"src/**/*.cts",
"samples-dev/**/*.ts",
"src/**/*.ts",
"src/**/*.mts",
"src/**/*.cts"
]
}

0 comments on commit 29b642d

Please sign in to comment.