forked from TrueCloudLab/xk6-frostfs
[#133] scenarios: Format with clang-format
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
87ffb551b6
commit
86ed8add10
2 changed files with 67 additions and 67 deletions
|
@ -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';
|
||||||
|
@ -30,8 +30,8 @@ const grpc_endpoint =
|
||||||
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' :
|
__ENV.PREPARE_LOCALLY ? __ENV.PREPARE_LOCALLY.toLowerCase() === 'true'
|
||||||
false);
|
: false);
|
||||||
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;
|
||||||
|
@ -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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,22 +73,22 @@ 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',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,17 +100,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() {
|
||||||
|
@ -140,8 +140,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),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,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)];
|
||||||
|
|
||||||
|
@ -179,7 +179,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
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,20 +12,20 @@ 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';
|
||||||
|
|
||||||
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(',');
|
||||||
|
@ -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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,22 +72,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',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,17 +98,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() {
|
||||||
|
@ -138,8 +138,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),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,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
|
||||||
|
@ -185,7 +185,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue