forked from TrueCloudLab/xk6-frostfs
[#154] scenarios: Delete data created in preset
* Currently, objects created in preset are never deleted. k6 deletes only objects from registry, if registry file is not provided k6 delete load fails. * Changed delete scenarios so they check if registry was provided and if it is not empty, and if not, they try deleting objects created in preset. Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
9b9db46a07
commit
4ec75a1c89
6 changed files with 118 additions and 60 deletions
|
@ -101,9 +101,9 @@ if (read_vu_count > 0) {
|
|||
|
||||
const delete_vu_count = parseInt(__ENV.DELETERS || '0');
|
||||
if (delete_vu_count > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
if (!obj_to_delete_selector && !obj_list.length) {
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector');
|
||||
'Positive DELETE worker number without a proper object selector or any preloaded objects');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -203,6 +203,7 @@ export function obj_delete() {
|
|||
sleep(__ENV.SLEEP_DELETE);
|
||||
}
|
||||
|
||||
if (obj_to_delete_selector) {
|
||||
const obj = obj_to_delete_selector.nextObject();
|
||||
if (!obj) {
|
||||
if (obj_to_delete_exit_on_null) {
|
||||
|
@ -210,13 +211,19 @@ export function obj_delete() {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const resp = grpc_client.delete(obj.c_id, obj.o_id);
|
||||
if (!resp.success) {
|
||||
// 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, op : 'DELETE' }).error(resp.error);
|
||||
return;
|
||||
}
|
||||
|
||||
obj_registry.deleteObject(obj.id);
|
||||
return
|
||||
}
|
||||
|
||||
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
|
||||
const resp = grpc_client.delete(obj.container, obj.object)
|
||||
if (!resp.success) {
|
||||
log.withFields({ cid: obj.container, oid: obj.object, op : 'DELETE' }).error(resp.error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,9 +107,9 @@ const pre_alloc_delete_vus = parseInt(__ENV.PRE_ALLOC_DELETERS || '0');
|
|||
const max_delete_vus = parseInt(__ENV.MAX_DELETERS || pre_alloc_write_vus);
|
||||
const delete_rate = parseInt(__ENV.DELETE_RATE || '0');
|
||||
if (delete_rate > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
if (!obj_to_delete_selector && !obj_list.length) {
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector');
|
||||
'Positive DELETE worker number without a proper object selector or any preloaded objects');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -222,6 +222,7 @@ export function obj_delete() {
|
|||
sleep(__ENV.SLEEP_DELETE);
|
||||
}
|
||||
|
||||
if (obj_to_delete_selector) {
|
||||
const obj = obj_to_delete_selector.nextObject();
|
||||
if (!obj) {
|
||||
return;
|
||||
|
@ -230,9 +231,17 @@ export function obj_delete() {
|
|||
const resp = grpc_client.delete(obj.c_id, obj.o_id);
|
||||
if (!resp.success) {
|
||||
// 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, op : 'DELETE' }).error(resp.error);
|
||||
return;
|
||||
}
|
||||
|
||||
obj_registry.deleteObject(obj.id);
|
||||
return
|
||||
}
|
||||
|
||||
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
|
||||
const resp = grpc_client.delete(obj.container, obj.object)
|
||||
if (!resp.success) {
|
||||
log.withFields({ cid: obj.container, oid: obj.object, op : 'DELETE' }).error(resp.error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,9 +81,9 @@ if (read_vu_count > 0) {
|
|||
|
||||
const delete_vu_count = parseInt(__ENV.DELETERS || '0');
|
||||
if (delete_vu_count > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
if (!obj_to_delete_selector && !obj_list.length) {
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector');
|
||||
'Positive DELETE worker number without a proper object selector or any preloaded objects');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -161,6 +161,7 @@ export function obj_read() {
|
|||
}
|
||||
|
||||
export function obj_delete() {
|
||||
if (obj_to_delete_selector) {
|
||||
const obj = obj_to_delete_selector.nextObject();
|
||||
if (!obj) {
|
||||
return;
|
||||
|
@ -174,4 +175,13 @@ export function obj_delete() {
|
|||
}
|
||||
|
||||
obj_registry.deleteObject(obj.id);
|
||||
return
|
||||
}
|
||||
|
||||
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
|
||||
const resp = grpc_client.delete(obj.container, obj.object)
|
||||
if (!resp.success) {
|
||||
log.withFields({cid : obj.container, oid : obj.object, op : 'DELETE'})
|
||||
.error(resp.error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,8 +100,9 @@ if (read_vu_count > 0) {
|
|||
|
||||
const delete_vu_count = parseInt(__ENV.DELETERS || '0');
|
||||
if (delete_vu_count > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
throw 'Positive DELETE worker number without a proper object selector';
|
||||
if (!obj_to_delete_selector && !obj_list.length) {
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector or any preloaded objects');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -201,6 +202,7 @@ export function obj_delete() {
|
|||
sleep(__ENV.SLEEP_DELETE);
|
||||
}
|
||||
|
||||
if (obj_to_delete_selector) {
|
||||
const obj = obj_to_delete_selector.nextObject();
|
||||
if (!obj) {
|
||||
if (obj_to_delete_exit_on_null) {
|
||||
|
@ -217,4 +219,13 @@ export function obj_delete() {
|
|||
}
|
||||
|
||||
obj_registry.deleteObject(obj.id);
|
||||
return
|
||||
}
|
||||
|
||||
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
|
||||
|
||||
const resp = s3_client.delete(obj.bucket, obj.object);
|
||||
if (!resp.success) {
|
||||
log.withFields({bucket : obj.bucket, key : obj.object, op : 'DELETE'}).error(resp.error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,9 +108,9 @@ const pre_alloc_delete_vus = parseInt(__ENV.PRE_ALLOC_DELETERS || '0');
|
|||
const max_delete_vus = parseInt(__ENV.MAX_DELETERS || pre_alloc_write_vus);
|
||||
const delete_rate = parseInt(__ENV.DELETE_RATE || '0');
|
||||
if (delete_rate > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
if (!obj_to_delete_selector && !obj_list.length) {
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector');
|
||||
'Positive DELETE worker number without a proper object selector or any preloaded objects');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -223,6 +223,7 @@ export function obj_delete() {
|
|||
sleep(__ENV.SLEEP_DELETE);
|
||||
}
|
||||
|
||||
if (obj_to_delete_selector) {
|
||||
const obj = obj_to_delete_selector.nextObject();
|
||||
if (!obj) {
|
||||
return;
|
||||
|
@ -236,4 +237,13 @@ export function obj_delete() {
|
|||
}
|
||||
|
||||
obj_registry.deleteObject(obj.id);
|
||||
return
|
||||
}
|
||||
|
||||
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
|
||||
|
||||
const resp = s3_client.delete(obj.bucket, obj.object);
|
||||
if (!resp.success) {
|
||||
log.withFields({bucket: obj.bucket, key: obj.object, op : 'DELETE'}).error(resp.error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,8 @@ if (registry_enabled ) {
|
|||
const delete_vu_count = parseInt(__ENV.DELETERS || '0');
|
||||
if (delete_vu_count > 0) {
|
||||
if (!obj_to_delete_selector) {
|
||||
throw 'Positive DELETE worker number without a proper object selector';
|
||||
throw new Error(
|
||||
'Positive DELETE worker number without a proper object selector');
|
||||
}
|
||||
|
||||
scenarios.delete = {
|
||||
|
@ -210,8 +211,18 @@ export function obj_delete() {
|
|||
sleep(__ENV.SLEEP_DELETE);
|
||||
}
|
||||
|
||||
if (obj_to_delete_selector) {
|
||||
const obj = obj_to_delete_selector.nextObject();
|
||||
delete_object(obj)
|
||||
return
|
||||
}
|
||||
|
||||
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
|
||||
|
||||
const resp = s3_client.delete(obj.bucket, obj.object);
|
||||
if (!resp.success) {
|
||||
log.withFields({bucket: obj.bucket, key: obj.object, op : 'DELETE'}).error(resp.error);
|
||||
}
|
||||
}
|
||||
|
||||
export function delete_object(obj) {
|
||||
|
|
Loading…
Reference in a new issue