[#154] scenarios: Format js files with clang formatter
All checks were successful
DCO action / DCO (pull_request) Successful in 1m4s
Tests and linters / Tests (1.21) (pull_request) Successful in 2m8s
Tests and linters / Tests (1.22) (pull_request) Successful in 2m38s
Tests and linters / Lint (pull_request) Successful in 4m6s
Tests and linters / Tests with -race (pull_request) Successful in 2m52s

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
Ekaterina Lebedeva 2024-07-25 18:38:51 +03:00
parent 4ec75a1c89
commit 5f20d5d88a
6 changed files with 337 additions and 326 deletions

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';
@ -27,17 +27,18 @@ 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 = const grpc_endpoint =
grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)]; grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)];
const grpc_client = native.connect( const grpc_client = native.connect(
grpc_endpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5, 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'
1024 * parseInt(__ENV.MAX_OBJECT_SIZE || '0')); : false,
1024 * parseInt(__ENV.MAX_OBJECT_SIZE || '0'));
const log = logging.new().withField('endpoint', grpc_endpoint); const log = logging.new().withField('endpoint', grpc_endpoint);
const registry_enabled = !!__ENV.REGISTRY_FILE; const registry_enabled = !!__ENV.REGISTRY_FILE;
const obj_registry = const obj_registry =
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined; registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
const duration = __ENV.DURATION; const duration = __ENV.DURATION;
@ -49,11 +50,11 @@ 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, '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,
}) })
} }
const scenarios = {}; const scenarios = {};
@ -63,11 +64,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',
}; };
} }
@ -78,24 +79,24 @@ if (registry_enabled && delete_age) {
obj_to_delete_exit_on_null = write_vu_count == 0; obj_to_delete_exit_on_null = write_vu_count == 0;
let constructor = obj_to_delete_exit_on_null ? registry.getOneshotSelector let constructor = obj_to_delete_exit_on_null ? registry.getOneshotSelector
: registry.getSelector; : registry.getSelector;
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',
}; };
} }
@ -103,21 +104,21 @@ const delete_vu_count = parseInt(__ENV.DELETERS || '0');
if (delete_vu_count > 0) { if (delete_vu_count > 0) {
if (!obj_to_delete_selector && !obj_list.length) { if (!obj_to_delete_selector && !obj_list.length) {
throw new Error( throw new Error(
'Positive DELETE worker number without a proper object selector or any preloaded objects'); 'Positive DELETE worker number without a proper object selector or any preloaded objects');
} }
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() {
@ -133,7 +134,7 @@ export function setup() {
const start_timestamp = Date.now() const start_timestamp = Date.now()
console.log( console.log(
`Load started at: ${Date(start_timestamp).toString()}`) `Load started at: ${Date(start_timestamp).toString()}`)
} }
export function teardown(data) { export function teardown(data) {
@ -142,13 +143,13 @@ export function teardown(data) {
} }
const end_timestamp = Date.now() const end_timestamp = Date.now()
console.log( console.log(
`Load finished at: ${Date(end_timestamp).toString()}`) `Load finished at: ${Date(end_timestamp).toString()}`)
} }
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,13 +158,13 @@ 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)];
const payload = generator.genPayload(); const payload = generator.genPayload();
const resp = const resp =
grpc_client.put(container, headers, payload, write_grpc_chunk_size); 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;
@ -186,7 +187,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 +195,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 +215,8 @@ 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, op : 'DELETE' }).error(resp.error); log.withFields({cid : obj.c_id, oid : obj.o_id, op : 'DELETE'})
.error(resp.error);
return; return;
} }
obj_registry.deleteObject(obj.id); obj_registry.deleteObject(obj.id);
@ -224,6 +226,7 @@ export function obj_delete() {
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.delete(obj.container, obj.object) const resp = grpc_client.delete(obj.container, obj.object)
if (!resp.success) { if (!resp.success) {
log.withFields({ cid: obj.container, oid: obj.object, op : 'DELETE' }).error(resp.error); log.withFields({cid : obj.container, oid : obj.object, op : 'DELETE'})
.error(resp.error);
} }
} }

View file

