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

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,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)];
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.withFields({ cid: obj.container, oid: obj.object, op : 'DELETE' }).error(resp.error);
}
}

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,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);
}
}

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,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);
}
}

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,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);
}
}

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,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);
}
}

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