-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Perf Tests] Storage file share perf tests - track 1 and track 2 (#12746
) ### Depends on #12662 and #12737 ### Changes in the PR - Track 2 tests are part of the test folder, which would be compiled along with the regular tests and would require changes if the API is updated - Track 1 tests - a separate npm project, takes dependence on the perf package, doesn't get compiled along with the regular tests ### To run track 2 tests 1. Build the storage-file-share package `rush build -t storage-file-share`. 2. Navigate to `storage-file-share` folder `cd sdk\storage\storage-file-share\`. 3. Create a storage account and populate the .env file at `storage\storage-file-share` folder with `ACCOUNT_NAME` and `ACCOUNT_KEY` variables. 4. Run the tests as shown below - download - `npm run perfstress-test:node -- StorageFileShareDownloadTest --warmup 2 --duration 7 --iterations 2 --parallel 2` - download to file - `npm run perfstress-test:node -- StorageFileShareDownloadToFileTest --warmup 2 --duration 7 --iterations 2 --parallel 2` - upload - `npm run perfstress-test:node -- StorageFileShareUploadTest --warmup 2 --duration 7 --iterations 2 --parallel 2` - upload from file - `npm run perfstress-test:node -- StorageFileShareUploadFromFileTest --warmup 2 --duration 7 --iterations 2 --parallel 2` ### To run track 1 tests 1. Navigate to `test-utils\perfstress` folder `cd sdk\test-utils\perfstress\` 2. Build the package `rush update && rush build -t test-utils-perfstress` 3. Pack the perf package `rushx pack` 4. Navigate to `storage-file-share\test\perfstress\track-1` folder `cd sdk\storage\storage-file-share\test\perfstress\track-1`. 5. Install the perf package `npm i ..\..\..\..\..\test-utils\perfstress\azure-test-utils-perfstress-1.0.0.tgz` 6. Run `npm install` to get `storage-file-share V10`. 7. Create a storage account and populate the .env file with `ACCOUNT_NAME` and `ACCOUNT_KEY` variables. 8. Run the tests as follows - download - `npm run perfstress-test:node -- StorageFileShareDownloadTest --warmup 2 --duration 7 --iterations 2 --parallel 2` - upload - `npm run perfstress-test:node -- StorageFileShareUploadTest --warmup 2 --duration 7 --iterations 2 --parallel 2`
- Loading branch information
1 parent
1d7e0e4
commit 13196dd
Showing
16 changed files
with
470 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
sdk/storage/storage-file-share/test/perfstress/track-1/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
### Guide | ||
|
||
1. Navigate to `test-utils\perfstress` folder `cd sdk\test-utils\perfstress\` | ||
2. Build the package `rush update && rush build -t test-utils-perfstress` | ||
3. Pack the perf package `rushx pack` | ||
4. Navigate to `storage-file-share\test\perfstress\track-1` folder `cd sdk\storage\storage-file-share\test\perfstress\track-1`. | ||
5. Install the perf package `npm i ..\..\..\..\..\test-utils\perfstress\azure-test-utils-perfstress-1.0.0.tgz` | ||
6. Run `npm install` to get `storage-file-share V10`. | ||
7. Create a storage account and populate the .env file with `ACCOUNT_NAME` and `ACCOUNT_KEY` variables. | ||
8. Run the tests as follows | ||
- download | ||
- `npm run perfstress-test:node -- StorageFileShareDownloadTest --warmup 2 --duration 7 --iterations 2 --parallel 2` | ||
- upload | ||
- `npm run perfstress-test:node -- StorageFileShareUploadTest --warmup 2 --duration 7 --iterations 2 --parallel 2` |
48 changes: 48 additions & 0 deletions
48
sdk/storage/storage-file-share/test/perfstress/track-1/download.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressOptionDictionary, drainStream } from "@azure/test-utils-perfstress"; | ||
import { Aborter, FileURL } from "@azure/storage-file"; | ||
import { StorageFileShareTest } from "./storageTest"; | ||
import { generateUuid } from "@azure/core-http"; | ||
|
||
interface StorageFileShareDownloadTestOptions { | ||
size: number; | ||
} | ||
|
||
export class StorageFileShareDownloadTest extends StorageFileShareTest< | ||
StorageFileShareDownloadTestOptions | ||
> { | ||
buffer = Buffer.alloc(this.parsedOptions.size.value!); | ||
public options: PerfStressOptionDictionary<StorageFileShareDownloadTestOptions> = { | ||
size: { | ||
required: true, | ||
description: "Size in bytes", | ||
shortName: "sz", | ||
longName: "size", | ||
defaultValue: 1024 | ||
} | ||
}; | ||
|
||
static fileName = generateUuid(); | ||
fileClient: FileURL; | ||
|
||
constructor() { | ||
super(); | ||
this.fileClient = FileURL.fromDirectoryURL( | ||
this.directoryClient, | ||
StorageFileShareDownloadTest.fileName | ||
); | ||
} | ||
|
||
public async globalSetup() { | ||
await super.globalSetup(); | ||
await this.fileClient.create(Aborter.none, this.parsedOptions.size.value!); | ||
await this.fileClient.uploadRange(Aborter.none, this.buffer, 0, this.parsedOptions.size.value!); | ||
} | ||
|
||
async runAsync(): Promise<void> { | ||
const downloadResponse = await this.fileClient.download(Aborter.none, 0); | ||
await drainStream(downloadResponse.readableStreamBody!); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
sdk/storage/storage-file-share/test/perfstress/track-1/index.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressProgram, selectPerfStressTest } from "@azure/test-utils-perfstress"; | ||
import { StorageFileShareDownloadTest } from "./download.spec"; | ||
import { StorageFileShareUploadTest } from "./upload.spec"; | ||
console.log("=== Starting the perfStress test ==="); | ||
|
||
const perfStressProgram = new PerfStressProgram( | ||
selectPerfStressTest([StorageFileShareDownloadTest, StorageFileShareUploadTest]) | ||
); | ||
|
||
perfStressProgram.run(); |
16 changes: 16 additions & 0 deletions
16
sdk/storage/storage-file-share/test/perfstress/track-1/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "track-1", | ||
"version": "1.0.0", | ||
"description": "1. Navigate to `test-utils\\perfstress` folder `cd sdk\\test-utils\\perfstress\\`\r 2. Build the package `rush update && rush build -t test-utils-perfstress`\r 3. Pack the perf package `rushx pack`\r 4. Navigate to `storage-file-share\\test\\perfstress\\track-1` folder `cd sdk\\storage\\storage-file-share\\test\\perfstress\\track-1`.\r 5. Install the perf package `npm i ..\\..\\..\\..\\..\\test-utils\\perfstress\\azure-test-utils-perfstress-1.0.0.tgz`\r 6. Run `npm install` to get `storage-file-share V10`.\r 7. Create a storage account and populate the .env file with `ACCOUNT_NAME` and `ACCOUNT_KEY` variables.\r 8. Run the tests as follows\r - download\r - `npm run perfstress-test:node -- StorageFileShareDownloadTest --warmup 2 --duration 7 --iterations 2 --parallel 2`\r - download to file\r - `npm run perfstress-test:node -- StorageFileShareDownloadToFileTest --warmup 2 --duration 7 --iterations 2 --parallel 2`\r - upload\r - `npm run perfstress-test:node -- StorageFileShareUploadTest --warmup 2 --duration 7 --iterations 2 --parallel 2`\r - upload from file\r - `npm run perfstress-test:node -- StorageFileShareUploadFromFileTest --warmup 2 --duration 7 --iterations 2 --parallel 2`", | ||
"main": "index.js", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@azure/storage-file": "^10.3.0", | ||
"@azure/test-utils-perfstress": "file:../../../../../test-utils/perfstress/azure-test-utils-perfstress-1.0.0.tgz" | ||
}, | ||
"scripts": { | ||
"perfstress-test:node": "ts-node index.spec.ts" | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
sdk/storage/storage-file-share/test/perfstress/track-1/storageTest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressTest, getEnvVar } from "@azure/test-utils-perfstress"; | ||
import { | ||
ServiceURL, | ||
ShareURL, | ||
DirectoryURL, | ||
StorageURL, | ||
SharedKeyCredential, | ||
Aborter | ||
} from "@azure/storage-file"; | ||
|
||
// Expects the .env file at the same level as the "test" folder | ||
import * as dotenv from "dotenv"; | ||
import { generateUuid } from "@azure/core-http"; | ||
dotenv.config({ path: "../../../.env" }); | ||
|
||
export abstract class StorageFileShareTest<TOptions> extends PerfStressTest<TOptions> { | ||
shareServiceClient: ServiceURL; | ||
shareClient: ShareURL; | ||
directoryClient: DirectoryURL; | ||
static shareName = generateUuid(); | ||
static dirName = generateUuid(); | ||
|
||
constructor() { | ||
super(); | ||
const connectionString = getEnvVar("STORAGE_CONNECTION_STRING"); | ||
const accountName = getValueInConnString(connectionString, "AccountName"); | ||
const accountKey = getValueInConnString(connectionString, "AccountKey"); | ||
const sharedKeyCredential = new SharedKeyCredential(accountName, accountKey); | ||
this.shareServiceClient = new ServiceURL( | ||
`https://${accountName}.file.core.windows.net`, | ||
StorageURL.newPipeline(sharedKeyCredential) | ||
); | ||
this.shareClient = ShareURL.fromServiceURL( | ||
this.shareServiceClient, | ||
StorageFileShareTest.shareName | ||
); | ||
this.directoryClient = DirectoryURL.fromShareURL( | ||
this.shareClient, | ||
StorageFileShareTest.dirName | ||
); | ||
} | ||
|
||
public async globalSetup() { | ||
await this.shareClient.create(Aborter.none); | ||
await this.directoryClient.create(Aborter.none); | ||
} | ||
|
||
public async globalCleanup() { | ||
await this.shareClient.delete(Aborter.none); | ||
} | ||
} | ||
|
||
export function getValueInConnString( | ||
connectionString: string, | ||
argument: "AccountName" | "AccountKey" | ||
) { | ||
const elements = connectionString.split(";"); | ||
for (const element of elements) { | ||
if (element.trim().startsWith(argument)) { | ||
return element.trim().match(argument + "=(.*)")![1]; | ||
} | ||
} | ||
return ""; | ||
} |
5 changes: 5 additions & 0 deletions
5
sdk/storage/storage-file-share/test/perfstress/track-1/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
sdk/storage/storage-file-share/test/perfstress/track-1/upload.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressOptionDictionary } from "@azure/test-utils-perfstress"; | ||
import { Aborter, FileURL } from "@azure/storage-file"; | ||
import { StorageFileShareTest } from "./storageTest"; | ||
import { generateUuid } from "@azure/core-http"; | ||
|
||
interface StorageFileShareUploadTestOptions { | ||
size: number; | ||
} | ||
export class StorageFileShareUploadTest extends StorageFileShareTest< | ||
StorageFileShareUploadTestOptions | ||
> { | ||
buffer = Buffer.alloc(this.parsedOptions.size.value!); | ||
fileClient: FileURL; | ||
public options: PerfStressOptionDictionary<StorageFileShareUploadTestOptions> = { | ||
size: { | ||
required: true, | ||
description: "Size in bytes", | ||
shortName: "sz", | ||
longName: "size", | ||
defaultValue: 1024 | ||
} | ||
}; | ||
|
||
constructor() { | ||
super(); | ||
const fileName = generateUuid(); | ||
this.fileClient = FileURL.fromDirectoryURL(this.directoryClient, fileName); | ||
} | ||
|
||
async setup() { | ||
await this.fileClient.create(Aborter.none, this.parsedOptions.size.value!); | ||
} | ||
|
||
async runAsync(): Promise<void> { | ||
await this.fileClient.uploadRange(Aborter.none, this.buffer, 0, this.parsedOptions.size.value!); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
sdk/storage/storage-file-share/test/perfstress/track-2/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
### Guide | ||
|
||
1. Build the storage-file-share package `rush build -t storage-file-share`. | ||
2. Navigate to `storage-file-share` folder `cd sdk\storage\storage-file-share\`. | ||
3. Create a storage account and populate the .env file at `storage\storage-file-share` folder with `ACCOUNT_NAME` and `ACCOUNT_KEY` variables. | ||
4. Run the tests as shown below | ||
- download | ||
- `npm run perfstress-test:node -- StorageFileShareDownloadTest --warmup 2 --duration 7 --iterations 2 --parallel 2` | ||
- download to file | ||
- `npm run perfstress-test:node -- StorageFileShareDownloadToFileTest --warmup 2 --duration 7 --iterations 2 --parallel 2` | ||
- upload | ||
- `npm run perfstress-test:node -- StorageFileShareUploadTest --warmup 2 --duration 7 --iterations 2 --parallel 2` | ||
- upload from file | ||
- `npm run perfstress-test:node -- StorageFileShareUploadFromFileTest --warmup 2 --duration 7 --iterations 2 --parallel 2` |
42 changes: 42 additions & 0 deletions
42
sdk/storage/storage-file-share/test/perfstress/track-2/download.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { generateUuid } from "@azure/core-http"; | ||
import { PerfStressOptionDictionary, drainStream } from "@azure/test-utils-perfstress"; | ||
import { ShareFileClient } from "../../../src"; | ||
|
||
import { StorageFileShareTest } from "./storageTest.spec"; | ||
interface StorageFileShareDownloadTestOptions { | ||
size: number; | ||
} | ||
|
||
export class StorageFileShareDownloadTest extends StorageFileShareTest< | ||
StorageFileShareDownloadTestOptions | ||
> { | ||
public options: PerfStressOptionDictionary<StorageFileShareDownloadTestOptions> = { | ||
size: { | ||
required: true, | ||
description: "Size in bytes", | ||
shortName: "sz", | ||
longName: "size", | ||
defaultValue: 1024 | ||
} | ||
}; | ||
static fileName = generateUuid(); | ||
fileClient: ShareFileClient; | ||
|
||
constructor() { | ||
super(); | ||
this.fileClient = this.directoryClient.getFileClient(StorageFileShareDownloadTest.fileName); | ||
} | ||
|
||
public async globalSetup() { | ||
await super.globalSetup(); | ||
await this.fileClient.uploadData(Buffer.alloc(this.parsedOptions.size.value!)); | ||
} | ||
|
||
async runAsync(): Promise<void> { | ||
const downloadResponse = await this.fileClient.download(); | ||
await drainStream(downloadResponse.readableStreamBody!); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
sdk/storage/storage-file-share/test/perfstress/track-2/downloadToFile.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressOptionDictionary } from "@azure/test-utils-perfstress"; | ||
import { ShareFileClient } from "../../../src"; | ||
import fs from "fs"; | ||
import util from "util"; | ||
const fileExists = util.promisify(fs.exists); | ||
const mkdir = util.promisify(fs.mkdir); | ||
const deleteFile = util.promisify(fs.unlink); | ||
|
||
import { StorageFileShareTest } from "./storageTest.spec"; | ||
import { generateUuid } from "@azure/core-http"; | ||
interface StorageFileShareDownloadTestOptions { | ||
size: number; | ||
} | ||
|
||
const localDirName = "temp"; | ||
|
||
export class StorageFileShareDownloadToFileTest extends StorageFileShareTest< | ||
StorageFileShareDownloadTestOptions | ||
> { | ||
public options: PerfStressOptionDictionary<StorageFileShareDownloadTestOptions> = { | ||
size: { | ||
required: true, | ||
description: "Size in bytes", | ||
shortName: "sz", | ||
longName: "size", | ||
defaultValue: 1024 | ||
} | ||
}; | ||
static fileName = generateUuid(); | ||
fileClient: ShareFileClient; | ||
localFileName: string; | ||
|
||
constructor() { | ||
super(); | ||
this.fileClient = this.directoryClient.getFileClient( | ||
StorageFileShareDownloadToFileTest.fileName | ||
); | ||
this.localFileName = generateUuid(); | ||
} | ||
|
||
public async globalSetup() { | ||
await super.globalSetup(); | ||
if (!(await fileExists(localDirName))) await mkdir(localDirName); | ||
await this.fileClient.uploadData(Buffer.alloc(this.parsedOptions.size.value!)); | ||
} | ||
|
||
public async cleanup() { | ||
await deleteFile(`${localDirName}/${this.localFileName}`); | ||
} | ||
|
||
async runAsync(): Promise<void> { | ||
await this.fileClient.downloadToFile(`${localDirName}/${this.localFileName}`, 0); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
sdk/storage/storage-file-share/test/perfstress/track-2/index.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { PerfStressProgram, selectPerfStressTest } from "@azure/test-utils-perfstress"; | ||
import { StorageFileShareDownloadTest } from "./download.spec"; | ||
import { StorageFileShareDownloadToFileTest } from "./downloadToFile.spec"; | ||
import { StorageFileShareUploadTest } from "./upload.spec"; | ||
import { StorageFileShareUploadFromFileTest } from "./uploadFromFile.spec"; | ||
|
||
console.log("=== Starting the perfStress test ==="); | ||
|
||
const perfStressProgram = new PerfStressProgram( | ||
selectPerfStressTest([ | ||
StorageFileShareDownloadTest, | ||
StorageFileShareDownloadToFileTest, | ||
StorageFileShareUploadTest, | ||
StorageFileShareUploadFromFileTest | ||
]) | ||
); | ||
|
||
perfStressProgram.run(); |
Oops, something went wrong.