Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
[SIEM][Detection Engine][Lists] Adds "wait_for" to all the create, up…
Browse files Browse the repository at this point in the history
…date, patch, delete endpoints (elastic#71290)

## Summary

* Adds "wait_for" to all the create, update, patch, and delete endpoints
* Ran some quick tests against import and the performance still looks acceptable
* Updates the unit tests to reflect the addition

### Checklist

- [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
  • Loading branch information
FrankHassanabad authored Jul 9, 2020
1 parent 95234bc commit c723eff
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('crete_list_item', () => {
body,
id: LIST_ITEM_ID,
index: LIST_ITEM_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('index', expected);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const createListItem = async ({
body,
id,
index: listItemIndex,
refresh: 'wait_for',
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('crete_list_item_bulk', () => {
secondRecord,
],
index: LIST_ITEM_INDEX,
refresh: 'wait_for',
});
});

Expand Down Expand Up @@ -70,6 +71,7 @@ describe('crete_list_item_bulk', () => {
},
],
index: '.items',
refresh: 'wait_for',
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const createListItemsBulk = async ({
await callCluster('bulk', {
body,
index: listItemIndex,
refresh: 'wait_for',
});
} catch (error) {
// TODO: Log out the error with return values from the bulk insert into another index or saved object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('delete_list_item', () => {
const deleteQuery = {
id: LIST_ITEM_ID,
index: LIST_ITEM_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('delete', deleteQuery);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const deleteListItem = async ({
await callCluster('delete', {
id,
index: listItemIndex,
refresh: 'wait_for',
});
}
return listItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('delete_list_item_by_value', () => {
},
},
index: '.items',
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('deleteByQuery', deleteByQuery);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const deleteListItemByValue = async ({
},
},
index: listItemIndex,
refresh: 'wait_for',
});
return listItems;
};
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const updateListItem = async ({
},
id: listItem.id,
index: listItemIndex,
refresh: 'wait_for',
});
return {
created_at: listItem.created_at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('crete_list', () => {
body,
id: LIST_ID,
index: LIST_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('index', expected);
});
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lists/server/services/lists/create_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const createList = async ({
body,
id,
index: listIndex,
refresh: 'wait_for',
});
return {
id: response._id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('delete_list', () => {
const deleteByQuery = {
body: { query: { term: { list_id: LIST_ID } } },
index: LIST_ITEM_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toBeCalledWith('deleteByQuery', deleteByQuery);
});
Expand All @@ -59,6 +60,7 @@ describe('delete_list', () => {
const deleteQuery = {
id: LIST_ID,
index: LIST_INDEX,
refresh: 'wait_for',
};
expect(options.callCluster).toHaveBeenNthCalledWith(2, 'delete', deleteQuery);
});
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/lists/server/services/lists/delete_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ export const deleteList = async ({
},
},
index: listItemIndex,
refresh: 'wait_for',
});

await callCluster('delete', {
id,
index: listIndex,
refresh: 'wait_for',
});
return list;
}
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lists/server/services/lists/update_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const updateList = async ({
body: { doc },
id,
index: listIndex,
refresh: 'wait_for',
});
return {
created_at: list.created_at,
Expand Down

0 comments on commit c723eff

Please sign in to comment.