[#131] scenarios: Format js files with clang formatter

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-03-20 11:04:13 +03:00
parent 0c4e2665ba
commit 93aaec4e0d
9 changed files with 1038 additions and 994 deletions

View file

@ -1,13 +1,14 @@
import native from 'k6/x/frostfs/native'; import {sleep} from 'k6';
import {SharedArray} from 'k6/data';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import native from 'k6/x/frostfs/native';
import registry from 'k6/x/frostfs/registry'; import registry from 'k6/x/frostfs/registry';
import stats from 'k6/x/frostfs/stats'; 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(); parseEnv();
@ -20,19 +21,22 @@ const container_list = new SharedArray('container_list', function () {
}); });
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size; 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 // Select random gRPC endpoint for current VU
const grpc_endpoints = __ENV.GRPC_ENDPOINTS.split(','); const grpc_endpoints = __ENV.GRPC_ENDPOINTS.split(',');
const grpc_endpoint = grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)]; const grpc_endpoint =
const grpc_client = native.connect(grpc_endpoint, '', grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)];
__ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5, const grpc_client = native.connect(
grpc_endpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5,
__ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_TIMEOUT) : 60, __ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_TIMEOUT) : 60,
__ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === "true" : false); __ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === 'true' :
const log = logging.new().withField("endpoint", grpc_endpoint); false);
const log = logging.new().withField('endpoint', grpc_endpoint);
const registry_enabled = !!__ENV.REGISTRY_FILE; 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; 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; let obj_to_delete_selector = undefined;
if (registry_enabled && delete_age) { if (registry_enabled && delete_age) {
obj_to_delete_selector = registry.getSelector( obj_to_delete_selector = registry.getSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_delete',
"obj_to_delete", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{
status: "created",
age: delete_age, age: delete_age,
} });
);
} }
const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10; const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10;
let obj_to_read_selector = undefined; let obj_to_read_selector = undefined;
if (registry_enabled) { if (registry_enabled) {
obj_to_read_selector = registry.getLoopedSelector( obj_to_read_selector = registry.getLoopedSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_read',
"obj_to_read", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{
status: "created",
age: read_age, age: read_age,
} })
)
} }
const scenarios = {}; const scenarios = {};
@ -97,7 +95,8 @@ if (read_vu_count > 0) {
const delete_vu_count = parseInt(__ENV.DELETERS || '0'); const delete_vu_count = parseInt(__ENV.DELETERS || '0');
if (delete_vu_count > 0) { if (delete_vu_count > 0) {
if (!obj_to_delete_selector) { 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 = { scenarios.delete = {
@ -126,7 +125,8 @@ export function setup() {
console.log(`Total VUs: ${total_vu_count}`); console.log(`Total VUs: ${total_vu_count}`);
const start_timestamp = Date.now() 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) { export function teardown(data) {
@ -134,7 +134,8 @@ export function teardown(data) {
obj_registry.close(); obj_registry.close();
} }
const end_timestamp = Date.now() 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) { export function handleSummary(data) {
@ -149,20 +150,20 @@ export function obj_write() {
sleep(__ENV.SLEEP_WRITE); sleep(__ENV.SLEEP_WRITE);
} }
const headers = { const headers = {unique_header: uuidv4()};
unique_header: uuidv4() 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 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) { if (!resp.success) {
log.withField("cid", container).error(resp.error); log.withField('cid', container).error(resp.error);
return; return;
} }
if (obj_registry) { if (obj_registry) {
obj_registry.addObject(container, resp.object_id, "", "", payload.hash()); obj_registry.addObject(container, resp.object_id, '', '', payload.hash());
} }
} }

View file

@ -1,13 +1,14 @@
import native from 'k6/x/frostfs/native'; import {sleep} from 'k6';
import {SharedArray} from 'k6/data';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import native from 'k6/x/frostfs/native';
import registry from 'k6/x/frostfs/registry'; import registry from 'k6/x/frostfs/registry';
import stats from 'k6/x/frostfs/stats'; 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(); parseEnv();
@ -20,19 +21,22 @@ const container_list = new SharedArray('container_list', function () {
}); });
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size; 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 // Select random gRPC endpoint for current VU
const grpc_endpoints = __ENV.GRPC_ENDPOINTS.split(','); const grpc_endpoints = __ENV.GRPC_ENDPOINTS.split(',');
const grpc_endpoint = grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)]; const grpc_endpoint =
const grpc_client = native.connect(grpc_endpoint, '', grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)];
__ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5, const grpc_client = native.connect(
grpc_endpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5,
__ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_TIMEOUT) : 60, __ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_TIMEOUT) : 60,
__ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === "true" : false); __ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === 'true' :
const log = logging.new().withField("endpoint", grpc_endpoint); false);
const log = logging.new().withField('endpoint', grpc_endpoint);
const registry_enabled = !!__ENV.REGISTRY_FILE; 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; 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; let obj_to_delete_selector = undefined;
if (registry_enabled && delete_age) { if (registry_enabled && delete_age) {
obj_to_delete_selector = registry.getSelector( obj_to_delete_selector = registry.getSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_delete',
"obj_to_delete", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{
status: "created",
age: delete_age, age: delete_age,
} });
);
} }
const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10; const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10;
let obj_to_read_selector = undefined; let obj_to_read_selector = undefined;
if (registry_enabled) { if (registry_enabled) {
obj_to_read_selector = registry.getLoopedSelector( obj_to_read_selector = registry.getLoopedSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_read',
"obj_to_read", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{
status: "created",
age: read_age, age: read_age,
} })
)
} }
const scenarios = {}; 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'); const delete_rate = parseInt(__ENV.DELETE_RATE || '0');
if (delete_rate > 0) { if (delete_rate > 0) {
if (!obj_to_delete_selector) { 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 = { scenarios.delete = {
@ -131,7 +130,8 @@ export const options = {
}; };
export function setup() { 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 const total_max_vu_count = max_read_vus + max_write_vus + max_delete_vus
console.log(`Pregenerated containers: ${container_list.length}`); console.log(`Pregenerated containers: ${container_list.length}`);
@ -151,7 +151,8 @@ export function setup() {
console.log(`Delete rate: ${delete_rate}`); console.log(`Delete rate: ${delete_rate}`);
const start_timestamp = Date.now() 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) { export function teardown(data) {
@ -159,7 +160,8 @@ export function teardown(data) {
obj_registry.close(); obj_registry.close();
} }
const end_timestamp = Date.now() 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) { export function handleSummary(data) {
@ -174,20 +176,20 @@ export function obj_write() {
sleep(__ENV.SLEEP_WRITE); sleep(__ENV.SLEEP_WRITE);
} }
const headers = { const headers = {unique_header: uuidv4()};
unique_header: uuidv4() 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 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) { if (!resp.success) {
log.withField("cid", container).error(resp.error); log.withField('cid', container).error(resp.error);
return; return;
} }
if (obj_registry) { if (obj_registry) {
obj_registry.addObject(container, resp.object_id, "", "", payload.hash()); obj_registry.addObject(container, resp.object_id, '', '', payload.hash());
} }
} }

View file

@ -1,13 +1,14 @@
import {sleep} from 'k6';
import {SharedArray} from 'k6/data';
import http from 'k6/http';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import registry from 'k6/x/frostfs/registry'; import registry from 'k6/x/frostfs/registry';
import stats from 'k6/x/frostfs/stats'; 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(); parseEnv();
@ -20,15 +21,17 @@ const container_list = new SharedArray('container_list', function () {
}); });
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size; 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 // Select random HTTP endpoint for current VU
const http_endpoints = __ENV.HTTP_ENDPOINTS.split(','); const http_endpoints = __ENV.HTTP_ENDPOINTS.split(',');
const http_endpoint = http_endpoints[Math.floor(Math.random() * http_endpoints.length)]; const http_endpoint =
const log = logging.new().withField("endpoint", 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 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; const duration = __ENV.DURATION;
@ -77,7 +80,8 @@ export function setup() {
console.log(`Total VUs: ${total_vu_count}`); console.log(`Total VUs: ${total_vu_count}`);
const start_timestamp = Date.now() 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) { export function teardown(data) {
@ -85,7 +89,8 @@ export function teardown(data) {
obj_registry.close(); obj_registry.close();
} }
const end_timestamp = Date.now() 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) { export function handleSummary(data) {
@ -100,14 +105,16 @@ export function obj_write() {
sleep(__ENV.SLEEP_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 payload = generator.genPayload();
const data = { const data = {
field: uuidv4(), 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. // `-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); 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; const object_id = JSON.parse(resp.body).object_id;
if (obj_registry) { 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 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) { 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);
} }
} }

View file

@ -1,13 +1,14 @@
import {SharedArray} from 'k6/data';
import exec from 'k6/execution';
import local from 'k6/x/frostfs/local'; import local from 'k6/x/frostfs/local';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import registry from 'k6/x/frostfs/registry'; import registry from 'k6/x/frostfs/registry';
import stats from 'k6/x/frostfs/stats'; 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(); parseEnv();
@ -20,17 +21,21 @@ const container_list = new SharedArray('container_list', function () {
}); });
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size; 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_file = __ENV.CONFIG_FILE;
const config_dir = __ENV.CONFIG_DIR; const config_dir = __ENV.CONFIG_DIR;
const debug_logger = (__ENV.DEBUG_LOGGER || 'false') == 'true'; 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 max_total_size_gb =
const local_client = local.connect(config_file, config_dir, '', debug_logger, max_total_size_gb); __ENV.MAX_TOTAL_SIZE_GB ? parseInt(__ENV.MAX_TOTAL_SIZE_GB) : 0;
const log = logging.new().withFields({"config_file": config_file,"config_dir": config_dir}); 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 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; 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; let obj_to_delete_selector = undefined;
if (registry_enabled && delete_age) { if (registry_enabled && delete_age) {
obj_to_delete_selector = registry.getSelector( obj_to_delete_selector = registry.getSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_delete',
"obj_to_delete", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{
status: "created",
age: delete_age, age: delete_age,
} });
);
} }
const scenarios = {}; const scenarios = {};
@ -80,7 +82,8 @@ if (read_vu_count > 0) {
const delete_vu_count = parseInt(__ENV.DELETERS || '0'); const delete_vu_count = parseInt(__ENV.DELETERS || '0');
if (delete_vu_count > 0) { if (delete_vu_count > 0) {
if (!obj_to_delete_selector) { 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 = { scenarios.delete = {
@ -109,7 +112,8 @@ export function setup() {
console.log(`Total VUs: ${total_vu_count}`); console.log(`Total VUs: ${total_vu_count}`);
const start_timestamp = Date.now() 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) { export function teardown(data) {
@ -117,7 +121,8 @@ export function teardown(data) {
obj_registry.close(); obj_registry.close();
} }
const end_timestamp = Date.now() 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) { export function handleSummary(data) {
@ -128,10 +133,9 @@ export function handleSummary(data) {
} }
export function obj_write() { export function obj_write() {
const headers = { const headers = {unique_header: uuidv4()};
unique_header: uuidv4() 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 payload = generator.genPayload();
const resp = local_client.put(container, headers, payload); const resp = local_client.put(container, headers, payload);
@ -139,12 +143,12 @@ export function obj_write() {
if (resp.abort) { if (resp.abort) {
exec.test.abort(resp.error); exec.test.abort(resp.error);
} }
log.withField("cid", container).error(resp.error); log.withField('cid', container).error(resp.error);
return; return;
} }
if (obj_registry) { if (obj_registry) {
obj_registry.addObject(container, resp.object_id, "", "", payload.hash()); obj_registry.addObject(container, resp.object_id, '', '', payload.hash());
} }
} }

View file

@ -1,13 +1,14 @@
import {sleep} from 'k6';
import {SharedArray} from 'k6/data';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import registry from 'k6/x/frostfs/registry'; import registry from 'k6/x/frostfs/registry';
import stats from 'k6/x/frostfs/stats';
import s3 from 'k6/x/frostfs/s3'; import s3 from 'k6/x/frostfs/s3';
import { SharedArray } from 'k6/data'; import stats from 'k6/x/frostfs/stats';
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(); parseEnv();
@ -20,18 +21,22 @@ const bucket_list = new SharedArray('bucket_list', function () {
}); });
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size; 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 no_verify_ssl = __ENV.NO_VERIFY_SSL || 'true';
const connection_args = {no_verify_ssl: no_verify_ssl} const connection_args = {
no_verify_ssl: no_verify_ssl
}
// Select random S3 endpoint for current VU // Select random S3 endpoint for current VU
const s3_endpoints = __ENV.S3_ENDPOINTS.split(','); 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 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 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; 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; let obj_to_delete_selector = undefined;
if (registry_enabled && delete_age) { if (registry_enabled && delete_age) {
obj_to_delete_selector = registry.getSelector( obj_to_delete_selector = registry.getSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_delete',
"obj_to_delete", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{
status: "created",
age: delete_age, age: delete_age,
} });
);
} }
const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10; const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10;
let obj_to_read_selector = undefined; let obj_to_read_selector = undefined;
if (registry_enabled) { if (registry_enabled) {
obj_to_read_selector = registry.getLoopedSelector( obj_to_read_selector = registry.getLoopedSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_read',
"obj_to_read", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{
status: "created",
age: read_age, age: read_age,
} })
)
} }
const scenarios = {}; const scenarios = {};
@ -124,7 +123,8 @@ export function setup() {
console.log(`Total VUs: ${total_vu_count}`); console.log(`Total VUs: ${total_vu_count}`);
const start_timestamp = Date.now() 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) { export function teardown(data) {
@ -132,7 +132,8 @@ export function teardown(data) {
obj_registry.close(); obj_registry.close();
} }
const end_timestamp = Date.now() 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) { export function handleSummary(data) {
@ -158,7 +159,7 @@ export function obj_write() {
} }
if (obj_registry) { if (obj_registry) {
obj_registry.addObject("", "", bucket, key, payload.hash()); obj_registry.addObject('', '', bucket, key, payload.hash());
} }
} }
@ -174,7 +175,8 @@ export function obj_read() {
} }
const resp = s3_client.get(obj.s3_bucket, obj.s3_key) const resp = s3_client.get(obj.s3_bucket, obj.s3_key)
if (!resp.success) { 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 return
} }
@ -199,7 +201,8 @@ export function obj_delete() {
const resp = s3_client.delete(obj.s3_bucket, obj.s3_key); const resp = s3_client.delete(obj.s3_bucket, obj.s3_key);
if (!resp.success) { 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; return;
} }

View file

@ -1,13 +1,14 @@
import {sleep} from 'k6';
import {SharedArray} from 'k6/data';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import registry from 'k6/x/frostfs/registry'; import registry from 'k6/x/frostfs/registry';
import stats from 'k6/x/frostfs/stats';
import s3 from 'k6/x/frostfs/s3'; import s3 from 'k6/x/frostfs/s3';
import { SharedArray } from 'k6/data'; import stats from 'k6/x/frostfs/stats';
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(); parseEnv();
@ -20,18 +21,22 @@ const bucket_list = new SharedArray('bucket_list', function () {
}); });
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size; 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 // Select random S3 endpoint for current VU
const s3_endpoints = __ENV.S3_ENDPOINTS.split(','); const s3_endpoints = __ENV.S3_ENDPOINTS.split(',');
const s3_endpoint = s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)]; const s3_endpoint =
const no_verify_ssl = __ENV.NO_VERIFY_SSL || "true"; s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
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_client = s3.connect(s3_endpoint, connection_args); 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 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; 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; let obj_to_delete_selector = undefined;
if (registry_enabled && delete_age) { if (registry_enabled && delete_age) {
obj_to_delete_selector = registry.getSelector( obj_to_delete_selector = registry.getSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_delete',
"obj_to_delete", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{
status: "created",
age: delete_age, age: delete_age,
} });
);
} }
const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10; const read_age = __ENV.READ_AGE ? parseInt(__ENV.READ_AGE) : 10;
let obj_to_read_selector = undefined; let obj_to_read_selector = undefined;
if (registry_enabled) { if (registry_enabled) {
obj_to_read_selector = registry.getLoopedSelector( obj_to_read_selector = registry.getLoopedSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_read',
"obj_to_read", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{
status: "created",
age: read_age, age: read_age,
} })
)
} }
const scenarios = {}; 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'); const delete_rate = parseInt(__ENV.DELETE_RATE || '0');
if (delete_rate > 0) { if (delete_rate > 0) {
if (!obj_to_delete_selector) { 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 = { scenarios.delete = {
@ -131,7 +131,8 @@ export const options = {
}; };
export function setup() { 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 const total_max_vu_count = max_read_vus + max_write_vus + max_delete_vus
console.log(`Pregenerated buckets: ${bucket_list.length}`); console.log(`Pregenerated buckets: ${bucket_list.length}`);
@ -151,7 +152,8 @@ export function setup() {
console.log(`Delete rate: ${delete_rate}`); console.log(`Delete rate: ${delete_rate}`);
const start_timestamp = Date.now() 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) { export function teardown(data) {
@ -159,7 +161,8 @@ export function teardown(data) {
obj_registry.close(); obj_registry.close();
} }
const end_timestamp = Date.now() 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) { export function handleSummary(data) {
@ -185,7 +188,7 @@ export function obj_write() {
} }
if (obj_registry) { if (obj_registry) {
obj_registry.addObject("", "", bucket, key, payload.hash()); obj_registry.addObject('', '', bucket, key, payload.hash());
} }
} }
@ -201,7 +204,8 @@ export function obj_read() {
} }
const resp = s3_client.get(obj.s3_bucket, obj.s3_key) const resp = s3_client.get(obj.s3_bucket, obj.s3_key)
if (!resp.success) { 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 return
} }
@ -226,7 +230,8 @@ export function obj_delete() {
const resp = s3_client.delete(obj.s3_bucket, obj.s3_key); const resp = s3_client.delete(obj.s3_bucket, obj.s3_key);
if (!resp.success) { 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; return;
} }

View file

@ -1,13 +1,14 @@
import {sleep} from 'k6';
import {SharedArray} from 'k6/data';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import registry from 'k6/x/frostfs/registry'; import registry from 'k6/x/frostfs/registry';
import stats from 'k6/x/frostfs/stats';
import s3 from 'k6/x/frostfs/s3'; import s3 from 'k6/x/frostfs/s3';
import {SharedArray} from 'k6/data'; import stats from 'k6/x/frostfs/stats';
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(); parseEnv();
@ -15,18 +16,22 @@ const bucket_list = new SharedArray('bucket_list', function () {
return JSON.parse(open(__ENV.PREGEN_JSON)).buckets; 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 // Select random S3 endpoint for current VU
const s3_endpoints = __ENV.S3_ENDPOINTS.split(','); const s3_endpoints = __ENV.S3_ENDPOINTS.split(',');
const s3_endpoint = s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)]; const s3_endpoint =
const no_verify_ssl = __ENV.NO_VERIFY_SSL || "true"; s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
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_client = s3.connect(s3_endpoint, connection_args); 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 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; 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'; 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) { if (write_vu_count > 0) {
scenarios.write_multipart = { scenarios.write_multipart = {
executor: 'constant-vus', 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) { if (write_multipart_part_size < 5 * 1024 * 1024) {
throw 'part size (env WRITE_OBJ_PART_SIZE * 1024) must be greater than (5 MB)'; 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 bucket = bucket_list[Math.floor(Math.random() * bucket_list.length)];
const payload = generator.genPayload(); 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) { if (!resp.success) {
log.withFields({bucket: bucket, key: key}).error(resp.error); log.withFields({bucket: bucket, key: key}).error(resp.error);
return; return;
} }
if (obj_registry) { if (obj_registry) {
obj_registry.addObject("", "", bucket, key, payload.hash()); obj_registry.addObject('', '', bucket, key, payload.hash());
} }
} }

View file

@ -1,13 +1,14 @@
import {SharedArray} from 'k6/data';
import exec from 'k6/execution';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import registry from 'k6/x/frostfs/registry'; import registry from 'k6/x/frostfs/registry';
import stats from 'k6/x/frostfs/stats';
import s3local from 'k6/x/frostfs/s3local'; import s3local from 'k6/x/frostfs/s3local';
import { SharedArray } from 'k6/data'; import stats from 'k6/x/frostfs/stats';
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(); parseEnv();
@ -35,33 +36,35 @@ function bucket_mapping() {
} }
const read_size = JSON.parse(open(__ENV.PREGEN_JSON)).obj_size; 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_file = __ENV.CONFIG_FILE;
const config_dir = __ENV.CONFIG_DIR; const config_dir = __ENV.CONFIG_DIR;
const max_total_size_gb = __ENV.MAX_TOTAL_SIZE_GB ? parseInt(__ENV.MAX_TOTAL_SIZE_GB) : 0; const max_total_size_gb =
const s3_client = s3local.connect(config_file, config_dir, { __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', '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) { if (!!__ENV.METRIC_TAGS) {
stats.setTags(__ENV.METRIC_TAGS) stats.setTags(__ENV.METRIC_TAGS)
} }
const registry_enabled = !!__ENV.REGISTRY_FILE; 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; let obj_to_read_selector = undefined;
if (registry_enabled) { if (registry_enabled) {
obj_to_read_selector = registry.getLoopedSelector( obj_to_read_selector = registry.getLoopedSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_read',
"obj_to_read", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{ })
status: "created",
}
)
} }
const duration = __ENV.DURATION; const duration = __ENV.DURATION;
@ -107,7 +110,8 @@ export function setup() {
console.log(`Total VUs: ${total_vu_count}`); console.log(`Total VUs: ${total_vu_count}`);
const start_timestamp = Date.now() 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) { export function teardown(data) {
@ -115,7 +119,8 @@ export function teardown(data) {
obj_registry.close(); obj_registry.close();
} }
const end_timestamp = Date.now() 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) { export function handleSummary(data) {
@ -140,7 +145,7 @@ export function obj_write() {
} }
if (obj_registry) { if (obj_registry) {
obj_registry.addObject("", "", bucket, key, payload.hash()); obj_registry.addObject('', '', bucket, key, payload.hash());
} }
} }
@ -152,7 +157,8 @@ export function obj_read() {
} }
const resp = s3_client.get(obj.s3_bucket, obj.s3_key) const resp = s3_client.get(obj.s3_bucket, obj.s3_key)
if (!resp.success) { 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 return
} }

