[8.16] Fixes Failing test: Jest Integration Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests - capacity based claiming should claim tasks to full capacity (#201681) (#210232)

# Backport

This will backport the following commits from `main` to `8.16`:
- [Fixes Failing test: Jest Integration
Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests
- capacity based claiming should claim tasks to full capacity
(#201681)](https://github.com/elastic/kibana/pull/201681)

<!--- Backport version: 9.6.4 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Ying
Mao","email":"ying.mao@elastic.co"},"sourceCommit":{"committedDate":"2025-02-05T21:20:38Z","message":"Fixes
Failing test: Jest Integration
Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests
- capacity based claiming should claim tasks to full capacity
(#201681)\n\nResolves
https://github.com/elastic/kibana/issues/205949,\r\nhttps://github.com/elastic/kibana/issues/191117\r\n\r\n##
Summary\r\n\r\nTrying to fix flaky integration test by performing a bulk
create for the\r\ntest tasks instead of creating one by one. After
making this change, was\r\nable to run the integration test ~100 times
without failure.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"7f28ae63e36d73ec471df7109909b1249f7edafd","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:Task
Manager","Team:ResponseOps","v9.0.0","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"Fixes
Failing test: Jest Integration
Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests
- capacity based claiming should claim tasks to full
capacity","number":201681,"url":"https://github.com/elastic/kibana/pull/201681","mergeCommit":{"message":"Fixes
Failing test: Jest Integration
Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests
- capacity based claiming should claim tasks to full capacity
(#201681)\n\nResolves
https://github.com/elastic/kibana/issues/205949,\r\nhttps://github.com/elastic/kibana/issues/191117\r\n\r\n##
Summary\r\n\r\nTrying to fix flaky integration test by performing a bulk
create for the\r\ntest tasks instead of creating one by one. After
making this change, was\r\nable to run the integration test ~100 times
without failure.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"7f28ae63e36d73ec471df7109909b1249f7edafd"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/209920","number":209920,"state":"MERGED","mergeCommit":{"sha":"90f844b2255f7463614f029c329b80cc741cf151","message":"[9.0]
Fixes Failing test: Jest Integration
Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests
- capacity based claiming should claim tasks to full capacity (#201681)
(#209920)\n\n# Backport\n\nThis will backport the following commits from
`main` to `9.0`:\n- [Fixes Failing test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)](https://github.com/elastic/kibana/pull/201681)\n\n<!---
Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Ying\nMao\",\"email\":\"ying.mao@elastic.co\"},\"sourceCommit\":{\"committedDate\":\"2025-02-05T21:20:38Z\",\"message\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)\\n\\nResolves\nhttps://github.com/elastic/kibana/issues/205949,\\r\\nhttps://github.com/elastic/kibana/issues/191117\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nTrying
to fix flaky integration test by performing a bulk\ncreate for
the\\r\\ntest tasks instead of creating one by one. After\nmaking this
change, was\\r\\nable to run the integration test ~100 times\nwithout
failure.\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by: Elastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"7f28ae63e36d73ec471df7109909b1249f7edafd\",\"branchLabelMapping\":{\"^v9.1.0$\":\"main\",\"^v8.19.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"release_note:skip\",\"Feature:Task\nManager\",\"Team:ResponseOps\",\"v9.0.0\",\"backport:version\",\"v8.18.0\",\"v9.1.0\",\"v8.19.0\"],\"title\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to
full\ncapacity\",\"number\":201681,\"url\":\"https://github.com/elastic/kibana/pull/201681\",\"mergeCommit\":{\"message\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)\\n\\nResolves\nhttps://github.com/elastic/kibana/issues/205949,\\r\\nhttps://github.com/elastic/kibana/issues/191117\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nTrying
to fix flaky integration test by performing a bulk\ncreate for
the\\r\\ntest tasks instead of creating one by one. After\nmaking this
change, was\\r\\nable to run the integration test ~100 times\nwithout
failure.\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by: Elastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"7f28ae63e36d73ec471df7109909b1249f7edafd\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"9.0\",\"8.18\",\"8.x\"],\"targetPullRequestStates\":[{\"branch\":\"9.0\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"},{\"branch\":\"8.18\",\"label\":\"v8.18.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"},{\"branch\":\"main\",\"label\":\"v9.1.0\",\"branchLabelMappingKey\":\"^v9.1.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/201681\",\"number\":201681,\"mergeCommit\":{\"message\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)\\n\\nResolves\nhttps://github.com/elastic/kibana/issues/205949,\\r\\nhttps://github.com/elastic/kibana/issues/191117\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nTrying
to fix flaky integration test by performing a bulk\ncreate for
the\\r\\ntest tasks instead of creating one by one. After\nmaking this
change, was\\r\\nable to run the integration test ~100 times\nwithout
failure.\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by: Elastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"7f28ae63e36d73ec471df7109909b1249f7edafd\"}},{\"branch\":\"8.x\",\"label\":\"v8.19.0\",\"branchLabelMappingKey\":\"^v8.19.0$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->\n\nCo-authored-by:
Ying Mao
<ying.mao@elastic.co>"}},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/209923","number":209923,"state":"MERGED","mergeCommit":{"sha":"afb1bd58a86cd7d43ec3dfcc7473f9b1a896ad4f","message":"[8.18]
Fixes Failing test: Jest Integration
Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests
- capacity based claiming should claim tasks to full capacity (#201681)
(#209923)\n\n# Backport\n\nThis will backport the following commits from
`main` to `8.18`:\n- [Fixes Failing test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)](https://github.com/elastic/kibana/pull/201681)\n\n<!---
Backport version: 9.6.4 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Ying\nMao\",\"email\":\"ying.mao@elastic.co\"},\"sourceCommit\":{\"committedDate\":\"2025-02-05T21:20:38Z\",\"message\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)\\n\\nResolves\nhttps://github.com/elastic/kibana/issues/205949,\\r\\nhttps://github.com/elastic/kibana/issues/191117\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nTrying
to fix flaky integration test by performing a bulk\ncreate for
the\\r\\ntest tasks instead of creating one by one. After\nmaking this
change, was\\r\\nable to run the integration test ~100 times\nwithout
failure.\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by: Elastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"7f28ae63e36d73ec471df7109909b1249f7edafd\",\"branchLabelMapping\":{\"^v9.1.0$\":\"main\",\"^v8.19.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"release_note:skip\",\"Feature:Task\nManager\",\"Team:ResponseOps\",\"v9.0.0\",\"backport:version\",\"v8.18.0\",\"v9.1.0\",\"v8.19.0\"],\"title\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to
full\ncapacity\",\"number\":201681,\"url\":\"https://github.com/elastic/kibana/pull/201681\",\"mergeCommit\":{\"message\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)\\n\\nResolves\nhttps://github.com/elastic/kibana/issues/205949,\\r\\nhttps://github.com/elastic/kibana/issues/191117\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nTrying
to fix flaky integration test by performing a bulk\ncreate for
the\\r\\ntest tasks instead of creating one by one. After\nmaking this
change, was\\r\\nable to run the integration test ~100 times\nwithout
failure.\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by: Elastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"7f28ae63e36d73ec471df7109909b1249f7edafd\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.18\",\"8.x\"],\"targetPullRequestStates\":[{\"branch\":\"9.0\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"url\":\"https://github.com/elastic/kibana/pull/209920\",\"number\":209920,\"state\":\"OPEN\"},{\"branch\":\"8.18\",\"label\":\"v8.18.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"},{\"branch\":\"main\",\"label\":\"v9.1.0\",\"branchLabelMappingKey\":\"^v9.1.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/201681\",\"number\":201681,\"mergeCommit\":{\"message\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)\\n\\nResolves\nhttps://github.com/elastic/kibana/issues/205949,\\r\\nhttps://github.com/elastic/kibana/issues/191117\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nTrying
to fix flaky integration test by performing a bulk\ncreate for
the\\r\\ntest tasks instead of creating one by one. After\nmaking this
change, was\\r\\nable to run the integration test ~100 times\nwithout
failure.\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by: Elastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"7f28ae63e36d73ec471df7109909b1249f7edafd\"}},{\"branch\":\"8.x\",\"label\":\"v8.19.0\",\"branchLabelMappingKey\":\"^v8.19.0$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->"}},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201681","number":201681,"mergeCommit":{"message":"Fixes
Failing test: Jest Integration
Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests
- capacity based claiming should claim tasks to full capacity
(#201681)\n\nResolves
https://github.com/elastic/kibana/issues/205949,\r\nhttps://github.com/elastic/kibana/issues/191117\r\n\r\n##
Summary\r\n\r\nTrying to fix flaky integration test by performing a bulk
create for the\r\ntest tasks instead of creating one by one. After
making this change, was\r\nable to run the integration test ~100 times
without failure.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"7f28ae63e36d73ec471df7109909b1249f7edafd"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/209922","number":209922,"state":"MERGED","mergeCommit":{"sha":"e8c26120d3d58beec3a233f6ee92556d96b20835","message":"[8.x]
Fixes Failing test: Jest Integration
Tests.x-pack/platform/plugins/shared/task_manager/server/integration_tests
- capacity based claiming should claim tasks to full capacity (#201681)
(#209922)\n\n# Backport\n\nThis will backport the following commits from
`main` to `8.x`:\n- [Fixes Failing test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)](https://github.com/elastic/kibana/pull/201681)\n\n<!---
Backport version: 9.6.4 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Ying\nMao\",\"email\":\"ying.mao@elastic.co\"},\"sourceCommit\":{\"committedDate\":\"2025-02-05T21:20:38Z\",\"message\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)\\n\\nResolves\nhttps://github.com/elastic/kibana/issues/205949,\\r\\nhttps://github.com/elastic/kibana/issues/191117\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nTrying
to fix flaky integration test by performing a bulk\ncreate for
the\\r\\ntest tasks instead of creating one by one. After\nmaking this
change, was\\r\\nable to run the integration test ~100 times\nwithout
failure.\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by: Elastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"7f28ae63e36d73ec471df7109909b1249f7edafd\",\"branchLabelMapping\":{\"^v9.1.0$\":\"main\",\"^v8.19.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"release_note:skip\",\"Feature:Task\nManager\",\"Team:ResponseOps\",\"v9.0.0\",\"backport:version\",\"v8.18.0\",\"v9.1.0\",\"v8.19.0\"],\"title\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to
full\ncapacity\",\"number\":201681,\"url\":\"https://github.com/elastic/kibana/pull/201681\",\"mergeCommit\":{\"message\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)\\n\\nResolves\nhttps://github.com/elastic/kibana/issues/205949,\\r\\nhttps://github.com/elastic/kibana/issues/191117\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nTrying
to fix flaky integration test by performing a bulk\ncreate for
the\\r\\ntest tasks instead of creating one by one. After\nmaking this
change, was\\r\\nable to run the integration test ~100 times\nwithout
failure.\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by: Elastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"7f28ae63e36d73ec471df7109909b1249f7edafd\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.18\",\"8.x\"],\"targetPullRequestStates\":[{\"branch\":\"9.0\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"url\":\"https://github.com/elastic/kibana/pull/209920\",\"number\":209920,\"state\":\"OPEN\"},{\"branch\":\"8.18\",\"label\":\"v8.18.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"},{\"branch\":\"main\",\"label\":\"v9.1.0\",\"branchLabelMappingKey\":\"^v9.1.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/201681\",\"number\":201681,\"mergeCommit\":{\"message\":\"Fixes\nFailing
test: Jest
Integration\nTests.x-pack/platform/plugins/shared/task_manager/server/integration_tests\n-
capacity based claiming should claim tasks to full
capacity\n(#201681)\\n\\nResolves\nhttps://github.com/elastic/kibana/issues/205949,\\r\\nhttps://github.com/elastic/kibana/issues/191117\\r\\n\\r\\n##\nSummary\\r\\n\\r\\nTrying
to fix flaky integration test by performing a bulk\ncreate for
the\\r\\ntest tasks instead of creating one by one. After\nmaking this
change, was\\r\\nable to run the integration test ~100 times\nwithout
failure.\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by: Elastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"7f28ae63e36d73ec471df7109909b1249f7edafd\"}},{\"branch\":\"8.x\",\"label\":\"v8.19.0\",\"branchLabelMappingKey\":\"^v8.19.0$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->"}}]}]
BACKPORT-->
This commit is contained in:
Ying Mao 2025-02-07 14:25:43 -05:00 committed by GitHub
parent f8365865c0
commit 5264ffad87
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 7 deletions

View file

@ -5,6 +5,6 @@
* 2.0.
*/
export { injectTask } from './inject_task';
export { injectTask, injectTaskBulk } from './inject_task';
export { setupTestServers } from './setup_test_servers';
export { retry } from './retry';

View file

@ -33,3 +33,27 @@ export async function injectTask(
},
});
}
export async function injectTaskBulk(esClient: ElasticsearchClient, tasks: ConcreteTaskInstance[]) {
const bulkRequest = [];
for (const task of tasks) {
bulkRequest.push({ create: { _id: `task:${task.id}` } });
bulkRequest.push({
references: [],
type: 'task',
updated_at: new Date().toISOString(),
task: {
...task,
state: JSON.stringify(task.state),
params: JSON.stringify(task.params),
runAt: task.runAt.toISOString(),
scheduledAt: task.scheduledAt.toISOString(),
partition: murmurhash.v3(task.id) % MAX_PARTITIONS,
},
});
}
await esClient.bulk({
index: '.kibana_task_manager',
body: bulkRequest,
});
}

View file

@ -12,7 +12,7 @@ import { times } from 'lodash';
import { TaskCost, TaskStatus } from '../task';
import type { TaskClaimingOpts } from '../queries/task_claiming';
import { TaskManagerPlugin, type TaskManagerStartContract } from '../plugin';
import { injectTask, setupTestServers, retry } from './lib';
import { injectTaskBulk, setupTestServers, retry } from './lib';
import { CreateMonitoringStatsOpts } from '../monitoring';
import { filter, map } from 'rxjs';
import { isTaskManagerWorkerUtilizationStatEvent } from '../task_events';
@ -169,9 +169,10 @@ describe('capacity based claiming', () => {
times(10, () => ids.push(uuidV4()));
const now = new Date();
const runAt = new Date(now.valueOf() + 5000);
const runAt = new Date(now.valueOf() + 6000);
const tasks = [];
for (const id of ids) {
await injectTask(kibanaServer.coreStart.elasticsearch.client.asInternalUser, {
tasks.push({
id,
taskType: '_normalCostType',
params: {},
@ -189,6 +190,8 @@ describe('capacity based claiming', () => {
taskIdsToRemove.push(id);
}
await injectTaskBulk(kibanaServer.coreStart.elasticsearch.client.asInternalUser, tasks);
await retry(async () => {
expect(mockTaskTypeNormalCostRunFn).toHaveBeenCalledTimes(10);
});
@ -234,8 +237,9 @@ describe('capacity based claiming', () => {
const ids: string[] = [];
times(6, () => ids.push(uuidV4()));
const runAt1 = new Date(now.valueOf() - 5);
const tasks = [];
for (const id of ids) {
await injectTask(kibanaServer.coreStart.elasticsearch.client.asInternalUser, {
tasks.push({
id,
taskType: '_normalCostType',
params: {},
@ -256,7 +260,7 @@ describe('capacity based claiming', () => {
// inject 1 XL cost task that will put us over the max cost capacity of 20
const xlid = uuidV4();
const runAt2 = now;
await injectTask(kibanaServer.coreStart.elasticsearch.client.asInternalUser, {
tasks.push({
id: xlid,
taskType: '_xlCostType',
params: {},
@ -276,7 +280,7 @@ describe('capacity based claiming', () => {
// inject one more normal cost task
const runAt3 = new Date(now.valueOf() + 5);
const lastid = uuidV4();
await injectTask(kibanaServer.coreStart.elasticsearch.client.asInternalUser, {
tasks.push({
id: lastid,
taskType: '_normalCostType',
params: {},
@ -293,6 +297,8 @@ describe('capacity based claiming', () => {
});
taskIdsToRemove.push(lastid);
await injectTaskBulk(kibanaServer.coreStart.elasticsearch.client.asInternalUser, tasks);
// retry until all tasks have been run
await retry(async () => {
expect(mockTaskTypeNormalCostRunFn).toHaveBeenCalledTimes(7);