forked from TrueCloudLab/xk6-frostfs
34 lines
No EOL
846 B
JavaScript
34 lines
No EOL
846 B
JavaScript
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 += objName();
|
|
return key;
|
|
}
|
|
|
|
const asciiLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
|
|
|
function objName() {
|
|
if (__ENV.OBJ_NAME) {
|
|
return __ENV.OBJ_NAME;
|
|
}
|
|
const length = parseInt(__ENV.OBJ_NAME_LENGTH || '0');
|
|
if (length > 0) {
|
|
let name = "";
|
|
for (let i = 0; i < length; i++) {
|
|
name += asciiLetters.charAt(Math.floor(Math.random() * asciiLetters.length));
|
|
}
|
|
return name;
|
|
}
|
|
return uuidv4();
|
|
} |