View file

@ -1,20 +1,21 @@
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 {sleep} from 'k6';
import {Counter} from 'k6/metrics'; import {Counter} from 'k6/metrics';
import { textSummary } from './libs/k6-summary-0.0.2.js'; import logging from 'k6/x/frostfs/logging';
import native from 'k6/x/frostfs/native';
import registry from 'k6/x/frostfs/registry';
import s3 from 'k6/x/frostfs/s3';
import stats from 'k6/x/frostfs/stats';
import {parseEnv} from './libs/env-parser.js'; import {parseEnv} from './libs/env-parser.js';
import {textSummary} from './libs/k6-summary-0.0.2.js';
parseEnv(); parseEnv();
const obj_registry = registry.open(__ENV.REGISTRY_FILE); const obj_registry = registry.open(__ENV.REGISTRY_FILE);
// Time limit (in seconds) for the run // Time limit (in seconds) for the run
const time_limit = __ENV.TIME_LIMIT || "60"; const time_limit = __ENV.TIME_LIMIT || '60';
const summary_json = __ENV.SUMMARY_JSON || "/tmp/summary.json"; const summary_json = __ENV.SUMMARY_JSON || '/tmp/summary.json';
// Number of objects in each status. These counters are cumulative in a // 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 // 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; let grpc_client = undefined;
if (__ENV.GRPC_ENDPOINTS) { if (__ENV.GRPC_ENDPOINTS) {
const grpcEndpoints = __ENV.GRPC_ENDPOINTS.split(','); const grpcEndpoints = __ENV.GRPC_ENDPOINTS.split(',');
const grpcEndpoint = grpcEndpoints[Math.floor(Math.random() * grpcEndpoints.length)]; const grpcEndpoint =
log = log.withField("endpoint", grpcEndpoint); grpcEndpoints[Math.floor(Math.random() * grpcEndpoints.length)];
grpc_client = native.connect(grpcEndpoint, '', log = log.withField('endpoint', grpcEndpoint);
__ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 0, grpc_client = native.connect(
grpcEndpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 0,
__ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_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 // Connect to random S3 endpoint
let s3_client = undefined; let s3_client = undefined;
if (__ENV.S3_ENDPOINTS) { if (__ENV.S3_ENDPOINTS) {
const no_verify_ssl = __ENV.NO_VERIFY_SSL || "true"; const no_verify_ssl = __ENV.NO_VERIFY_SSL || 'true';
const connection_args = {no_verify_ssl: no_verify_ssl} const connection_args = {no_verify_ssl: no_verify_ssl};
const s3_endpoints = __ENV.S3_ENDPOINTS.split(','); const s3_endpoints = __ENV.S3_ENDPOINTS.split(',');
const s3_endpoint = s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)]; const s3_endpoint =
log = log.withField("endpoint", 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); s3_client = s3.connect(s3_endpoint, connection_args);
} }
// We will attempt to verify every object in "created" status. The scenario will execute // We will attempt to verify every object in "created" status. The scenario will
// as many iterations as there are objects. Each object will have 3 retries to be verified // execute as many iterations as there are objects. Each object will have 3
// retries to be verified
const obj_to_verify_selector = registry.getSelector( const obj_to_verify_selector = registry.getSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, 'obj_to_verify',
"obj_to_verify", __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, status: 'created',
{ });
status: "created",
}
);
const obj_to_verify_count = obj_to_verify_selector.count(); 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); 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 vus = Math.min(__ENV.CLIENTS, iterations);
const scenarios = { const scenarios = {
@ -92,10 +97,8 @@ export function setup() {
// Populate counters with initial values // Populate counters with initial values
for (const [status, counter] of Object.entries(obj_counters)) { for (const [status, counter] of Object.entries(obj_counters)) {
const obj_selector = registry.getSelector( const obj_selector = registry.getSelector(
__ENV.REGISTRY_FILE, __ENV.REGISTRY_FILE, status,
status, __ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0, {status});
__ENV.SELECTION_SIZE ? parseInt(__ENV.SELECTION_SIZE) : 0,
{ status });
counter.add(obj_selector.count()); counter.add(obj_selector.count());
} }
} }
@ -109,7 +112,7 @@ export function handleSummary(data) {
export function obj_verify() { export function obj_verify() {
if (obj_to_verify_count == 0) { if (obj_to_verify_count == 0) {
log.info("Nothing to verify"); log.info('Nothing to verify');
return; return;
} }
@ -119,7 +122,7 @@ export function obj_verify() {
const obj = obj_to_verify_selector.nextObject(); const obj = obj_to_verify_selector.nextObject();
if (!obj) { if (!obj) {
log.info("All objects have been verified"); log.info('All objects have been verified');
return; 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); result = grpc_client.verifyHash(obj.c_id, obj.o_id, obj.payload_hash);
} else if (obj.s3_bucket && obj.s3_key) { } else if (obj.s3_bucket && obj.s3_key) {
lg = lg.withFields({bucket: obj.s3_bucket, key: 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 { } else {
lg.withFields({ lg.withFields({
cid: obj.c_id, cid: obj.c_id,
@ -147,19 +151,20 @@ function verify_object_with_retries(obj, attempts) {
bucket: obj.s3_bucket, bucket: obj.s3_bucket,
key: obj.s3_key key: obj.s3_key
}).warn(`Object cannot be verified with supported protocols`); }).warn(`Object cannot be verified with supported protocols`);
return "skipped"; return 'skipped';
} }
if (result.success) { if (result.success) {
return "verified"; return 'verified';
} else if (result.error == "hash mismatch") { } else if (result.error == 'hash mismatch') {
return "invalid"; 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`); lg.error(`Verify error: ${result.error}. Object will be re-tried`);
sleep(__ENV.SLEEP); sleep(__ENV.SLEEP);
} }
return "invalid"; return 'invalid';
} }