Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alerting] Change execution of alerts from async to sync #97311

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
71e752d
added ability to run ephemeral tasks
gmmorris Apr 11, 2021
6cf4263
fixed typing
gmmorris Apr 11, 2021
5a72036
added typing on plugin
gmmorris Apr 12, 2021
12f3923
WIP
chrisronline Apr 12, 2021
f2692ef
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Apr 15, 2021
fdc81c4
Fix type issues
chrisronline Apr 15, 2021
3541692
Hook up the ephemeral task into the task runner for actions
chrisronline Apr 15, 2021
11d0b9a
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Apr 20, 2021
0522e1e
Tasks can now run independently of one another
chrisronline Apr 21, 2021
9fdd327
Use deferred language
chrisronline Apr 22, 2021
80e11df
Refactor taskParams slightly
chrisronline Apr 22, 2021
4ade4d3
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Apr 23, 2021
068a4a5
Use Promise.all
chrisronline Apr 24, 2021
9909617
Remove deferred logic
chrisronline Apr 24, 2021
1785f5d
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Apr 26, 2021
3800f5c
Add config options to limit the amount of tasks executing at once
chrisronline Apr 27, 2021
9bb7ed2
Add ephemeral task monitoring
chrisronline Apr 28, 2021
ee10e6b
WIP
chrisronline Apr 30, 2021
539314a
Add single test so far
chrisronline Apr 30, 2021
92443cc
Ensure we log after actions have executed
chrisronline May 3, 2021
00c2e88
Remove confusing * 1
chrisronline May 3, 2021
b93e6fc
Add logic to ensure we fallback to default enqueueing if the total ac…
chrisronline May 3, 2021
989b927
Add additional test
chrisronline May 3, 2021
2fb8d31
Fix tests a bit, ensure we log the alerting:actions-execute right awa…
chrisronline May 4, 2021
217567c
Better tests
chrisronline May 6, 2021
eaeef7c
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline May 6, 2021
e3576a2
If the queue is at capacity, attempt to execute the ephemeral task as…
chrisronline May 7, 2021
052bfb6
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline May 10, 2021
b4fa75a
Ensure we run ephemeral tasks before to avoid them getting stuck in t…
chrisronline May 10, 2021
79397aa
Do not handle the promise anymore
chrisronline May 11, 2021
d409567
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline May 13, 2021
4132353
Remove unnecessary code
chrisronline May 13, 2021
5abd26b
Properly handle errors from ephemeral task lifecycle
chrisronline May 13, 2021
44babf8
Merge branch 'master' into pr/97311
gmmorris May 14, 2021
c78782f
moved acitons domain out of alerting and into actions plugin
gmmorris May 14, 2021
5719b88
Remove some tests
chrisronline May 18, 2021
bd18226
Fix TS and test issues
chrisronline May 20, 2021
2df4910
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline May 20, 2021
289946d
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline May 21, 2021
552972b
Fix type issues
chrisronline May 21, 2021
ee6db03
Fix more type issues
chrisronline May 21, 2021
2c24c84
Fix more type issues
chrisronline May 21, 2021
e73f5c3
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline May 24, 2021
17a0c76
Fix jest tests
chrisronline May 24, 2021
2828a45
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline May 24, 2021
ac1b151
Fix more jest tests
chrisronline May 24, 2021
5871b68
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline May 25, 2021
12bf330
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 1, 2021
1b33fc4
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 2, 2021
675b27b
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 4, 2021
cf5aefa
Off by default
chrisronline Jun 7, 2021
b7c93c0
Merge in master
chrisronline Jun 8, 2021
d64452b
Fix jest tests
chrisronline Jun 8, 2021
eb26717
Update config for this suite too
chrisronline Jun 8, 2021
6f1f7c1
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 9, 2021
0427224
Start of telemetry code
chrisronline Jun 9, 2021
1cee9e6
Fix types and add missing files
chrisronline Jun 9, 2021
ac15e26
Fix telemetry schema
chrisronline Jun 9, 2021
596c94f
Fix types
chrisronline Jun 9, 2021
c09f688
Fix more types
chrisronline Jun 9, 2021
aa6c53e
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 14, 2021
c27e148
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 14, 2021
3e7e2f5
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 14, 2021
8947562
Merge branch 'master' into alerting/ephemeral_action_execution
kibanamachine Jun 14, 2021
063d894
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 15, 2021
a1d1ed4
moved load event emission to pollingcycle and added health stats on E…
gmmorris Jun 17, 2021
9c8b1dd
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 17, 2021
088d75a
Add more telemetry data based on new health metrics for the ephemeral…
chrisronline Jun 17, 2021
9b6b27d
Fix tests and types
chrisronline Jun 17, 2021
71f7eaa
Add separate request capacity for ephemeral queue
chrisronline Jun 17, 2021
3ec65c7
Fix telemetry schema and add tests for usage collection
chrisronline Jun 17, 2021
3f2a172
track polled tasks by persistence and use in capacity estimation inst…
gmmorris Jun 17, 2021
bfe46b7
fixed typing
gmmorris Jun 17, 2021
e2fed05
Bump default capacity
chrisronline Jun 17, 2021
90625b5
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 18, 2021
da04a6d
added delay metric to ephemeral stats
gmmorris Jun 18, 2021
7dda0d6
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 18, 2021
995a8f6
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 21, 2021
d71e417
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 21, 2021
bca2270
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jun 23, 2021
3992f09
Fix bad merge
chrisronline Jun 23, 2021
4ba152f
Fix tests
chrisronline Jun 23, 2021
8bf1508
Fix tests
chrisronline Jun 23, 2021
44c57b3
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 1, 2021
8f34926
Fix types
chrisronline Jul 1, 2021
2b2dc8b
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 6, 2021
409ac4b
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 9, 2021
3becd24
Skip failing tests
chrisronline Jul 12, 2021
a61b070
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 12, 2021
2d3d392
Exclude ephemeral stats from capacity estimation tests
chrisronline Jul 13, 2021
5b487c5
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 14, 2021
3890639
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 15, 2021
339c95a
PR feedback
chrisronline Jul 15, 2021
1fad6f4
More PR feedback
chrisronline Jul 15, 2021
451957a
PR feedback
chrisronline Jul 16, 2021
d9261c7
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 16, 2021
90e0154
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 16, 2021
4edb827
Fix merge conflict
chrisronline Jul 16, 2021
f3e5577
Try fixing CI
chrisronline Jul 16, 2021
7a78848
Fix broken lock file from merge
chrisronline Jul 19, 2021
1a794f8
Match master
chrisronline Jul 19, 2021
f9dfc66
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 19, 2021
9f1c2d4
Add this back
chrisronline Jul 19, 2021
d27deee
PR feedback
chrisronline Jul 19, 2021
af7c6e2
Change to queue and add test
chrisronline Jul 19, 2021
018cfda
Disable ephemeral queue in tests
chrisronline Jul 19, 2021
399eb2d
Updated desc
chrisronline Jul 19, 2021
b7ea9d9
Comment out ephemeral-specific tests tha require the entire test suit…
chrisronline Jul 19, 2021
74c2482
Merge remote-tracking branch 'elastic/master' into alerting/ephemeral…
chrisronline Jul 20, 2021
5c45af9
Add clarifying comment
chrisronline Jul 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/settings/alert-action-settings.asciidoc
Expand Up @@ -207,4 +207,10 @@ Use `full` to perform hostname verification, `certificate` to skip hostname veri
[[alert-settings]]
==== Alerting settings

You do not need to configure any additional settings to use alerting in {kib}.
[cols="2*<"]
|===

| `xpack.alerting.maxEphemeralActionsPerAlert`
| Sets the number of actions that will be executed ephemerally. To use this, enable ephemeral tasks in task manager first with <<task-manager-settings,`xpack.task_manager.ephemeral_tasks.enabled`>>

|===
8 changes: 8 additions & 0 deletions docs/settings/task-manager-settings.asciidoc
Expand Up @@ -37,6 +37,14 @@ Task Manager runs background tasks by polling for work on an interval. You can
`monitored_stats_health_verbose_log.`
`warn_delayed_task_start_in_seconds`
| The amount of seconds we allow a task to delay before printing a warning server log. Defaults to 60.

| `xpack.task_manager.ephemeral_tasks.enabled`
| Enables an experimental feature that executes a limited (and configurable) number of actions in the same task as the alert which triggered them.
These action tasks will reduce the latency of the time it takes an action to run after it's triggered, but are not persisted as SavedObjects.
These non-persisted action tasks have a risk that they won't be run at all if the Kibana instance running them exits unexpectedly. Defaults to false.

| `xpack.task_manager.ephemeral_tasks.request_capacity`
| Sets the size of the ephemeral queue defined above. Defaults to 10.
|===

