From e0cbc3b763328383df4df58f8b8de3286d0660d1 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Wed, 23 Oct 2024 17:14:54 +0300 Subject: [PATCH] [#124] s3: Allow to specify directory height and width Signed-off-by: Dmitrii Stepanov --- scenarios/libs/keygen.js | 17 +++++++++++++++++ scenarios/run_scenarios.md | 1 + scenarios/s3.js | 5 ++--- scenarios/s3_car.js | 4 ++-- scenarios/s3_dar.js | 4 ++-- scenarios/s3_multipart.js | 4 ++-- scenarios/s3local.js | 3 ++- 7 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 scenarios/libs/keygen.js diff --git a/scenarios/libs/keygen.js b/scenarios/libs/keygen.js new file mode 100644 index 0000000..f6a9aa5 --- /dev/null +++ b/scenarios/libs/keygen.js @@ -0,0 +1,17 @@ +import {uuidv4} from './k6-utils-1.4.0.js'; + +export function generateS3Key() { + let width = parseInt(__ENV.DIR_WIDTH || '0'); + let height = parseInt(__ENV.DIR_HEIGHT || '0'); + + let key = '' + if (width > 0 && height > 0) { + for (let index = 0; index < height; index++) { + const w = Math.floor(Math.random() * width) + 1; + key = key + 'dir' + w + '/'; + } + } + + key += (__ENV.OBJ_NAME || uuidv4()); + return key; +} \ No newline at end of file diff --git a/scenarios/run_scenarios.md b/scenarios/run_scenarios.md index 5dcb733..468340a 100644 --- a/scenarios/run_scenarios.md +++ b/scenarios/run_scenarios.md @@ -138,6 +138,7 @@ Options (in addition to the common options): * `DELETE_AGE` - age of object in seconds before which it can not be deleted. This parameter can be used to control how many objects we have in the system under load. * `SLEEP_DELETE` - time interval (in seconds) between deleting VU iterations. * `OBJ_NAME` - if specified, this name will be used for all write operations instead of random generation. + * `DIR_HEIGHT`, `DIR_WIDTH` - if both specified, object name will consist of `DIR_HEIGHT` directories, each of which can have `DIR_WIDTH` subdirectories, for example for `DIR_HEIGHT = 3, DIR_WIDTH = 100`, object names will be `/dir{1...100}/dir{1...100}/dir{1...100}/{uuid || OBJ_NAME}` ## S3 Multipart diff --git a/scenarios/s3.js b/scenarios/s3.js index aa707c9..d9f738c 100644 --- a/scenarios/s3.js +++ b/scenarios/s3.js @@ -6,10 +6,9 @@ import registry from 'k6/x/frostfs/registry'; import s3 from 'k6/x/frostfs/s3'; import stats from 'k6/x/frostfs/stats'; -import {newGenerator} from './libs/datagen.js'; +import {generateS3Key} from './libs/keygen.js'; import {parseEnv} from './libs/env-parser.js'; import {textSummary} from './libs/k6-summary-0.0.2.js'; -import {uuidv4} from './libs/k6-utils-1.4.0.js'; parseEnv(); @@ -159,7 +158,7 @@ export function obj_write() { sleep(__ENV.SLEEP_WRITE); } - const key = __ENV.OBJ_NAME || uuidv4(); + const key = generateS3Key(); const bucket = bucket_list[Math.floor(Math.random() * bucket_list.length)]; const payload = generator.genPayload(); diff --git a/scenarios/s3_car.js b/scenarios/s3_car.js index 2aaa94e..af89e09 100644 --- a/scenarios/s3_car.js +++ b/scenarios/s3_car.js @@ -5,10 +5,10 @@ import registry from 'k6/x/frostfs/registry'; import s3 from 'k6/x/frostfs/s3'; import stats from 'k6/x/frostfs/stats'; +import {generateS3Key} from './libs/keygen.js'; import {newGenerator} from './libs/datagen.js'; import {parseEnv} from './libs/env-parser.js'; import {textSummary} from './libs/k6-summary-0.0.2.js'; -import {uuidv4} from './libs/k6-utils-1.4.0.js'; parseEnv(); @@ -177,7 +177,7 @@ export function obj_write() { sleep(__ENV.SLEEP_WRITE); } - const key = __ENV.OBJ_NAME || uuidv4(); + const key = generateS3Key(); const bucket = bucket_list[Math.floor(Math.random() * bucket_list.length)]; const payload = generator.genPayload(); diff --git a/scenarios/s3_dar.js b/scenarios/s3_dar.js index 5f10bd0..d9a71da 100644 --- a/scenarios/s3_dar.js +++ b/scenarios/s3_dar.js @@ -6,10 +6,10 @@ import registry from 'k6/x/frostfs/registry'; import s3 from 'k6/x/frostfs/s3'; import stats from 'k6/x/frostfs/stats'; +import {generateS3Key} from './libs/keygen.js'; import {newGenerator} from './libs/datagen.js'; import {parseEnv} from './libs/env-parser.js'; import {textSummary} from './libs/k6-summary-0.0.2.js'; -import {uuidv4} from './libs/k6-utils-1.4.0.js'; parseEnv(); @@ -159,7 +159,7 @@ export function obj_write() { sleep(__ENV.SLEEP_WRITE); } - const key = __ENV.OBJ_NAME || uuidv4(); + const key = generateS3Key(); const bucket = bucket_list[Math.floor(Math.random() * bucket_list.length)]; const payload = generator.genPayload(); diff --git a/scenarios/s3_multipart.js b/scenarios/s3_multipart.js index 2b94ddc..10a6d62 100644 --- a/scenarios/s3_multipart.js +++ b/scenarios/s3_multipart.js @@ -5,10 +5,10 @@ import registry from 'k6/x/frostfs/registry'; import s3 from 'k6/x/frostfs/s3'; import stats from 'k6/x/frostfs/stats'; +import {generateS3Key} from './libs/keygen.js'; import {newGenerator} from './libs/datagen.js'; import {parseEnv} from './libs/env-parser.js'; import {textSummary} from './libs/k6-summary-0.0.2.js'; -import {uuidv4} from './libs/k6-utils-1.4.0.js'; parseEnv(); @@ -101,7 +101,7 @@ export function obj_write_multipart() { sleep(__ENV.SLEEP_WRITE); } - const key = __ENV.OBJ_NAME || uuidv4(); + const key = generateS3Key(); const bucket = bucket_list[Math.floor(Math.random() * bucket_list.length)]; const payload = generator.genPayload(); diff --git a/scenarios/s3local.js b/scenarios/s3local.js index 6eaf049..f17a556 100644 --- a/scenarios/s3local.js +++ b/scenarios/s3local.js @@ -5,6 +5,7 @@ import registry from 'k6/x/frostfs/registry'; import s3local from 'k6/x/frostfs/s3local'; import stats from 'k6/x/frostfs/stats'; +import {generateS3Key} from './libs/keygen.js'; import {newGenerator} from './libs/datagen.js'; import {parseEnv} from './libs/env-parser.js'; import {textSummary} from './libs/k6-summary-0.0.2.js'; @@ -131,7 +132,7 @@ export function handleSummary(data) { } export function obj_write() { - const key = __ENV.OBJ_NAME || uuidv4(); + const key = generateS3Key(); const bucket = bucket_list[Math.floor(Math.random() * bucket_list.length)]; const payload = generator.genPayload(); -- 2.45.2