Delete data created in preset #157

Closed
elebedeva wants to merge 1 commit from elebedeva/xk6-frostfs:fix/delet-preset-data into master
6 changed files with 118 additions and 60 deletions
Showing only changes of commit 4ec75a1c89 - Show all commits

View file

@ -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,20 +203,27 @@ export function obj_delete() {
sleep(__ENV.SLEEP_DELETE);
}
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
if (obj_to_delete_exit_on_null) {
exec.test.abort("No more objects to select");
if (obj_to_delete_selector) {
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
if (obj_to_delete_exit_on_null) {
exec.test.abort("No more objects to select");
}
return;
}
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, op : 'DELETE' }).error(resp.error);
return;
}
obj_registry.deleteObject(obj.id);
return
}
const resp = grpc_client.delete(obj.c_id, obj.o_id);
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
Review

It makes sense for read, because we can read each object multiple times.
But we cannot delete it multiple times (probably can, but the result would be meaningless).

It makes sense for read, because we can read each object multiple times. But we cannot delete it multiple times (probably can, but the result would be meaningless).
const resp = grpc_client.delete(obj.container, obj.object)
if (!resp.success) {
// Log errors except (2052 - object already deleted)
log.withFields({ cid: obj.c_id, oid: obj.o_id }).error(resp.error);
return;
log.withFields({ cid: obj.container, oid: obj.object, op : 'DELETE' }).error(resp.error);
}
obj_registry.deleteObject(obj.id);
}

View file

@ -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,17 +222,26 @@ export function obj_delete() {
sleep(__ENV.SLEEP_DELETE);
}
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
return;
if (obj_to_delete_selector) {
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
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, op : 'DELETE' }).error(resp.error);
return;
}
obj_registry.deleteObject(obj.id);
return
}
const resp = grpc_client.delete(obj.c_id, obj.o_id);
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
const resp = grpc_client.delete(obj.container, obj.object)
if (!resp.success) {
// Log errors except (2052 - object already deleted)
log.withFields({ cid: obj.c_id, oid: obj.o_id }).error(resp.error);
return;
log.withFields({ cid: obj.container, oid: obj.object, op : 'DELETE' }).error(resp.error);
}
obj_registry.deleteObject(obj.id);
}

View file

@ -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,17 +161,27 @@ export function obj_read() {
}
export function obj_delete() {
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
return;
if (obj_to_delete_selector) {
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
return;
}
const resp = local_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);
return;
}
obj_registry.deleteObject(obj.id);
return
}
const resp = local_client.delete(obj.c_id, obj.o_id);
const obj = obj_list[Math.floor(Math.random() * obj_list.length)];
const resp = grpc_client.delete(obj.container, obj.object)
if (!resp.success) {
// Log errors except (2052 - object already deleted)
log.withFields({cid: obj.c_id, oid: obj.o_id}).error(resp.error);
return;
log.withFields({cid : obj.container, oid : obj.object, op : 'DELETE'})
.error(resp.error);
}
obj_registry.deleteObject(obj.id);
}

View file

@ -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,20 +202,30 @@ export function obj_delete() {
sleep(__ENV.SLEEP_DELETE);
}
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
if (obj_to_delete_exit_on_null) {
exec.test.abort("No more objects to select");
if (obj_to_delete_selector) {
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
if (obj_to_delete_exit_on_null) {
exec.test.abort("No more objects to select");
}
return;
}
return;
const resp = s3_client.delete(obj.s3_bucket, obj.s3_key);
if (!resp.success) {
log.withFields({bucket : obj.s3_bucket, key : obj.s3_key, op : 'DELETE'})
.error(resp.error);
return;
}
obj_registry.deleteObject(obj.id);
return
}
const resp = s3_client.delete(obj.s3_bucket, obj.s3_key);
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.s3_bucket, key : obj.s3_key, op : 'DELETE'})
.error(resp.error);
return;
log.withFields({bucket : obj.bucket, key : obj.object, op : 'DELETE'}).error(resp.error);
}
obj_registry.deleteObject(obj.id);
}

View file

@ -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,17 +223,27 @@ export function obj_delete() {
sleep(__ENV.SLEEP_DELETE);
}
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
return;
if (obj_to_delete_selector) {
const obj = obj_to_delete_selector.nextObject();
if (!obj) {
return;
}
const resp = s3_client.delete(obj.s3_bucket, obj.s3_key);
if (!resp.success) {
log.withFields({bucket: obj.s3_bucket, key: obj.s3_key, op: 'DELETE'})
.error(resp.error);
return;
}
obj_registry.deleteObject(obj.id);
return
}
const resp = s3_client.delete(obj.s3_bucket, obj.s3_key);
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.s3_bucket, key: obj.s3_key, op: 'DELETE'})
.error(resp.error);
return;
log.withFields({bucket: obj.bucket, key: obj.object, op : 'DELETE'}).error(resp.error);
}
obj_registry.deleteObject(obj.id);
}

View file

@ -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) {