@ -1,24 +1,24 @@
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(
return JSON.parse(open(__ENV.PREGEN_JSON)).objects; 'obj_list',
}); function() { return JSON.parse(open(__ENV.PREGEN_JSON)).objects; });
const container_list = new SharedArray('container_list', function () { const container_list = new SharedArray(
return JSON.parse(open(__ENV.PREGEN_JSON)).containers; 'container_list',
}); 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';
@ -26,17 +26,18 @@ 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 = const grpc_endpoint =
grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)]; grpc_endpoints[Math.floor(Math.random() * grpc_endpoints.length)];
const grpc_client = native.connect( const grpc_client = native.connect(
grpc_endpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 5, 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'
1024 * parseInt(__ENV.MAX_OBJECT_SIZE || '0')); : false,
1024 * parseInt(__ENV.MAX_OBJECT_SIZE || '0'));
const log = logging.new().withField('endpoint', grpc_endpoint); const log = logging.new().withField('endpoint', grpc_endpoint);
const registry_enabled = !!__ENV.REGISTRY_FILE; const registry_enabled = !!__ENV.REGISTRY_FILE;
const obj_registry = const obj_registry =
registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined; registry_enabled ? registry.open(__ENV.REGISTRY_FILE) : undefined;
const duration = __ENV.DURATION; const duration = __ENV.DURATION;
@ -48,22 +49,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, 'obj_to_delete', __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_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, '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,
}) })
} }
const scenarios = {}; const scenarios = {};
@ -76,14 +77,14 @@ const write_grpc_chunk_size = 1024 * parseInt(__ENV.GRPC_CHUNK_SIZE || '0')
const generator = newGenerator(write_rate > 0); const generator = newGenerator(write_rate > 0);
if (write_rate > 0) { if (write_rate > 0) {
scenarios.write = { scenarios.write = {
executor: 'constant-arrival-rate', executor : 'constant-arrival-rate',
duration: `${duration}s`, duration : `${duration}s`,
preAllocatedVUs: pre_alloc_write_vus, preAllocatedVUs : pre_alloc_write_vus,
maxVUs: max_write_vus, maxVUs : max_write_vus,
rate: write_rate, rate : write_rate,
timeUnit: time_unit, timeUnit : time_unit,
exec: 'obj_write', exec : 'obj_write',
gracefulStop: '5s', gracefulStop : '5s',
}; };
} }
@ -92,14 +93,14 @@ const max_read_vus = parseInt(__ENV.MAX_READERS || pre_alloc_read_vus);
const read_rate = parseInt(__ENV.READ_RATE || '0'); const read_rate = parseInt(__ENV.READ_RATE || '0');
if (read_rate > 0) { if (read_rate > 0) {
scenarios.read = { scenarios.read = {
executor: 'constant-arrival-rate', executor : 'constant-arrival-rate',
duration: `${duration}s`, duration : `${duration}s`,
preAllocatedVUs: pre_alloc_write_vus, preAllocatedVUs : pre_alloc_write_vus,
maxVUs: max_read_vus, maxVUs : max_read_vus,
rate: read_rate, rate : read_rate,
timeUnit: time_unit, timeUnit : time_unit,
exec: 'obj_read', exec : 'obj_read',
gracefulStop: '5s', gracefulStop : '5s',
}; };
} }
@ -109,29 +110,29 @@ const delete_rate = parseInt(__ENV.DELETE_RATE || '0');
if (delete_rate > 0) { if (delete_rate > 0) {
if (!obj_to_delete_selector && !obj_list.length) { if (!obj_to_delete_selector && !obj_list.length) {
throw new Error( throw new Error(
'Positive DELETE worker number without a proper object selector or any preloaded objects'); 'Positive DELETE worker number without a proper object selector or any preloaded objects');
} }
scenarios.delete = { scenarios.delete = {
executor: 'constant-arrival-rate', executor : 'constant-arrival-rate',
duration: `${duration}s`, duration : `${duration}s`,
preAllocatedVUs: pre_alloc_delete_vus, preAllocatedVUs : pre_alloc_delete_vus,
maxVUs: max_delete_vus, maxVUs : max_delete_vus,
rate: delete_rate, rate : delete_rate,
timeUnit: time_unit, timeUnit : time_unit,
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() {
const total_pre_allocated_vu_count = const total_pre_allocated_vu_count =
pre_alloc_write_vus + pre_alloc_read_vus + pre_alloc_delete_vus; 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}`);
@ -152,7 +153,7 @@ export function setup() {
const start_timestamp = Date.now() const start_timestamp = Date.now()
console.log( console.log(
`Load started at: ${Date(start_timestamp).toString()}`) `Load started at: ${Date(start_timestamp).toString()}`)
} }
export function teardown(data) { export function teardown(data) {
@ -161,13 +162,13 @@ export function teardown(data) {
} }
const end_timestamp = Date.now() const end_timestamp = Date.now()
console.log( console.log(
`Load finished at: ${Date(end_timestamp).toString()}`) `Load finished at: ${Date(end_timestamp).toString()}`)
} }
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,13 +177,13 @@ 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)];
const payload = generator.genPayload(); const payload = generator.genPayload();
const resp = const resp =
grpc_client.put(container, headers, payload, write_grpc_chunk_size); 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;
@ -205,7 +206,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 +214,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);
} }
} }
@ -231,7 +232,8 @@ 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, op : 'DELETE' }).error(resp.error); log.withFields({cid : obj.c_id, oid : obj.o_id, op : 'DELETE'})
.error(resp.error);
return; return;
} }
@ -242,6 +244,7 @@ export function obj_delete() {
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.delete(obj.container, obj.object) const resp = grpc_client.delete(obj.container, obj.object)
if (!resp.success) { if (!resp.success) {
log.withFields({ cid: obj.container, oid: obj.object, op : 'DELETE' }).error(resp.error); log.withFields({cid : obj.container, oid : obj.object, op : 'DELETE'})
.error(resp.error);
} }
} }

View file

@ -12,13 +12,13 @@ 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(
return JSON.parse(open(__ENV.PREGEN_JSON)).objects; 'obj_list',
}); function() { return JSON.parse(open(__ENV.PREGEN_JSON)).objects; });
const container_list = new SharedArray('container_list', function() { const container_list = new SharedArray(
return JSON.parse(open(__ENV.PREGEN_JSON)).containers; 'container_list',
}); 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';
@ -31,7 +31,7 @@ const max_total_size_gb =
const local_client = const local_client =
local.connect(config_file, config_dir, '', debug_logger, max_total_size_gb); local.connect(config_file, config_dir, '', debug_logger, max_total_size_gb);
const log = logging.new().withFields( const log = logging.new().withFields(
{'config_file': config_file, 'config_dir': config_dir}); {'config_file' : config_file, 'config_dir' : config_dir});
const registry_enabled = !!__ENV.REGISTRY_FILE; const registry_enabled = !!__ENV.REGISTRY_FILE;
const obj_registry = const obj_registry =
@ -49,8 +49,8 @@ if (registry_enabled && delete_age) {
obj_to_delete_selector = registry.getSelector( obj_to_delete_selector = registry.getSelector(
__ENV.REGISTRY_FILE, 'obj_to_delete', __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,
}); });
} }
@ -60,22 +60,22 @@ const write_vu_count = parseInt(__ENV.WRITERS || '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',
}; };
} }
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',
}; };
} }
@ -87,17 +87,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() {
@ -127,13 +127,13 @@ 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),
}; };
} }
export function obj_write() { export function obj_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)];
@ -156,7 +156,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 = local_client.get(obj.container, obj.object) const resp = local_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);
} }
} }
@ -170,7 +170,7 @@ export function obj_delete() {
const resp = local_client.delete(obj.c_id, obj.o_id); const resp = local_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

@ -102,7 +102,7 @@ const delete_vu_count = parseInt(__ENV.DELETERS || '0');
if (delete_vu_count > 0) { if (delete_vu_count > 0) {
if (!obj_to_delete_selector && !obj_list.length) { if (!obj_to_delete_selector && !obj_list.length) {
throw new Error( throw new Error(
'Positive DELETE worker number without a proper object selector or any preloaded objects'); 'Positive DELETE worker number without a proper object selector or any preloaded objects');
} }
scenarios.delete = { scenarios.delete = {
@ -226,6 +226,7 @@ export function obj_delete() {
const resp = s3_client.delete(obj.bucket, obj.object); const resp = s3_client.delete(obj.bucket, obj.object);
if (!resp.success) { if (!resp.success) {
log.withFields({bucket : obj.bucket, key : obj.object, op : 'DELETE'}).error(resp.error); log.withFields({bucket : obj.bucket, key : obj.object, op : 'DELETE'})
.error(resp.error);
} }
} }

View file

@ -12,13 +12,13 @@ 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(
return JSON.parse(open(__ENV.PREGEN_JSON)).objects; 'obj_list',
}); function() { return JSON.parse(open(__ENV.PREGEN_JSON)).objects; });
const bucket_list = new SharedArray('bucket_list', function() { const bucket_list = new SharedArray(
return JSON.parse(open(__ENV.PREGEN_JSON)).buckets; 'bucket_list',
}); function() { return JSON.parse(open(__ENV.PREGEN_JSON)).buckets; });
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';
@ -29,7 +29,7 @@ const s3_endpoint =
s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)]; s3_endpoints[Math.floor(Math.random() * s3_endpoints.length)];
const no_verify_ssl = __ENV.NO_VERIFY_SSL || 'true'; const no_verify_ssl = __ENV.NO_VERIFY_SSL || 'true';
const connection_args = { const connection_args = {
no_verify_ssl: no_verify_ssl 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);
@ -50,8 +50,8 @@ if (registry_enabled && delete_age) {
obj_to_delete_selector = registry.getSelector( obj_to_delete_selector = registry.getSelector(
__ENV.REGISTRY_FILE, 'obj_to_delete', __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,
}); });
} }
@ -61,8 +61,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,
}) })
} }
@ -75,35 +75,33 @@ const write_rate = parseInt(__ENV.WRITE_RATE || '0');
const generator = newGenerator(write_rate > 0); const generator = newGenerator(write_rate > 0);
if (write_rate > 0) { if (write_rate > 0) {
scenarios.write = { scenarios.write = {
executor: 'constant-arrival-rate', executor : 'constant-arrival-rate',
duration: `${duration}s`, duration : `${duration}s`,
preAllocatedVUs: pre_alloc_write_vus, preAllocatedVUs : pre_alloc_write_vus,
maxVUs: max_write_vus, maxVUs : max_write_vus,
rate: write_rate, rate : write_rate,
timeUnit: time_unit, timeUnit : time_unit,
exec: 'obj_write', exec : 'obj_write',
gracefulStop: '5s', gracefulStop : '5s',
}; };
} }
const pre_alloc_read_vus = parseInt(__ENV.PRE_ALLOC_READERS || '0'); const pre_alloc_read_vus = parseInt(__ENV.PRE_ALLOC_READERS || '0');
const max_read_vus = parseInt(__ENV.MAX_READERS || pre_alloc_read_vus); const max_read_vus = parseInt(__ENV.MAX_READERS || pre_alloc_read_vus);
const read_rate = parseInt(__ENV.READ_RATE || '0'); const read_rate = parseInt(__ENV.READ_RATE || '0');
if (read_rate > 0) { if (read_rate > 0) {
scenarios.read = { scenarios.read = {
executor: 'constant-arrival-rate', executor : 'constant-arrival-rate',
duration: `${duration}s`, duration : `${duration}s`,
preAllocatedVUs: pre_alloc_write_vus, preAllocatedVUs : pre_alloc_write_vus,
maxVUs: max_read_vus, maxVUs : max_read_vus,
rate: read_rate, rate : read_rate,
timeUnit: time_unit, timeUnit : time_unit,
exec: 'obj_read', exec : 'obj_read',
gracefulStop: '5s', gracefulStop : '5s',
}; };
} }
const pre_alloc_delete_vus = parseInt(__ENV.PRE_ALLOC_DELETERS || '0'); const pre_alloc_delete_vus = parseInt(__ENV.PRE_ALLOC_DELETERS || '0');
const max_delete_vus = parseInt(__ENV.MAX_DELETERS || pre_alloc_write_vus); 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');
@ -114,20 +112,20 @@ if (delete_rate > 0) {
} }
scenarios.delete = { scenarios.delete = {
executor: 'constant-arrival-rate', executor : 'constant-arrival-rate',
duration: `${duration}s`, duration : `${duration}s`,
preAllocatedVUs: pre_alloc_delete_vus, preAllocatedVUs : pre_alloc_delete_vus,
maxVUs: max_delete_vus, maxVUs : max_delete_vus,
rate: delete_rate, rate : delete_rate,
timeUnit: time_unit, timeUnit : time_unit,
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() {
@ -167,8 +165,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),
}; };
} }
@ -183,7 +181,7 @@ export function obj_write() {
const payload = generator.genPayload(); const payload = generator.genPayload();
const resp = s3_client.put(bucket, key, payload); const resp = s3_client.put(bucket, key, 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;
} }
@ -204,7 +202,7 @@ 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}) log.withFields({bucket : obj.s3_bucket, key : obj.s3_key})
.error(resp.error); .error(resp.error);
} }
return return
@ -214,7 +212,7 @@ export function obj_read() {
const resp = s3_client.get(obj.bucket, obj.object); const resp = s3_client.get(obj.bucket, obj.object);
if (!resp.success) { if (!resp.success) {
log.withFields({bucket: obj.bucket, key: obj.object}).error(resp.error); log.withFields({bucket : obj.bucket, key : obj.object}).error(resp.error);
} }
} }
@ -231,7 +229,7 @@ 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'}) log.withFields({bucket : obj.s3_bucket, key : obj.s3_key, op : 'DELETE'})
.error(resp.error); .error(resp.error);
return; return;
} }
@ -244,6 +242,7 @@ export function obj_delete() {
const resp = s3_client.delete(obj.bucket, obj.object); const resp = s3_client.delete(obj.bucket, obj.object);
if (!resp.success) { if (!resp.success) {
log.withFields({bucket: obj.bucket, key: obj.object, op : 'DELETE'}).error(resp.error); log.withFields({bucket : obj.bucket, key : obj.object, op : 'DELETE'})
.error(resp.error);
} }
} }

View file

@ -27,7 +27,7 @@ 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 = { const connection_args = {
no_verify_ssl : no_verify_ssl 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(',');
@ -43,18 +43,18 @@ const obj_registry =
const duration = __ENV.DURATION; const duration = __ENV.DURATION;
if (!!__ENV.METRIC_TAGS) { if (!!__ENV.METRIC_TAGS) {
stats.setTags(__ENV.METRIC_TAGS) stats.setTags(__ENV.METRIC_TAGS)
} }
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.getSelector( obj_to_read_selector = registry.getSelector(
__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,
}) })
} }
const scenarios = {}; const scenarios = {};
@ -62,183 +62,188 @@ const scenarios = {};
const write_vu_count = parseInt(__ENV.WRITERS || '0'); const write_vu_count = parseInt(__ENV.WRITERS || '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',
}; };
} }
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',
}; };
} }
const delete_age = __ENV.DELETE_AGE ? parseInt(__ENV.DELETE_AGE) : undefined; const delete_age = __ENV.DELETE_AGE ? parseInt(__ENV.DELETE_AGE) : undefined;
let obj_to_delete_selector = undefined; let obj_to_delete_selector = undefined;
let obj_to_delete_exit_on_null = undefined; let obj_to_delete_exit_on_null = undefined;
if (registry_enabled ) { if (registry_enabled) {
obj_to_delete_exit_on_null = (write_vu_count == 0) && (read_vu_count == 0) obj_to_delete_exit_on_null = (write_vu_count == 0) && (read_vu_count == 0)
let constructor = obj_to_delete_exit_on_null ? registry.getOneshotSelector let constructor = obj_to_delete_exit_on_null ? registry.getOneshotSelector
: registry.getSelector; : registry.getSelector;
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 : 'read', status : 'read',
age : delete_age, age : delete_age,
}); });
} }
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( throw new Error(
'Positive DELETE worker number without a proper object selector'); 'Positive DELETE worker number without a proper object selector');
} }
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() {
const total_vu_count = write_vu_count + read_vu_count + delete_vu_count; const total_vu_count = write_vu_count + read_vu_count + delete_vu_count;
console.log(`Pregenerated buckets: ${bucket_list.length}`); console.log(`Pregenerated buckets: ${bucket_list.length}`);
console.log(`Pregenerated read object size: ${read_size}`); console.log(`Pregenerated read object size: ${read_size}`);
console.log(`Pregenerated total objects: ${obj_list.length}`); console.log(`Pregenerated total objects: ${obj_list.length}`);
console.log(`Reading VUs: ${read_vu_count}`); console.log(`Reading VUs: ${read_vu_count}`);
console.log(`Writing VUs: ${write_vu_count}`); console.log(`Writing VUs: ${write_vu_count}`);
console.log(`Deleting VUs: ${delete_vu_count}`); console.log(`Deleting VUs: ${delete_vu_count}`);
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( console.log(
`Load started at: ${Date(start_timestamp).toString()}`) `Load started at: ${Date(start_timestamp).toString()}`)
} }
export function teardown(data) { export function teardown(data) {
if (obj_registry) { if (obj_registry) {
obj_registry.close(); obj_registry.close();
} }
const end_timestamp = Date.now() const end_timestamp = Date.now()
console.log( console.log(
`Load finished at: ${Date(end_timestamp).toString()}`) `Load finished at: ${Date(end_timestamp).toString()}`)
} }
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),
}; };
} }
export function obj_write() { export function obj_write() {
if (__ENV.SLEEP_WRITE) { if (__ENV.SLEEP_WRITE) {
sleep(__ENV.SLEEP_WRITE); sleep(__ENV.SLEEP_WRITE);
} }
const key = __ENV.OBJ_NAME || uuidv4(); const key = __ENV.OBJ_NAME || uuidv4();
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.put(bucket, key, payload); const resp = s3_client.put(bucket, key, 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());
} }
} }
export function obj_read() { export function obj_read() {
if (__ENV.SLEEP_READ) { if (__ENV.SLEEP_READ) {
sleep(__ENV.SLEEP_READ); sleep(__ENV.SLEEP_READ);
}
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 (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, status: obj.status, op: `READ`})
.error(resp.error);
} else {
obj_registry.setObjectStatus(obj.id, obj.status, 'read');
}
return
}
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
const resp = s3_client.get(obj.bucket, obj.object);
if (!resp.success) { if (!resp.success) {
log.withFields({bucket : obj.bucket, key : obj.object}).error(resp.error); log.withFields({
} else { bucket : obj.s3_bucket,
obj_registry.setObjectStatus(obj.id, obj.status, 'read'); key : obj.s3_key,
status : obj.status,
op : `READ`
})
.error(resp.error);
} }
else {
obj_registry.setObjectStatus(obj.id, obj.status, 'read');
}
return
}
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
const resp = s3_client.get(obj.bucket, obj.object);
if (!resp.success) {
log.withFields({bucket : obj.bucket, key : obj.object}).error(resp.error);
} else {
obj_registry.setObjectStatus(obj.id, obj.status, 'read');
}
} }
export function obj_delete() { export function obj_delete() {
if (__ENV.SLEEP_DELETE) { if (__ENV.SLEEP_DELETE) {
sleep(__ENV.SLEEP_DELETE); sleep(__ENV.SLEEP_DELETE);
} }
if (obj_to_delete_selector) { if (obj_to_delete_selector) {
const obj = obj_to_delete_selector.nextObject(); const obj = obj_to_delete_selector.nextObject();
delete_object(obj) delete_object(obj)
return return
} }
const obj = obj_list[Math.floor(Math.random() * obj_list.length)]; const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
const resp = s3_client.delete(obj.bucket, obj.object); const resp = s3_client.delete(obj.bucket, obj.object);
if (!resp.success) { if (!resp.success) {
log.withFields({bucket: obj.bucket, key: obj.object, op : 'DELETE'}).error(resp.error); log.withFields({bucket : obj.bucket, key : obj.object, op : 'DELETE'})
} .error(resp.error);
}
} }
export function delete_object(obj) { export function delete_object(obj) {
if (!obj) { if (!obj) {
if (obj_to_delete_exit_on_null) { if (obj_to_delete_exit_on_null) {
exec.test.abort("No more objects to select"); exec.test.abort("No more objects to select");
}
return;
} }
return;
}
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'}) log.withFields({bucket : obj.s3_bucket, key : obj.s3_key, op : 'DELETE'})
.error(resp.error); .error(resp.error);
return; return;
} }
obj_registry.deleteObject(obj.id); obj_registry.deleteObject(obj.id);
} }