[#145] scenarios: Format js files with clang
All checks were successful
DCO action / DCO (pull_request) Successful in 1m18s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m10s
Tests and linters / Tests (1.21) (pull_request) Successful in 3m27s
Tests and linters / Tests with -race (pull_request) Successful in 3m28s
Tests and linters / Lint (pull_request) Successful in 4m29s

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-06-14 11:26:01 +03:00
parent 6d1e7eb49e
commit e92ce668a8
5 changed files with 119 additions and 119 deletions

View file

@ -7,7 +7,7 @@ const frostfs_cli = native.connect("s01.frostfs.devenv:8080", "1dd37fba80fec4e6a
export const options = { export const options = {
stages: [ stages: [
{duration: '30s', target: 10}, { duration: '30s', target: 10 },
], ],
}; };
@ -24,7 +24,7 @@ export function setup() {
fail(res.error) fail(res.error)
} }
console.info("created container", res.container_id) console.info("created container", res.container_id)
return {container_id: res.container_id} return { container_id: res.container_id }
} }
export default function (data) { export default function (data) {

View file

@ -1,25 +1,25 @@
import {sleep} from 'k6'; import { sleep } from 'k6';
import {SharedArray} from 'k6/data'; import { SharedArray } from 'k6/data';
import exec from 'k6/execution'; import exec from 'k6/execution';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import native from 'k6/x/frostfs/native'; 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 {newGenerator} from './libs/datagen.js'; import { newGenerator } from './libs/datagen.js';
import {parseEnv} from './libs/env-parser.js'; import { parseEnv } from './libs/env-parser.js';
import {textSummary} from './libs/k6-summary-0.0.2.js'; import { textSummary } from './libs/k6-summary-0.0.2.js';
import {uuidv4} from './libs/k6-utils-1.4.0.js'; import { uuidv4 } from './libs/k6-utils-1.4.0.js';
parseEnv(); parseEnv();
const obj_list = new SharedArray( const obj_list = new SharedArray(
'obj_list', 'obj_list',
function() { return JSON.parse(open(__ENV.PREGEN_JSON)).objects; }); function () { return JSON.parse(open(__ENV.PREGEN_JSON)).objects; });
const container_list = new SharedArray( const container_list = new SharedArray(
'container_list', 'container_list',
function() { return JSON.parse(open(__ENV.PREGEN_JSON)).containers; }); function () { return JSON.parse(open(__ENV.PREGEN_JSON)).containers; });
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';
@ -51,8 +51,8 @@ if (registry_enabled) {
obj_to_read_selector = registry.getLoopedSelector( obj_to_read_selector = registry.getLoopedSelector(
__ENV.REGISTRY_FILE, 'obj_to_read', __ENV.REGISTRY_FILE, '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,
}) })
} }
@ -63,11 +63,11 @@ const write_grpc_chunk_size = 1024 * parseInt(__ENV.GRPC_CHUNK_SIZE || '0')
const generator = newGenerator(write_vu_count > 0); const generator = newGenerator(write_vu_count > 0);
if (write_vu_count > 0) { if (write_vu_count > 0) {
scenarios.write = { scenarios.write = {
executor : 'constant-vus', executor: 'constant-vus',
vus : write_vu_count, vus: write_vu_count,
duration : `${duration}s`, duration: `${duration}s`,
exec : 'obj_write', exec: 'obj_write',
gracefulStop : '5s', gracefulStop: '5s',
}; };
} }
@ -83,19 +83,19 @@ if (registry_enabled && delete_age) {
obj_to_delete_selector = obj_to_delete_selector =
constructor(__ENV.REGISTRY_FILE, 'obj_to_delete', constructor(__ENV.REGISTRY_FILE, '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_vu_count = parseInt(__ENV.READERS || '0'); const read_vu_count = parseInt(__ENV.READERS || '0');
if (read_vu_count > 0) { if (read_vu_count > 0) {
scenarios.read = { scenarios.read = {
executor : 'constant-vus', executor: 'constant-vus',
vus : read_vu_count, vus: read_vu_count,
duration : `${duration}s`, duration: `${duration}s`,
exec : 'obj_read', exec: 'obj_read',
gracefulStop : '5s', gracefulStop: '5s',
}; };
} }
@ -107,17 +107,17 @@ if (delete_vu_count > 0) {
} }
scenarios.delete = { scenarios.delete = {
executor : 'constant-vus', executor: 'constant-vus',
vus : delete_vu_count, vus: delete_vu_count,
duration : `${duration}s`, duration: `${duration}s`,
exec : 'obj_delete', exec: 'obj_delete',
gracefulStop : '5s', gracefulStop: '5s',
}; };
} }
export const options = { export const options = {
scenarios, scenarios,
setupTimeout : '5s', setupTimeout: '5s',
}; };
export function setup() { export function setup() {
@ -147,8 +147,8 @@ export function teardown(data) {
export function handleSummary(data) { export function handleSummary(data) {
return { return {
'stdout' : textSummary(data, {indent : ' ', enableColors : false}), 'stdout': textSummary(data, { indent: ' ', enableColors: false }),
[summary_json] : JSON.stringify(data), [summary_json]: JSON.stringify(data),
}; };
} }
@ -157,7 +157,7 @@ export function obj_write() {
sleep(__ENV.SLEEP_WRITE); sleep(__ENV.SLEEP_WRITE);
} }
const headers = {unique_header : uuidv4()}; const headers = { unique_header: uuidv4() };
const container = const container =
container_list[Math.floor(Math.random() * container_list.length)]; container_list[Math.floor(Math.random() * container_list.length)];
@ -186,7 +186,7 @@ export function obj_read() {
} }
const resp = grpc_client.get(obj.c_id, obj.o_id) const resp = grpc_client.get(obj.c_id, obj.o_id)
if (!resp.success) { if (!resp.success) {
log.withFields({cid : obj.c_id, oid : obj.o_id}).error(resp.error); log.withFields({ cid: obj.c_id, oid: obj.o_id }).error(resp.error);
} }
return return
} }
@ -194,7 +194,7 @@ 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 = grpc_client.get(obj.container, obj.object) const resp = grpc_client.get(obj.container, obj.object)
if (!resp.success) { if (!resp.success) {
log.withFields({cid : obj.container, oid : obj.object}).error(resp.error); log.withFields({ cid: obj.container, oid: obj.object }).error(resp.error);
} }
} }
@ -214,7 +214,7 @@ export function obj_delete() {
const resp = grpc_client.delete(obj.c_id, obj.o_id); const resp = grpc_client.delete(obj.c_id, obj.o_id);
if (!resp.success) { if (!resp.success) {
// Log errors except (2052 - object already deleted) // Log errors except (2052 - object already deleted)
log.withFields({cid : obj.c_id, oid : obj.o_id}).error(resp.error); log.withFields({ cid: obj.c_id, oid: obj.o_id }).error(resp.error);
return; return;
} }

View file

@ -1,22 +1,22 @@
import {sleep} from 'k6'; import { sleep } from 'k6';
import {SharedArray} from 'k6/data'; 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 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 {newGenerator} from './libs/datagen.js'; import { newGenerator } from './libs/datagen.js';
import {parseEnv} from './libs/env-parser.js'; import { parseEnv } from './libs/env-parser.js';
import {textSummary} from './libs/k6-summary-0.0.2.js'; import { textSummary } from './libs/k6-summary-0.0.2.js';
import {uuidv4} from './libs/k6-utils-1.4.0.js'; import { uuidv4 } from './libs/k6-utils-1.4.0.js';
parseEnv(); 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; 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; return JSON.parse(open(__ENV.PREGEN_JSON)).containers;
}); });
@ -166,7 +166,7 @@ export function teardown(data) {
export function handleSummary(data) { export function handleSummary(data) {
return { return {
'stdout': textSummary(data, {indent: ' ', enableColors: false}), 'stdout': textSummary(data, { indent: ' ', enableColors: false }),
[summary_json]: JSON.stringify(data), [summary_json]: JSON.stringify(data),
}; };
} }
@ -176,7 +176,7 @@ export function obj_write() {
sleep(__ENV.SLEEP_WRITE); sleep(__ENV.SLEEP_WRITE);
} }
const headers = {unique_header: uuidv4()}; const headers = { unique_header: uuidv4() };
const container = const container =
container_list[Math.floor(Math.random() * container_list.length)]; container_list[Math.floor(Math.random() * container_list.length)];
@ -205,7 +205,7 @@ export function obj_read() {
} }
const resp = grpc_client.get(obj.c_id, obj.o_id) const resp = grpc_client.get(obj.c_id, obj.o_id)
if (!resp.success) { if (!resp.success) {
log.withFields({cid: obj.c_id, oid: obj.o_id}).error(resp.error); log.withFields({ cid: obj.c_id, oid: obj.o_id }).error(resp.error);
} }
return return
} }
@ -213,7 +213,7 @@ 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 = grpc_client.get(obj.container, obj.object) const resp = grpc_client.get(obj.container, obj.object)
if (!resp.success) { if (!resp.success) {
log.withFields({cid: obj.container, oid: obj.object}).error(resp.error); log.withFields({ cid: obj.container, oid: obj.object }).error(resp.error);
} }
} }
@ -230,7 +230,7 @@ export function obj_delete() {
const resp = grpc_client.delete(obj.c_id, obj.o_id); const resp = grpc_client.delete(obj.c_id, obj.o_id);
if (!resp.success) { if (!resp.success) {
// Log errors except (2052 - object already deleted) // Log errors except (2052 - object already deleted)
log.withFields({cid: obj.c_id, oid: obj.o_id}).error(resp.error); log.withFields({ cid: obj.c_id, oid: obj.o_id }).error(resp.error);
return; return;
} }

View file

@ -1,13 +1,13 @@
import {sleep} from 'k6'; import { sleep } from 'k6';
import {Counter} from 'k6/metrics'; import { Counter } from 'k6/metrics';
import logging from 'k6/x/frostfs/logging'; import logging from 'k6/x/frostfs/logging';
import native from 'k6/x/frostfs/native'; import native from 'k6/x/frostfs/native';
import registry from 'k6/x/frostfs/registry'; import registry from 'k6/x/frostfs/registry';
import s3 from 'k6/x/frostfs/s3'; import s3 from 'k6/x/frostfs/s3';
import stats from 'k6/x/frostfs/stats'; 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'; import { textSummary } from './libs/k6-summary-0.0.2.js';
parseEnv(); parseEnv();
@ -52,7 +52,7 @@ if (__ENV.GRPC_ENDPOINTS) {
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 = const s3_endpoint =
s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)]; s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
@ -67,7 +67,7 @@ const obj_to_verify_selector = registry.getSelector(
__ENV.REGISTRY_FILE, 'obj_to_verify', __ENV.REGISTRY_FILE, '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 // Execute at least one iteration (executor shared-iterations can't run 0
// iterations) // iterations)
@ -97,14 +97,14 @@ export function setup() {
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, status, __ENV.REGISTRY_FILE, 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());
} }
} }
export function handleSummary(data) { export function handleSummary(data) {
return { return {
'stdout': textSummary(data, {indent: ' ', enableColors: false}), 'stdout': textSummary(data, { indent: ' ', enableColors: false }),
[summary_json]: JSON.stringify(data), [summary_json]: JSON.stringify(data),
}; };
} }
@ -137,10 +137,10 @@ function verify_object_with_retries(obj, attempts) {
// ReferenceError: Cannot access a variable before initialization. // ReferenceError: Cannot access a variable before initialization.
let lg = log; let lg = log;
if (obj.c_id && obj.o_id) { if (obj.c_id && obj.o_id) {
lg = lg.withFields({cid: obj.c_id, oid: obj.o_id}); lg = lg.withFields({ cid: obj.c_id, oid: obj.o_id });
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 = result =
s3_client.verifyHash(obj.s3_bucket, obj.s3_key, obj.payload_hash); s3_client.verifyHash(obj.s3_bucket, obj.s3_key, obj.payload_hash);
} else { } else {