[#131] scenarios: Format js files with clang formatter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
0c4e2665ba
commit
93aaec4e0d
9 changed files with 1038 additions and 994 deletions
|
@ -1,38 +1,42 @@
|
|||
import native from 'k6/x/frostfs/native';
|
||||
import {sleep} from 'k6';
|
||||
import {SharedArray} from 'k6/data';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import native from 'k6/x/frostfs/native';
|
||||
import registry from 'k6/x/frostfs/registry';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
import { SharedArray } from 'k6/data';
|
||||
import { sleep } from 'k6';
|
||||
import { textSummary } from './libs/k6-summary-0.0.2.js';
|
||||
import { parseEnv } from './libs/env-parser.js';
|
||||
import { uuidv4 } from './libs/k6-utils-1.4.0.js';
|
||||
import { newGenerator } from './libs/datagen.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();
|
||||
|
||||
const obj_list = new SharedArray('obj_list', function () {
|
||||
const obj_list = new SharedArray('obj_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).objects;
|
||||
});
|
||||
|
||||
const container_list = new SharedArray('container_list', function () {
|
||||
const container_list = new SharedArray('container_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).containers;
|
||||
});
|
||||
|
||||
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size;
|
||||
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json";
|
||||
const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
|
||||
|
||||
// Select random gRPC endpoint for current VU
|
||||
const grpc_endpoints = __ENV.GRPC_ENDPOINTS.split(',');
|
||||
const grpc_endpoint = grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)];
|
||||
const grpc_client = native.connect(grpc_endpoint, '',
|
||||
__ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5,
|
||||
const grpc_endpoint =
|
||||
grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)];
|
||||
const grpc_client = native.connect(
|
||||
grpc_endpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5,
|
||||
__ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_TIMEOUT) : 60,
|
||||
__ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === "true" : false);
|
||||
const log = logging.new().withField("endpoint", grpc_endpoint);
|
||||
__ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === 'true' :
|
||||
false);
|
||||
const log = logging.new().withField('endpoint', grpc_endpoint);
|
||||
|
||||
const registry_enabled = !!__ENV.REGISTRY_FILE;
|
||||
const obj_registry = registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
const obj_registry =
|
||||
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
|
||||
const duration = __ENV.DURATION;
|
||||
|
||||
|
@ -44,28 +48,22 @@ const delete_age = __ENV.DELETE_AGE ? parseInt(__ENV.DELETE_AGE) : undefined;
|
|||
let obj_to_delete_selector = undefined;
|
||||
if (registry_enabled && delete_age) {
|
||||
obj_to_delete_selector = registry.getSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_delete",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
__ENV.REGISTRY_FILE, 'obj_to_delete',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
age: delete_age,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10;
|
||||
let obj_to_read_selector = undefined;
|
||||
if (registry_enabled) {
|
||||
obj_to_read_selector = registry.getLoopedSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_read",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
__ENV.REGISTRY_FILE, 'obj_to_read',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
age: read_age,
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const scenarios = {};
|
||||
|
@ -97,7 +95,8 @@ if (read_vu_count > 0) {
|
|||
const delete_vu_count = parseInt(__ENV.DELETERS || '0');
|
||||
if (delete_vu_count > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
throw new Error('Positive DELETE worker number without a proper object selector');
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -126,7 +125,8 @@ export function setup() {
|
|||
console.log(`Total VUs: ${total_vu_count}`);
|
||||
|
||||
const start_timestamp = Date.now()
|
||||
console.log(`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function teardown(data) {
|
||||
|
@ -134,12 +134,13 @@ export function teardown(data) {
|
|||
obj_registry.close();
|
||||
}
|
||||
const end_timestamp = Date.now()
|
||||
console.log(`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return {
|
||||
'stdout': textSummary(data, { indent: ' ', enableColors: false }),
|
||||
'stdout': textSummary(data, {indent: ' ', enableColors: false}),
|
||||
[summary_json]: JSON.stringify(data),
|
||||
};
|
||||
}
|
||||
|
@ -149,20 +150,20 @@ export function obj_write() {
|
|||
sleep(__ENV.SLEEP_WRITE);
|
||||
}
|
||||
|
||||
const headers = {
|
||||
unique_header: uuidv4()
|
||||
};
|
||||
const container = container_list[Math.floor(Math.random() * container_list.length)];
|
||||
const headers = {unique_header: uuidv4()};
|
||||
const container =
|
||||
container_list[Math.floor(Math.random() * container_list.length)];
|
||||
|
||||
const payload = generator.genPayload();
|
||||
const resp = grpc_client.put(container, headers, payload, write_grpc_chunk_size);
|
||||
const resp =
|
||||
grpc_client.put(container, headers, payload, write_grpc_chunk_size);
|
||||
if (!resp.success) {
|
||||
log.withField("cid", container).error(resp.error);
|
||||
log.withField('cid', container).error(resp.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj_registry) {
|
||||
obj_registry.addObject(container, resp.object_id, "", "", payload.hash());
|
||||
obj_registry.addObject(container, resp.object_id, '', '', payload.hash());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +172,7 @@ export function obj_read() {
|
|||
sleep(__ENV.SLEEP_READ);
|
||||
}
|
||||
|
||||
if(obj_to_read_selector) {
|
||||
if (obj_to_read_selector) {
|
||||
const obj = obj_to_read_selector.nextObject();
|
||||
if (!obj) {
|
||||
return;
|
||||
|
|
|
@ -1,38 +1,42 @@
|
|||
import native from 'k6/x/frostfs/native';
|
||||
import {sleep} from 'k6';
|
||||
import {SharedArray} from 'k6/data';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import native from 'k6/x/frostfs/native';
|
||||
import registry from 'k6/x/frostfs/registry';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
import { SharedArray } from 'k6/data';
|
||||
import { sleep } from 'k6';
|
||||
import { textSummary } from './libs/k6-summary-0.0.2.js';
|
||||
import { parseEnv } from './libs/env-parser.js';
|
||||
import { uuidv4 } from './libs/k6-utils-1.4.0.js';
|
||||
import { newGenerator } from './libs/datagen.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();
|
||||
|
||||
const obj_list = new SharedArray('obj_list', function () {
|
||||
const obj_list = new SharedArray('obj_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).objects;
|
||||
});
|
||||
|
||||
const container_list = new SharedArray('container_list', function () {
|
||||
const container_list = new SharedArray('container_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).containers;
|
||||
});
|
||||
|
||||
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size;
|
||||
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json";
|
||||
const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
|
||||
|
||||
// Select random gRPC endpoint for current VU
|
||||
const grpc_endpoints = __ENV.GRPC_ENDPOINTS.split(',');
|
||||
const grpc_endpoint = grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)];
|
||||
const grpc_client = native.connect(grpc_endpoint, '',
|
||||
__ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5,
|
||||
const grpc_endpoint =
|
||||
grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)];
|
||||
const grpc_client = native.connect(
|
||||
grpc_endpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5,
|
||||
__ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_TIMEOUT) : 60,
|
||||
__ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === "true" : false);
|
||||
const log = logging.new().withField("endpoint", grpc_endpoint);
|
||||
__ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === 'true' :
|
||||
false);
|
||||
const log = logging.new().withField('endpoint', grpc_endpoint);
|
||||
|
||||
const registry_enabled = !!__ENV.REGISTRY_FILE;
|
||||
const obj_registry = registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
const obj_registry =
|
||||
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
|
||||
const duration = __ENV.DURATION;
|
||||
|
||||
|
@ -44,28 +48,22 @@ const delete_age = __ENV.DELETE_AGE ? parseInt(__ENV.DELETE_AGE) : undefined;
|
|||
let obj_to_delete_selector = undefined;
|
||||
if (registry_enabled && delete_age) {
|
||||
obj_to_delete_selector = registry.getSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_delete",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
__ENV.REGISTRY_FILE, 'obj_to_delete',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
age: delete_age,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10;
|
||||
let obj_to_read_selector = undefined;
|
||||
if (registry_enabled) {
|
||||
obj_to_read_selector = registry.getLoopedSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_read",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
__ENV.REGISTRY_FILE, 'obj_to_read',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
age: read_age,
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const scenarios = {};
|
||||
|
@ -110,7 +108,8 @@ const max_delete_vus = parseInt(__ENV.MAX_DELETERS || pre_alloc_write_vus);
|
|||
const delete_rate = parseInt(__ENV.DELETE_RATE || '0');
|
||||
if (delete_rate > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
throw new Error('Positive DELETE worker number without a proper object selector');
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -131,7 +130,8 @@ export const options = {
|
|||
};
|
||||
|
||||
export function setup() {
|
||||
const total_pre_allocated_vu_count = pre_alloc_write_vus + pre_alloc_read_vus + pre_alloc_delete_vus;
|
||||
const total_pre_allocated_vu_count =
|
||||
pre_alloc_write_vus + pre_alloc_read_vus + pre_alloc_delete_vus;
|
||||
const total_max_vu_count = max_read_vus + max_write_vus + max_delete_vus
|
||||
|
||||
console.log(`Pregenerated containers: ${container_list.length}`);
|
||||
|
@ -151,7 +151,8 @@ export function setup() {
|
|||
console.log(`Delete rate: ${delete_rate}`);
|
||||
|
||||
const start_timestamp = Date.now()
|
||||
console.log(`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function teardown(data) {
|
||||
|
@ -159,12 +160,13 @@ export function teardown(data) {
|
|||
obj_registry.close();
|
||||
}
|
||||
const end_timestamp = Date.now()
|
||||
console.log(`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return {
|
||||
'stdout': textSummary(data, { indent: ' ', enableColors: false }),
|
||||
'stdout': textSummary(data, {indent: ' ', enableColors: false}),
|
||||
[summary_json]: JSON.stringify(data),
|
||||
};
|
||||
}
|
||||
|
@ -174,20 +176,20 @@ export function obj_write() {
|
|||
sleep(__ENV.SLEEP_WRITE);
|
||||
}
|
||||
|
||||
const headers = {
|
||||
unique_header: uuidv4()
|
||||
};
|
||||
const container = container_list[Math.floor(Math.random() * container_list.length)];
|
||||
const headers = {unique_header: uuidv4()};
|
||||
const container =
|
||||
container_list[Math.floor(Math.random() * container_list.length)];
|
||||
|
||||
const payload = generator.genPayload();
|
||||
const resp = grpc_client.put(container, headers, payload, write_grpc_chunk_size);
|
||||
const resp =
|
||||
grpc_client.put(container, headers, payload, write_grpc_chunk_size);
|
||||
if (!resp.success) {
|
||||
log.withField("cid", container).error(resp.error);
|
||||
log.withField('cid', container).error(resp.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj_registry) {
|
||||
obj_registry.addObject(container, resp.object_id, "", "", payload.hash());
|
||||
obj_registry.addObject(container, resp.object_id, '', '', payload.hash());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +198,7 @@ export function obj_read() {
|
|||
sleep(__ENV.SLEEP_READ);
|
||||
}
|
||||
|
||||
if(obj_to_read_selector) {
|
||||
if (obj_to_read_selector) {
|
||||
const obj = obj_to_read_selector.nextObject();
|
||||
if (!obj) {
|
||||
return;
|
||||
|
|
|
@ -1,34 +1,37 @@
|
|||
import {sleep} from 'k6';
|
||||
import {SharedArray} from 'k6/data';
|
||||
import http from 'k6/http';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import registry from 'k6/x/frostfs/registry';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
import http from 'k6/http';
|
||||
import { SharedArray } from 'k6/data';
|
||||
import { sleep } from 'k6';
|
||||
import { textSummary } from './libs/k6-summary-0.0.2.js';
|
||||
import { parseEnv } from './libs/env-parser.js';
|
||||
import { uuidv4 } from './libs/k6-utils-1.4.0.js';
|
||||
import { newGenerator } from './libs/datagen.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();
|
||||
|
||||
const obj_list = new SharedArray('obj_list', function () {
|
||||
const obj_list = new SharedArray('obj_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).objects;
|
||||
});
|
||||
|
||||
const container_list = new SharedArray('container_list', function () {
|
||||
const container_list = new SharedArray('container_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).containers;
|
||||
});
|
||||
|
||||
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size;
|
||||
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json";
|
||||
const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
|
||||
|
||||
// Select random HTTP endpoint for current VU
|
||||
const http_endpoints = __ENV.HTTP_ENDPOINTS.split(',');
|
||||
const http_endpoint = http_endpoints[Math.floor(Math.random() * http_endpoints.length)];
|
||||
const log = logging.new().withField("endpoint", http_endpoint);
|
||||
const http_endpoint =
|
||||
http_endpoints[Math.floor(Math.random() * http_endpoints.length)];
|
||||
const log = logging.new().withField('endpoint', http_endpoint);
|
||||
|
||||
const registry_enabled = !!__ENV.REGISTRY_FILE;
|
||||
const obj_registry = registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
const obj_registry =
|
||||
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
|
||||
const duration = __ENV.DURATION;
|
||||
|
||||
|
@ -77,7 +80,8 @@ export function setup() {
|
|||
console.log(`Total VUs: ${total_vu_count}`);
|
||||
|
||||
const start_timestamp = Date.now()
|
||||
console.log(`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function teardown(data) {
|
||||
|
@ -85,12 +89,13 @@ export function teardown(data) {
|
|||
obj_registry.close();
|
||||
}
|
||||
const end_timestamp = Date.now()
|
||||
console.log(`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return {
|
||||
'stdout': textSummary(data, { indent: ' ', enableColors: false }),
|
||||
'stdout': textSummary(data, {indent: ' ', enableColors: false}),
|
||||
[summary_json]: JSON.stringify(data),
|
||||
};
|
||||
}
|
||||
|
@ -100,14 +105,16 @@ export function obj_write() {
|
|||
sleep(__ENV.SLEEP_WRITE);
|
||||
}
|
||||
|
||||
const container = container_list[Math.floor(Math.random() * container_list.length)];
|
||||
const container =
|
||||
container_list[Math.floor(Math.random() * container_list.length)];
|
||||
|
||||
const payload = generator.genPayload();
|
||||
const data = {
|
||||
field: uuidv4(),
|
||||
// Because we use `file` wrapping and it is not straightforward to use streams here,
|
||||
// Because we use `file` wrapping and it is not straightforward to use
|
||||
// streams here,
|
||||
// `-e STREAMING=1` has no effect for this scenario.
|
||||
file: http.file(payload.bytes(), "random.data"),
|
||||
file: http.file(payload.bytes(), 'random.data'),
|
||||
};
|
||||
|
||||
const resp = http.post(`http://${http_endpoint}/upload/${container}`, data);
|
||||
|
@ -117,7 +124,7 @@ export function obj_write() {
|
|||
}
|
||||
const object_id = JSON.parse(resp.body).object_id;
|
||||
if (obj_registry) {
|
||||
obj_registry.addObject(container, object_id, "", "", payload.hash());
|
||||
obj_registry.addObject(container, object_id, '', '', payload.hash());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,8 +134,10 @@ export function obj_read() {
|
|||
}
|
||||
|
||||
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
|
||||
const resp = http.get(`http://${http_endpoint}/get/${obj.container}/${obj.object}`);
|
||||
const resp =
|
||||
http.get(`http://${http_endpoint}/get/${obj.container}/${obj.object}`);
|
||||
if (resp.status != 200) {
|
||||
log.withFields({status: resp.status, cid: obj.container, oid: obj.object}).error(resp.error);
|
||||
log.withFields({status: resp.status, cid: obj.container, oid: obj.object})
|
||||
.error(resp.error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,41 @@
|
|||
import {SharedArray} from 'k6/data';
|
||||
import exec from 'k6/execution';
|
||||
import local from 'k6/x/frostfs/local';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import registry from 'k6/x/frostfs/registry';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
import { SharedArray } from 'k6/data';
|
||||
import { textSummary } from './libs/k6-summary-0.0.2.js';
|
||||
import { parseEnv } from './libs/env-parser.js';
|
||||
import { uuidv4 } from './libs/k6-utils-1.4.0.js';
|
||||
import exec from 'k6/execution';
|
||||
import { newGenerator } from './libs/datagen.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();
|
||||
|
||||
const obj_list = new SharedArray('obj_list', function () {
|
||||
const obj_list = new SharedArray('obj_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).objects;
|
||||
});
|
||||
|
||||
const container_list = new SharedArray('container_list', function () {
|
||||
const container_list = new SharedArray('container_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).containers;
|
||||
});
|
||||
|
||||
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size;
|
||||
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json";
|
||||
const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
|
||||
|
||||
const config_file = __ENV.CONFIG_FILE;
|
||||
const config_dir = __ENV.CONFIG_DIR;
|
||||
const debug_logger = (__ENV.DEBUG_LOGGER || 'false') == 'true';
|
||||
const max_total_size_gb = __ENV.MAX_TOTAL_SIZE_GB ? parseInt(__ENV.MAX_TOTAL_SIZE_GB) : 0;
|
||||
const local_client = local.connect(config_file, config_dir, '', debug_logger, max_total_size_gb);
|
||||
const log = logging.new().withFields({"config_file": config_file,"config_dir": config_dir});
|
||||
const max_total_size_gb =
|
||||
__ENV.MAX_TOTAL_SIZE_GB ? parseInt(__ENV.MAX_TOTAL_SIZE_GB) : 0;
|
||||
const local_client =
|
||||
local.connect(config_file, config_dir, '', debug_logger, max_total_size_gb);
|
||||
const log = logging.new().withFields(
|
||||
{'config_file': config_file, 'config_dir': config_dir});
|
||||
|
||||
const registry_enabled = !!__ENV.REGISTRY_FILE;
|
||||
const obj_registry = registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
const obj_registry =
|
||||
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
|
||||
const duration = __ENV.DURATION;
|
||||
|
||||
|
@ -42,14 +47,11 @@ const delete_age = __ENV.DELETE_AGE ? parseInt(__ENV.DELETE_AGE) : undefined;
|
|||
let obj_to_delete_selector = undefined;
|
||||
if (registry_enabled && delete_age) {
|
||||
obj_to_delete_selector = registry.getSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_delete",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
__ENV.REGISTRY_FILE, 'obj_to_delete',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
age: delete_age,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const scenarios = {};
|
||||
|
@ -80,7 +82,8 @@ if (read_vu_count > 0) {
|
|||
const delete_vu_count = parseInt(__ENV.DELETERS || '0');
|
||||
if (delete_vu_count > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
throw new Error('Positive DELETE worker number without a proper object selector');
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -109,7 +112,8 @@ export function setup() {
|
|||
console.log(`Total VUs: ${total_vu_count}`);
|
||||
|
||||
const start_timestamp = Date.now()
|
||||
console.log(`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function teardown(data) {
|
||||
|
@ -117,21 +121,21 @@ export function teardown(data) {
|
|||
obj_registry.close();
|
||||
}
|
||||
const end_timestamp = Date.now()
|
||||
console.log(`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return {
|
||||
'stdout': textSummary(data, { indent: ' ', enableColors: false }),
|
||||
'stdout': textSummary(data, {indent: ' ', enableColors: false}),
|
||||
[summary_json]: JSON.stringify(data),
|
||||
};
|
||||
}
|
||||
|
||||
export function obj_write() {
|
||||
const headers = {
|
||||
unique_header: uuidv4()
|
||||
};
|
||||
const container = container_list[Math.floor(Math.random() * container_list.length)];
|
||||
const headers = {unique_header: uuidv4()};
|
||||
const container =
|
||||
container_list[Math.floor(Math.random() * container_list.length)];
|
||||
|
||||
const payload = generator.genPayload();
|
||||
const resp = local_client.put(container, headers, payload);
|
||||
|
@ -139,12 +143,12 @@ export function obj_write() {
|
|||
if (resp.abort) {
|
||||
exec.test.abort(resp.error);
|
||||
}
|
||||
log.withField("cid", container).error(resp.error);
|
||||
log.withField('cid', container).error(resp.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj_registry) {
|
||||
obj_registry.addObject(container, resp.object_id, "", "", payload.hash());
|
||||
obj_registry.addObject(container, resp.object_id, '', '', payload.hash());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +1,42 @@
|
|||
import {sleep} from 'k6';
|
||||
import {SharedArray} from 'k6/data';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import registry from 'k6/x/frostfs/registry';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
import s3 from 'k6/x/frostfs/s3';
|
||||
import { SharedArray } from 'k6/data';
|
||||
import { sleep } from 'k6';
|
||||
import { textSummary } from './libs/k6-summary-0.0.2.js';
|
||||
import { parseEnv } from './libs/env-parser.js';
|
||||
import { uuidv4 } from './libs/k6-utils-1.4.0.js';
|
||||
import { newGenerator } from './libs/datagen.js';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
|
||||
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();
|
||||
|
||||
const obj_list = new SharedArray('obj_list', function () {
|
||||
const obj_list = new SharedArray('obj_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).objects;
|
||||
});
|
||||
|
||||
const bucket_list = new SharedArray('bucket_list', function () {
|
||||
const bucket_list = new SharedArray('bucket_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).buckets;
|
||||
});
|
||||
|
||||
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size;
|
||||
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json";
|
||||
const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
|
||||
|
||||
const no_verify_ssl = __ENV.NO_VERIFY_SSL || "true";
|
||||
const connection_args = {no_verify_ssl: no_verify_ssl}
|
||||
const no_verify_ssl = __ENV.NO_VERIFY_SSL || 'true';
|
||||
const connection_args = {
|
||||
no_verify_ssl: no_verify_ssl
|
||||
}
|
||||
// Select random S3 endpoint for current VU
|
||||
const s3_endpoints = __ENV.S3_ENDPOINTS.split(',');
|
||||
const s3_endpoint = s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
|
||||
const s3_endpoint =
|
||||
s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
|
||||
const s3_client = s3.connect(s3_endpoint, connection_args);
|
||||
const log = logging.new().withField("endpoint", s3_endpoint);
|
||||
const log = logging.new().withField('endpoint', s3_endpoint);
|
||||
|
||||
const registry_enabled = !!__ENV.REGISTRY_FILE;
|
||||
const obj_registry = registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
const obj_registry =
|
||||
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
|
||||
const duration = __ENV.DURATION;
|
||||
|
||||
|
@ -43,28 +48,22 @@ const delete_age = __ENV.DELETE_AGE ? parseInt(__ENV.DELETE_AGE) : undefined;
|
|||
let obj_to_delete_selector = undefined;
|
||||
if (registry_enabled && delete_age) {
|
||||
obj_to_delete_selector = registry.getSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_delete",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
__ENV.REGISTRY_FILE, 'obj_to_delete',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
age: delete_age,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10;
|
||||
let obj_to_read_selector = undefined;
|
||||
if (registry_enabled) {
|
||||
obj_to_read_selector = registry.getLoopedSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_read",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
__ENV.REGISTRY_FILE, 'obj_to_read',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
age: read_age,
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const scenarios = {};
|
||||
|
@ -124,7 +123,8 @@ export function setup() {
|
|||
console.log(`Total VUs: ${total_vu_count}`);
|
||||
|
||||
const start_timestamp = Date.now()
|
||||
console.log(`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function teardown(data) {
|
||||
|
@ -132,15 +132,16 @@ export function teardown(data) {
|
|||
obj_registry.close();
|
||||
}
|
||||
const end_timestamp = Date.now()
|
||||
console.log(`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return {
|
||||
'stdout': textSummary(data, { indent: ' ', enableColors: false }),
|
||||
'stdout': textSummary(data, {indent: ' ', enableColors: false}),
|
||||
[summary_json]: JSON.stringify(data),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function obj_write() {
|
||||
if (__ENV.SLEEP_WRITE) {
|
||||
|
@ -158,7 +159,7 @@ export function obj_write() {
|
|||
}
|
||||
|
||||
if (obj_registry) {
|
||||
obj_registry.addObject("", "", bucket, key, payload.hash());
|
||||
obj_registry.addObject('', '', bucket, key, payload.hash());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,14 +168,15 @@ export function obj_read() {
|
|||
sleep(__ENV.SLEEP_READ);
|
||||
}
|
||||
|
||||
if(obj_to_read_selector) {
|
||||
if (obj_to_read_selector) {
|
||||
const obj = obj_to_read_selector.nextObject();
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
const resp = s3_client.get(obj.s3_bucket, obj.s3_key)
|
||||
if (!resp.success) {
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key}).error(resp.error);
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key})
|
||||
.error(resp.error);
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -199,7 +201,8 @@ export function obj_delete() {
|
|||
|
||||
const resp = s3_client.delete(obj.s3_bucket, obj.s3_key);
|
||||
if (!resp.success) {
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key, op: "DELETE"}).error(resp.error);
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key, op: 'DELETE'})
|
||||
.error(resp.error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +1,42 @@
|
|||
import {sleep} from 'k6';
|
||||
import {SharedArray} from 'k6/data';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import registry from 'k6/x/frostfs/registry';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
import s3 from 'k6/x/frostfs/s3';
|
||||
import { SharedArray } from 'k6/data';
|
||||
import { sleep } from 'k6';
|
||||
import { textSummary } from './libs/k6-summary-0.0.2.js';
|
||||
import { parseEnv } from './libs/env-parser.js';
|
||||
import { uuidv4 } from './libs/k6-utils-1.4.0.js';
|
||||
import { newGenerator } from './libs/datagen.js';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
|
||||
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();
|
||||
|
||||
const obj_list = new SharedArray('obj_list', function () {
|
||||
const obj_list = new SharedArray('obj_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).objects;
|
||||
});
|
||||
|
||||
const bucket_list = new SharedArray('bucket_list', function () {
|
||||
const bucket_list = new SharedArray('bucket_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).buckets;
|
||||
});
|
||||
|
||||
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size;
|
||||
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json";
|
||||
const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
|
||||
|
||||
// Select random S3 endpoint for current VU
|
||||
const s3_endpoints = __ENV.S3_ENDPOINTS.split(',');
|
||||
const s3_endpoint = s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
|
||||
const no_verify_ssl = __ENV.NO_VERIFY_SSL || "true";
|
||||
const connection_args = {no_verify_ssl: no_verify_ssl}
|
||||
const s3_endpoint =
|
||||
s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
|
||||
const no_verify_ssl = __ENV.NO_VERIFY_SSL || 'true';
|
||||
const connection_args = {
|
||||
no_verify_ssl: no_verify_ssl
|
||||
};
|
||||
const s3_client = s3.connect(s3_endpoint, connection_args);
|
||||
const log = logging.new().withField("endpoint", s3_endpoint);
|
||||
const log = logging.new().withField('endpoint', s3_endpoint);
|
||||
|
||||
const registry_enabled = !!__ENV.REGISTRY_FILE;
|
||||
const obj_registry = registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
const obj_registry =
|
||||
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
|
||||
const duration = __ENV.DURATION;
|
||||
|
||||
|
@ -43,28 +48,22 @@ const delete_age = __ENV.DELETE_AGE ? parseInt(__ENV.DELETE_AGE) : undefined;
|
|||
let obj_to_delete_selector = undefined;
|
||||
if (registry_enabled && delete_age) {
|
||||
obj_to_delete_selector = registry.getSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_delete",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
__ENV.REGISTRY_FILE, 'obj_to_delete',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
age: delete_age,
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10;
|
||||
let obj_to_read_selector = undefined;
|
||||
if (registry_enabled) {
|
||||
obj_to_read_selector = registry.getLoopedSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_read",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
__ENV.REGISTRY_FILE, 'obj_to_read',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
age: read_age,
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const scenarios = {};
|
||||
|
@ -110,7 +109,8 @@ const max_delete_vus = parseInt(__ENV.MAX_DELETERS || pre_alloc_write_vus);
|
|||
const delete_rate = parseInt(__ENV.DELETE_RATE || '0');
|
||||
if (delete_rate > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
throw new Error('Positive DELETE worker number without a proper object selector');
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -131,7 +131,8 @@ export const options = {
|
|||
};
|
||||
|
||||
export function setup() {
|
||||
const total_pre_allocated_vu_count = pre_alloc_write_vus + pre_alloc_read_vus + pre_alloc_delete_vus;
|
||||
const total_pre_allocated_vu_count =
|
||||
pre_alloc_write_vus + pre_alloc_read_vus + pre_alloc_delete_vus;
|
||||
const total_max_vu_count = max_read_vus + max_write_vus + max_delete_vus
|
||||
|
||||
console.log(`Pregenerated buckets: ${bucket_list.length}`);
|
||||
|
@ -151,7 +152,8 @@ export function setup() {
|
|||
console.log(`Delete rate: ${delete_rate}`);
|
||||
|
||||
const start_timestamp = Date.now()
|
||||
console.log(`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function teardown(data) {
|
||||
|
@ -159,15 +161,16 @@ export function teardown(data) {
|
|||
obj_registry.close();
|
||||
}
|
||||
const end_timestamp = Date.now()
|
||||
console.log(`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return {
|
||||
'stdout': textSummary(data, { indent: ' ', enableColors: false }),
|
||||
'stdout': textSummary(data, {indent: ' ', enableColors: false}),
|
||||
[summary_json]: JSON.stringify(data),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function obj_write() {
|
||||
if (__ENV.SLEEP_WRITE) {
|
||||
|
@ -185,7 +188,7 @@ export function obj_write() {
|
|||
}
|
||||
|
||||
if (obj_registry) {
|
||||
obj_registry.addObject("", "", bucket, key, payload.hash());
|
||||
obj_registry.addObject('', '', bucket, key, payload.hash());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,14 +197,15 @@ export function obj_read() {
|
|||
sleep(__ENV.SLEEP_READ);
|
||||
}
|
||||
|
||||
if(obj_to_read_selector) {
|
||||
if (obj_to_read_selector) {
|
||||
const obj = obj_to_read_selector.nextObject();
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
const resp = s3_client.get(obj.s3_bucket, obj.s3_key)
|
||||
if (!resp.success) {
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key}).error(resp.error);
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key})
|
||||
.error(resp.error);
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -226,7 +230,8 @@ export function obj_delete() {
|
|||
|
||||
const resp = s3_client.delete(obj.s3_bucket, obj.s3_key);
|
||||
if (!resp.success) {
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key, op: "DELETE"}).error(resp.error);
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key, op: 'DELETE'})
|
||||
.error(resp.error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,32 +1,37 @@
|
|||
import {sleep} from 'k6';
|
||||
import {SharedArray} from 'k6/data';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import registry from 'k6/x/frostfs/registry';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
import s3 from 'k6/x/frostfs/s3';
|
||||
import {SharedArray} from 'k6/data';
|
||||
import {sleep} from 'k6';
|
||||
import {textSummary} from './libs/k6-summary-0.0.2.js';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
|
||||
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';
|
||||
import { newGenerator } from './libs/datagen.js';
|
||||
|
||||
parseEnv();
|
||||
|
||||
const bucket_list = new SharedArray('bucket_list', function () {
|
||||
const bucket_list = new SharedArray('bucket_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).buckets;
|
||||
});
|
||||
|
||||
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json";
|
||||
const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
|
||||
|
||||
// Select random S3 endpoint for current VU
|
||||
const s3_endpoints = __ENV.S3_ENDPOINTS.split(',');
|
||||
const s3_endpoint = s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
|
||||
const no_verify_ssl = __ENV.NO_VERIFY_SSL || "true";
|
||||
const connection_args = {no_verify_ssl: no_verify_ssl}
|
||||
const s3_endpoint =
|
||||
s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
|
||||
const no_verify_ssl = __ENV.NO_VERIFY_SSL || 'true';
|
||||
const connection_args = {
|
||||
no_verify_ssl: no_verify_ssl
|
||||
};
|
||||
const s3_client = s3.connect(s3_endpoint, connection_args);
|
||||
const log = logging.new().withField("endpoint", s3_endpoint);
|
||||
const log = logging.new().withField('endpoint', s3_endpoint);
|
||||
|
||||
const registry_enabled = !!__ENV.REGISTRY_FILE;
|
||||
const obj_registry = registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
const obj_registry =
|
||||
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
|
||||
const duration = __ENV.DURATION;
|
||||
|
||||
|
@ -46,7 +51,8 @@ if (write_multipart_vu_count < 1) {
|
|||
throw 'number of parts (env WRITERS_MULTIPART) to upload in parallel should be greater than 0';
|
||||
}
|
||||
|
||||
const generator = newGenerator(write_vu_count > 0 || write_multipart_vu_count > 0);
|
||||
const generator =
|
||||
newGenerator(write_vu_count > 0 || write_multipart_vu_count > 0);
|
||||
if (write_vu_count > 0) {
|
||||
scenarios.write_multipart = {
|
||||
executor: 'constant-vus',
|
||||
|
@ -84,7 +90,8 @@ export function handleSummary(data) {
|
|||
};
|
||||
}
|
||||
|
||||
const write_multipart_part_size = 1024 * parseInt(__ENV.WRITE_OBJ_PART_SIZE || '0')
|
||||
const write_multipart_part_size =
|
||||
1024 * parseInt(__ENV.WRITE_OBJ_PART_SIZE || '0')
|
||||
if (write_multipart_part_size < 5 * 1024 * 1024) {
|
||||
throw 'part size (env WRITE_OBJ_PART_SIZE * 1024) must be greater than (5 MB)';
|
||||
}
|
||||
|
@ -98,13 +105,15 @@ export function obj_write_multipart() {
|
|||
const bucket = bucket_list[Math.floor(Math.random() * bucket_list.length)];
|
||||
|
||||
const payload = generator.genPayload();
|
||||
const resp = s3_client.multipart(bucket, key, write_multipart_part_size, write_multipart_vu_count, payload);
|
||||
const resp = s3_client.multipart(
|
||||
bucket, key, write_multipart_part_size, write_multipart_vu_count,
|
||||
payload);
|
||||
if (!resp.success) {
|
||||
log.withFields({bucket: bucket, key: key}).error(resp.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj_registry) {
|
||||
obj_registry.addObject("", "", bucket, key, payload.hash());
|
||||
obj_registry.addObject('', '', bucket, key, payload.hash());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
import {SharedArray} from 'k6/data';
|
||||
import exec from 'k6/execution';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import registry from 'k6/x/frostfs/registry';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
import s3local from 'k6/x/frostfs/s3local';
|
||||
import { SharedArray } from 'k6/data';
|
||||
import { textSummary } from './libs/k6-summary-0.0.2.js';
|
||||
import { parseEnv } from './libs/env-parser.js';
|
||||
import { uuidv4 } from './libs/k6-utils-1.4.0.js';
|
||||
import exec from 'k6/execution';
|
||||
import { newGenerator } from './libs/datagen.js';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
|
||||
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();
|
||||
|
||||
const obj_list = new SharedArray('obj_list', function () {
|
||||
const obj_list = new SharedArray('obj_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).objects;
|
||||
});
|
||||
|
||||
const container_list = new SharedArray('container_list', function () {
|
||||
const container_list = new SharedArray('container_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).containers;
|
||||
});
|
||||
|
||||
const bucket_list = new SharedArray('bucket_list', function () {
|
||||
const bucket_list = new SharedArray('bucket_list', function() {
|
||||
return JSON.parse(open(__ENV.PREGEN_JSON)).buckets;
|
||||
});
|
||||
|
||||
|
@ -35,33 +36,35 @@ function bucket_mapping() {
|
|||
}
|
||||
|
||||
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size;
|
||||
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json";
|
||||
const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
|
||||
|
||||
const config_file = __ENV.CONFIG_FILE;
|
||||
const config_dir = __ENV.CONFIG_DIR;
|
||||
const max_total_size_gb = __ENV.MAX_TOTAL_SIZE_GB ? parseInt(__ENV.MAX_TOTAL_SIZE_GB) : 0;
|
||||
const s3_client = s3local.connect(config_file, config_dir, {
|
||||
const max_total_size_gb =
|
||||
__ENV.MAX_TOTAL_SIZE_GB ? parseInt(__ENV.MAX_TOTAL_SIZE_GB) : 0;
|
||||
const s3_client = s3local.connect(
|
||||
config_file, config_dir, {
|
||||
'debug_logger': __ENV.DEBUG_LOGGER || 'false',
|
||||
}, bucket_mapping(), max_total_size_gb);
|
||||
const log = logging.new().withFields({"config_file": config_file,"config_dir": config_dir});
|
||||
},
|
||||
bucket_mapping(), max_total_size_gb);
|
||||
const log = logging.new().withFields(
|
||||
{'config_file': config_file, 'config_dir': config_dir});
|
||||
|
||||
if (!!__ENV.METRIC_TAGS) {
|
||||
stats.setTags(__ENV.METRIC_TAGS)
|
||||
}
|
||||
|
||||
const registry_enabled = !!__ENV.REGISTRY_FILE;
|
||||
const obj_registry = registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
const obj_registry =
|
||||
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
|
||||
|
||||
let obj_to_read_selector = undefined;
|
||||
if (registry_enabled) {
|
||||
obj_to_read_selector = registry.getLoopedSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_read",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
}
|
||||
)
|
||||
__ENV.REGISTRY_FILE, 'obj_to_read',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
})
|
||||
}
|
||||
|
||||
const duration = __ENV.DURATION;
|
||||
|
@ -107,7 +110,8 @@ export function setup() {
|
|||
console.log(`Total VUs: ${total_vu_count}`);
|
||||
|
||||
const start_timestamp = Date.now()
|
||||
console.log(`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load started at: ${Date(start_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function teardown(data) {
|
||||
|
@ -115,15 +119,16 @@ export function teardown(data) {
|
|||
obj_registry.close();
|
||||
}
|
||||
const end_timestamp = Date.now()
|
||||
console.log(`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
console.log(
|
||||
`Load finished at: ${Date(end_timestamp).toString()}`)
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return {
|
||||
'stdout': textSummary(data, { indent: ' ', enableColors: false }),
|
||||
'stdout': textSummary(data, {indent: ' ', enableColors: false}),
|
||||
[summary_json]: JSON.stringify(data),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function obj_write() {
|
||||
const key = __ENV.OBJ_NAME || uuidv4();
|
||||
|
@ -140,19 +145,20 @@ export function obj_write() {
|
|||
}
|
||||
|
||||
if (obj_registry) {
|
||||
obj_registry.addObject("", "", bucket, key, payload.hash());
|
||||
obj_registry.addObject('', '', bucket, key, payload.hash());
|
||||
}
|
||||
}
|
||||
|
||||
export function obj_read() {
|
||||
if(obj_to_read_selector) {
|
||||
if (obj_to_read_selector) {
|
||||
const obj = obj_to_read_selector.nextObject();
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
const resp = s3_client.get(obj.s3_bucket, obj.s3_key)
|
||||
if (!resp.success) {
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key}).error(resp.error);
|
||||
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key})
|
||||
.error(resp.error);
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
import {sleep} from 'k6';
|
||||
import {Counter} from 'k6/metrics';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import native from 'k6/x/frostfs/native';
|
||||
import registry from 'k6/x/frostfs/registry';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
import s3 from 'k6/x/frostfs/s3';
|
||||
import logging from 'k6/x/frostfs/logging';
|
||||
import { sleep } from 'k6';
|
||||
import { Counter } from 'k6/metrics';
|
||||
import { textSummary } from './libs/k6-summary-0.0.2.js';
|
||||
import { parseEnv } from './libs/env-parser.js';
|
||||
import stats from 'k6/x/frostfs/stats';
|
||||
|
||||
import {parseEnv} from './libs/env-parser.js';
|
||||
import {textSummary} from './libs/k6-summary-0.0.2.js';
|
||||
|
||||
parseEnv();
|
||||
|
||||
const obj_registry = registry.open(__ENV.REGISTRY_FILE);
|
||||
|
||||
// Time limit (in seconds) for the run
|
||||
const time_limit = __ENV.TIME_LIMIT || "60";
|
||||
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json";
|
||||
const time_limit = __ENV.TIME_LIMIT || '60';
|
||||
const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
|
||||
|
||||
// Number of objects in each status. These counters are cumulative in a
|
||||
// sense that they reflect total number of objects in the registry, not just
|
||||
|
@ -37,39 +38,43 @@ if (!!__ENV.METRIC_TAGS) {
|
|||
let grpc_client = undefined;
|
||||
if (__ENV.GRPC_ENDPOINTS) {
|
||||
const grpcEndpoints = __ENV.GRPC_ENDPOINTS.split(',');
|
||||
const grpcEndpoint = grpcEndpoints[Math.floor(Math.random() * grpcEndpoints.length)];
|
||||
log = log.withField("endpoint", grpcEndpoint);
|
||||
grpc_client = native.connect(grpcEndpoint, '',
|
||||
__ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 0,
|
||||
const grpcEndpoint =
|
||||
grpcEndpoints[Math.floor(Math.random() * grpcEndpoints.length)];
|
||||
log = log.withField('endpoint', grpcEndpoint);
|
||||
grpc_client = native.connect(
|
||||
grpcEndpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 0,
|
||||
__ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_TIMEOUT) : 0,
|
||||
__ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === "true" : false, '');
|
||||
__ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === 'true' :
|
||||
false,
|
||||
'');
|
||||
}
|
||||
|
||||
// Connect to random S3 endpoint
|
||||
let s3_client = undefined;
|
||||
if (__ENV.S3_ENDPOINTS) {
|
||||
const no_verify_ssl = __ENV.NO_VERIFY_SSL || "true";
|
||||
const connection_args = {no_verify_ssl: no_verify_ssl}
|
||||
const no_verify_ssl = __ENV.NO_VERIFY_SSL || 'true';
|
||||
const connection_args = {no_verify_ssl: no_verify_ssl};
|
||||
const s3_endpoints = __ENV.S3_ENDPOINTS.split(',');
|
||||
const s3_endpoint = s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
|
||||
log = log.withField("endpoint", s3_endpoint);
|
||||
const s3_endpoint =
|
||||
s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
|
||||
log = log.withField('endpoint', s3_endpoint);
|
||||
s3_client = s3.connect(s3_endpoint, connection_args);
|
||||
}
|
||||
|
||||
// We will attempt to verify every object in "created" status. The scenario will execute
|
||||
// as many iterations as there are objects. Each object will have 3 retries to be verified
|
||||
// We will attempt to verify every object in "created" status. The scenario will
|
||||
// execute as many iterations as there are objects. Each object will have 3
|
||||
// retries to be verified
|
||||
const obj_to_verify_selector = registry.getSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
"obj_to_verify",
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{
|
||||
status: "created",
|
||||
}
|
||||
);
|
||||
__ENV.REGISTRY_FILE, 'obj_to_verify',
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
|
||||
status: 'created',
|
||||
});
|
||||
const obj_to_verify_count = obj_to_verify_selector.count();
|
||||
// Execute at least one iteration (executor shared-iterations can't run 0 iterations)
|
||||
// Execute at least one iteration (executor shared-iterations can't run 0
|
||||
// iterations)
|
||||
const iterations = Math.max(1, obj_to_verify_count);
|
||||
// Executor shared-iterations requires number of iterations to be larger than number of VUs
|
||||
// Executor shared-iterations requires number of iterations to be larger than
|
||||
// number of VUs
|
||||
const vus = Math.min(__ENV.CLIENTS, iterations);
|
||||
|
||||
const scenarios = {
|
||||
|
@ -92,24 +97,22 @@ export function setup() {
|
|||
// Populate counters with initial values
|
||||
for (const [status, counter] of Object.entries(obj_counters)) {
|
||||
const obj_selector = registry.getSelector(
|
||||
__ENV.REGISTRY_FILE,
|
||||
status,
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
|
||||
{ status });
|
||||
__ENV.REGISTRY_FILE, status,
|
||||
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {status});
|
||||
counter.add(obj_selector.count());
|
||||
}
|
||||
}
|
||||
|
||||
export function handleSummary(data) {
|
||||
return {
|
||||
'stdout': textSummary(data, { indent: ' ', enableColors: false }),
|
||||
'stdout': textSummary(data, {indent: ' ', enableColors: false}),
|
||||
[summary_json]: JSON.stringify(data),
|
||||
};
|
||||
}
|
||||
|
||||
export function obj_verify() {
|
||||
if (obj_to_verify_count == 0) {
|
||||
log.info("Nothing to verify");
|
||||
log.info('Nothing to verify');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -119,7 +122,7 @@ export function obj_verify() {
|
|||
|
||||
const obj = obj_to_verify_selector.nextObject();
|
||||
if (!obj) {
|
||||
log.info("All objects have been verified");
|
||||
log.info('All objects have been verified');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -139,7 +142,8 @@ function verify_object_with_retries(obj, attempts) {
|
|||
result = grpc_client.verifyHash(obj.c_id, obj.o_id, obj.payload_hash);
|
||||
} else if (obj.s3_bucket && obj.s3_key) {
|
||||
lg = lg.withFields({bucket: obj.s3_bucket, key: obj.s3_key});
|
||||
result = s3_client.verifyHash(obj.s3_bucket, obj.s3_key, obj.payload_hash);
|
||||
result =
|
||||
s3_client.verifyHash(obj.s3_bucket, obj.s3_key, obj.payload_hash);
|
||||
} else {
|
||||
lg.withFields({
|
||||
cid: obj.c_id,
|
||||
|
@ -147,19 +151,20 @@ function verify_object_with_retries(obj, attempts) {
|
|||
bucket: obj.s3_bucket,
|
||||
key: obj.s3_key
|
||||
}).warn(`Object cannot be verified with supported protocols`);
|
||||
return "skipped";
|
||||
return 'skipped';
|
||||
}
|
||||
|
||||
if (result.success) {
|
||||
return "verified";
|
||||
} else if (result.error == "hash mismatch") {
|
||||
return "invalid";
|
||||
return 'verified';
|
||||
} else if (result.error == 'hash mismatch') {
|
||||
return 'invalid';
|
||||
}
|
||||
|
||||
// Unless we explicitly saw that there was a hash mismatch, then we will retry after a delay
|
||||
// Unless we explicitly saw that there was a hash mismatch, then we will
|
||||
// retry after a delay
|
||||
lg.error(`Verify error: ${result.error}. Object will be re-tried`);
|
||||
sleep(__ENV.SLEEP);
|
||||
}
|
||||
|
||||
return "invalid";
|
||||
return 'invalid';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue