Skip to content

Commit

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

- @azure-tests/perf-storage-blob

### Issues associated with this PR

- #31338

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

Migrates @azure-tests/perf-storage-blob 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 2a34627 commit ba7b2e0
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 48 deletions.
63 changes: 47 additions & 16 deletions sdk/storage/perf-tests/storage-blob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,77 @@
"sdk-type": "perf-test",
"version": "1.0.0",
"description": "",
"main": "",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"keywords": [],
"author": "",
"license": "ISC",
"author": "Microsoft Corporation",
"license": "MIT",
"dependencies": {
"@azure-tools/test-perf": "^1.0.0",
"@azure/core-rest-pipeline": "^1.1.0",
"@azure/core-util": "^1.6.1",
"@azure/storage-blob": "^12.23.0-beta.1",
"dotenv": "^16.0.0"
"@azure/core-rest-pipeline": "^1.18.0",
"@azure/core-util": "^1.11.0",
"@azure/storage-blob": "^12.26.0",
"dotenv": "^16.0.0",
"tslib": "^2.8.1"
},
"devDependencies": {
"@azure/dev-tool": "^1.0.0",
"@types/node": "^18.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"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { StorageBlobDownloadWithSASTest } from "./dowloadWithSAS.spec";
import { StorageBlobDownloadWithSASTest } from "./dowloadWithSAS.spec.js";
import {
createDefaultHttpClient,
HttpClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Licensed under the MIT License.

import { PerfOptionDictionary, getEnvVar, drainStream } from "@azure-tools/test-perf";
import { StorageBlobTest } from "./storageTest.spec";
import { StorageBlobTest } from "./storageTest.spec.js";
import {
BlockBlobClient,
generateBlobSASQueryParameters,
BlobSASPermissions,
BlobClient,
} from "@azure/storage-blob";
import { getValueInConnString } from "./utils/utils";
import { getValueInConnString } from "./utils/utils.js";
import { randomUUID } from "@azure/core-util";

interface StorageBlobDownloadTestOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { drainStream, PerfOptionDictionary } from "@azure-tools/test-perf";
import { StorageBlobTest } from "./storageTest.spec";
import { StorageBlobTest } from "./storageTest.spec.js";
import { BlockBlobClient } from "@azure/storage-blob";
import { randomUUID } from "@azure/core-util";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Licensed under the MIT License.

import { createPerfProgram } from "@azure-tools/test-perf";
import { StorageBlobDownloadTest } from "./download.spec";
import { StorageBlobUploadTest } from "./upload.spec";
import { StorageBlobUploadFileTest } from "./uploadFromFile.spec";
import { StorageBlobListTest } from "./listBlobs.spec";
import { StorageBlobDownloadWithSASTest } from "./dowloadWithSAS.spec";
import { CoreHTTPSDownloadWithSASTest } from "./core-rest-pipeline.spec";
import { StorageBlobDownloadTest } from "./download.spec.js";
import { StorageBlobUploadTest } from "./upload.spec.js";
import { StorageBlobUploadFileTest } from "./uploadFromFile.spec.js";
import { StorageBlobListTest } from "./listBlobs.spec.js";
import { StorageBlobDownloadWithSASTest } from "./dowloadWithSAS.spec.js";
import { CoreHTTPSDownloadWithSASTest } from "./core-rest-pipeline.spec.js";

const perfProgram = createPerfProgram(
StorageBlobDownloadTest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import { randomUUID } from "@azure/core-util";
import { PerfOptionDictionary, executeParallel } from "@azure-tools/test-perf";
import { StorageBlobTest } from "./storageTest.spec";
import { StorageBlobTest } from "./storageTest.spec.js";

interface StorageBlobListTestOptions {
count: number;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import {
ContainerClient,
StorageSharedKeyCredential,
} from "@azure/storage-blob";
import { getValueInConnString } from "./utils/utils";
import { getValueInConnString } from "./utils/utils.js";

// Expects the .env file at the same level
import * as dotenv from "dotenv";
dotenv.config();
import "dotenv/config";

export abstract class StorageBlobTest<TOptions> extends PerfTest<TOptions> {
blobServiceClient: BlobServiceClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { randomUUID } from "@azure/core-util";
import { PerfOptionDictionary } from "@azure-tools/test-perf";
import { StorageBlobTest } from "./storageTest.spec";
import { StorageBlobTest } from "./storageTest.spec.js";

interface StorageBlobUploadTestOptions {
size: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import fs from "fs";
import util from "util";
import { BlockBlobClient } from "@azure/storage-blob";
const writeFile = util.promisify(fs.writeFile);
const fileExists = util.promisify(fs.exists);
const mkdir = util.promisify(fs.mkdir);
const deleteFile = util.promisify(fs.unlink);

import { StorageBlobUploadTest } from "./upload.spec";
import { existsSync } from "node:fs";
import { mkdir, unlink, writeFile } from "node:fs/promises";
import { BlockBlobClient } from "@azure/storage-blob";
import { StorageBlobUploadTest } from "./upload.spec.js";

const dirName = "temp";
const fileName = `${dirName}/upload-from-test-temp-file.txt`;
Expand All @@ -22,12 +18,12 @@ export class StorageBlobUploadFileTest extends StorageBlobUploadTest {

public async globalSetup() {
await super.globalSetup();
if (!(await fileExists(dirName))) await mkdir(dirName);
if (!existsSync(dirName)) await mkdir(dirName);
await writeFile(fileName, Buffer.alloc(this.parsedOptions.size.value!));
}

public async globalCleanup() {
await deleteFile(fileName);
await unlink(fileName);
await super.globalCleanup();
}

Expand Down
22 changes: 15 additions & 7 deletions sdk/storage/perf-tests/storage-blob/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
"extends": "../../../../tsconfig",
"compilerOptions": {
"module": "commonjs",
"declarationDir": "./types/latest",
"outDir": "./dist-esm",
"lib": ["dom", "es5", "es6", "es7", "esnext"]
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": ".",
"paths": {
"@azure-tests/perf-storage-blob": ["./src/index.js"]
}
},
"compileOnSave": true,
"exclude": ["node_modules"],
"include": ["./test/**/*.ts"]
"include": [
"src/**/*.ts",
"src/**/*.mts",
"src/**/*.cts",
"samples-dev/**/*.ts",
"test/**/*.ts",
"test/**/*.mts",
"test/**/*.cts"
]
}

0 comments on commit ba7b2e0

Please sign in to comment.