[float]
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/actions/server/actions_client.mock.ts
Expand Up @@ -21,6 +21,7 @@ const createActionsClientMock = () => {
getBulk: jest.fn(),
execute: jest.fn(),
enqueueExecution: jest.fn(),
ephemeralEnqueuedExecution: jest.fn(),
listTypes: jest.fn(),
isActionTypeEnabled: jest.fn(),
};
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/actions/server/actions_client.test.ts
Expand Up @@ -44,6 +44,7 @@ const scopedClusterClient = elasticsearchServiceMock.createScopedClusterClient()
const actionExecutor = actionExecutorMock.create();
const authorization = actionsAuthorizationMock.create();
const executionEnqueuer = jest.fn();
const ephemeralExecutionEnqueuer = jest.fn();
const request = httpServerMock.createKibanaRequest();
const auditLogger = auditServiceMock.create().asScoped(request);

Expand Down Expand Up @@ -77,6 +78,7 @@ beforeEach(() => {
preconfiguredActions: [],
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization: (authorization as unknown) as ActionsAuthorization,
auditLogger,
Expand Down Expand Up @@ -453,6 +455,7 @@ describe('create()', () => {
preconfiguredActions: [],
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization: (authorization as unknown) as ActionsAuthorization,
});
Expand Down Expand Up @@ -553,6 +556,7 @@ describe('get()', () => {
defaultKibanaIndex,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization: (authorization as unknown) as ActionsAuthorization,
preconfiguredActions: [
Expand Down Expand Up @@ -608,6 +612,7 @@ describe('get()', () => {
defaultKibanaIndex,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization: (authorization as unknown) as ActionsAuthorization,
preconfiguredActions: [
Expand Down Expand Up @@ -724,6 +729,7 @@ describe('get()', () => {
defaultKibanaIndex,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization: (authorization as unknown) as ActionsAuthorization,
preconfiguredActions: [
Expand Down Expand Up @@ -793,6 +799,7 @@ describe('getAll()', () => {
defaultKibanaIndex,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization: (authorization as unknown) as ActionsAuthorization,
preconfiguredActions: [
Expand Down Expand Up @@ -930,6 +937,7 @@ describe('getAll()', () => {
defaultKibanaIndex,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization: (authorization as unknown) as ActionsAuthorization,
preconfiguredActions: [
Expand Down Expand Up @@ -1005,6 +1013,7 @@ describe('getBulk()', () => {
defaultKibanaIndex,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization: (authorization as unknown) as ActionsAuthorization,
preconfiguredActions: [
Expand Down Expand Up @@ -1136,6 +1145,7 @@ describe('getBulk()', () => {
defaultKibanaIndex,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization: (authorization as unknown) as ActionsAuthorization,
preconfiguredActions: [
Expand Down
20 changes: 18 additions & 2 deletions x-pack/plugins/actions/server/actions_client.ts
Expand Up @@ -41,6 +41,7 @@ import {
AuthorizationMode,
} from './authorization/get_authorization_mode_by_source';
import { connectorAuditEvent, ConnectorAuditAction } from './lib/audit_events';
import { RunNowResult } from '../../task_manager/server';

// We are assuming there won't be many actions. This is why we will load
// all the actions in advance and assume the total count to not go over 10000.
Expand Down Expand Up @@ -68,7 +69,8 @@ interface ConstructorOptions {
unsecuredSavedObjectsClient: SavedObjectsClientContract;
preconfiguredActions: PreConfiguredAction[];
actionExecutor: ActionExecutorContract;
executionEnqueuer: ExecutionEnqueuer;
executionEnqueuer: ExecutionEnqueuer<void>;
ephemeralExecutionEnqueuer: ExecutionEnqueuer<RunNowResult>;
request: KibanaRequest;
authorization: ActionsAuthorization;
auditLogger?: AuditLogger;
Expand All @@ -88,7 +90,8 @@ export class ActionsClient {
private readonly actionExecutor: ActionExecutorContract;
private readonly request: KibanaRequest;
private readonly authorization: ActionsAuthorization;
private readonly executionEnqueuer: ExecutionEnqueuer;
private readonly executionEnqueuer: ExecutionEnqueuer<void>;
private readonly ephemeralExecutionEnqueuer: ExecutionEnqueuer<RunNowResult>;
private readonly auditLogger?: AuditLogger;

constructor({
Expand All @@ -99,6 +102,7 @@ export class ActionsClient {
preconfiguredActions,
actionExecutor,
executionEnqueuer,
ephemeralExecutionEnqueuer,
request,
authorization,
auditLogger,
Expand All @@ -110,6 +114,7 @@ export class ActionsClient {
this.preconfiguredActions = preconfiguredActions;
this.actionExecutor = actionExecutor;
this.executionEnqueuer = executionEnqueuer;
this.ephemeralExecutionEnqueuer = ephemeralExecutionEnqueuer;
this.request = request;
this.authorization = authorization;
this.auditLogger = auditLogger;
Expand Down Expand Up @@ -497,6 +502,17 @@ export class ActionsClient {
return this.executionEnqueuer(this.unsecuredSavedObjectsClient, options);
}

public async ephemeralEnqueuedExecution(options: EnqueueExecutionOptions): Promise<RunNowResult> {
const { source } = options;
if (
(await getAuthorizationModeBySource(this.unsecuredSavedObjectsClient, source)) ===
AuthorizationMode.RBAC
) {
await this.authorization.ensureAuthorized('execute');
}
return this.ephemeralExecutionEnqueuer(this.unsecuredSavedObjectsClient, options);
}

public async listTypes(): Promise<ActionType[]> {
return this.actionTypeRegistry.list();
}
Expand Down
78 changes: 61 additions & 17 deletions x-pack/plugins/actions/server/create_execute_function.ts
Expand Up @@ -6,8 +6,13 @@
*/

import { SavedObjectsClientContract } from '../../../../src/core/server';
import { TaskManagerStartContract } from '../../task_manager/server';
import { RawAction, ActionTypeRegistryContract, PreConfiguredAction } from './types';
import { RunNowResult, TaskManagerStartContract } from '../../task_manager/server';
import {
RawAction,
ActionTypeRegistryContract,
PreConfiguredAction,
ActionTaskExecutorParams,
} from './types';
import { ACTION_TASK_PARAMS_SAVED_OBJECT_TYPE } from './constants/saved_objects';
import { ExecuteOptions as ActionExecutorOptions } from './lib/action_executor';
import { isSavedObjectExecutionSource } from './lib';
Expand All @@ -27,17 +32,17 @@ export interface ExecuteOptions extends Pick<ActionExecutorOptions, 'params' | '
relatedSavedObjects?: RelatedSavedObjects;
}

export type ExecutionEnqueuer = (
export type ExecutionEnqueuer<T> = (
unsecuredSavedObjectsClient: SavedObjectsClientContract,
options: ExecuteOptions
) => Promise<void>;
) => Promise<T>;

export function createExecutionEnqueuerFunction({
taskManager,
actionTypeRegistry,
isESOCanEncrypt,
preconfiguredActions,
}: CreateExecuteFunctionOptions) {
}: CreateExecuteFunctionOptions): ExecutionEnqueuer<void> {
return async function execute(
unsecuredSavedObjectsClient: SavedObjectsClientContract,
{ id, params, spaceId, source, apiKey, relatedSavedObjects }: ExecuteOptions
Expand All @@ -48,18 +53,10 @@ export function createExecutionEnqueuerFunction({
);
}

const { actionTypeId, name, isMissingSecrets } = await getAction(
unsecuredSavedObjectsClient,
preconfiguredActions,
id
);

if (isMissingSecrets) {
throw new Error(
`Unable to execute action because no secrets are defined for the "${name}" connector.`
);
}
const action = await getAction(unsecuredSavedObjectsClient, preconfiguredActions, id);
validateCanActionBeUsed(action);

const { actionTypeId } = action;
if (!actionTypeRegistry.isActionExecutable(id, actionTypeId, { notifyUsage: true })) {
actionTypeRegistry.ensureActionTypeEnabled(actionTypeId);
}
Expand All @@ -76,7 +73,7 @@ export function createExecutionEnqueuerFunction({
);

await taskManager.schedule({
taskType: `actions:${actionTypeId}`,
taskType: `actions:${action.actionTypeId}`,
params: {
spaceId,
actionTaskParamsId: actionTaskParamsRecord.id,
Expand All @@ -87,6 +84,53 @@ export function createExecutionEnqueuerFunction({
};
}

export function createEphemeralExecutionEnqueuerFunction({
taskManager,
actionTypeRegistry,
preconfiguredActions,
}: CreateExecuteFunctionOptions): ExecutionEnqueuer<RunNowResult> {
return async function execute(
unsecuredSavedObjectsClient: SavedObjectsClientContract,
{ id, params, spaceId, source, apiKey }: ExecuteOptions
): Promise<RunNowResult> {
ymao1 marked this conversation as resolved.
Show resolved Hide resolved
const action = await getAction(unsecuredSavedObjectsClient, preconfiguredActions, id);
validateCanActionBeUsed(action);

chrisronline marked this conversation as resolved.
Show resolved Hide resolved
const { actionTypeId } = action;
if (!actionTypeRegistry.isActionExecutable(id, actionTypeId, { notifyUsage: true })) {
actionTypeRegistry.ensureActionTypeEnabled(actionTypeId);
}

const taskParams: ActionTaskExecutorParams = {
spaceId,
taskParams: {
actionId: id,
// Saved Objects won't allow us to enforce unknown rather than any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
params: params as Record<string, any>,
...(apiKey ? { apiKey } : {}),
},
...executionSourceAsSavedObjectReferences(source),
};

return taskManager.ephemeralRunNow({
taskType: `actions:${action.actionTypeId}`,
params: taskParams,
state: {},
scope: ['actions'],
});
};
}

function validateCanActionBeUsed(action: PreConfiguredAction | RawAction) {
const { name, isMissingSecrets } = action;
if (isMissingSecrets) {
throw new Error(
`Unable to execute action because no secrets are defined for the "${name}" connector.`
);
}
}

function executionSourceAsSavedObjectReferences(executionSource: ActionExecutorOptions['source']) {
return isSavedObjectExecutionSource(executionSource)
? {
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/actions/server/lib/action_executor.ts
Expand Up @@ -48,6 +48,7 @@ export interface TaskInfo {

export interface ExecuteOptions<Source = unknown> {
actionId: string;
isEphemeral?: boolean;
request: KibanaRequest;
params: Record<string, unknown>;
source?: ActionExecutionSource<Source>;
Expand Down Expand Up @@ -79,6 +80,7 @@ export class ActionExecutor {
params,
request,
source,
isEphemeral,
taskInfo,
relatedSavedObjects,
}: ExecuteOptions): Promise<ActionTypeExecutorResult<unknown>> {
Expand Down Expand Up @@ -207,6 +209,7 @@ export class ActionExecutor {
params: validatedParams,
config: validatedConfig,
secrets: validatedSecrets,
isEphemeral,
});
} catch (err) {
rawResult = {
Expand Down
Expand Up @@ -125,6 +125,7 @@ test('executes the task by calling the executor with proper parameters', async (

expect(mockedActionExecutor.execute).toHaveBeenCalledWith({
actionId: '2',
isEphemeral: false,
params: { baz: true },
relatedSavedObjects: [],
request: expect.objectContaining({
Expand Down Expand Up @@ -250,6 +251,7 @@ test('uses API key when provided', async () => {

expect(mockedActionExecutor.execute).toHaveBeenCalledWith({
actionId: '2',
isEphemeral: false,
params: { baz: true },
relatedSavedObjects: [],
request: expect.objectContaining({
Expand Down Expand Up @@ -293,6 +295,7 @@ test('uses relatedSavedObjects when provided', async () => {

expect(mockedActionExecutor.execute).toHaveBeenCalledWith({
actionId: '2',
isEphemeral: false,
params: { baz: true },
relatedSavedObjects: [
{
Expand Down Expand Up @@ -334,14 +337,15 @@ test('sanitizes invalid relatedSavedObjects when provided', async () => {
await taskRunner.run();
expect(mockedActionExecutor.execute).toHaveBeenCalledWith({
actionId: '2',
isEphemeral: false,
params: { baz: true },
relatedSavedObjects: [],
request: expect.objectContaining({
headers: {
// base64 encoded "123:abc"
authorization: 'ApiKey MTIzOmFiYw==',
},
}),
relatedSavedObjects: [],
taskInfo: {
scheduled: new Date(),
},
Expand Down Expand Up @@ -369,6 +373,7 @@ test(`doesn't use API key when not provided`, async () => {

expect(mockedActionExecutor.execute).toHaveBeenCalledWith({
actionId: '2',
isEphemeral: false,
params: { baz: true },
relatedSavedObjects: [],
request: expect.objectContaining({
Expand Down