Skip to content

Commit

Permalink
Merge branch 'master' into support/mac-arm
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Oct 19, 2021
2 parents 3a476f4 + f2ef8b3 commit ac35e2e
Show file tree
Hide file tree
Showing 24 changed files with 432 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ function wrapQueryBarTopRowInContext(testProps: any) {
);
}

describe('QueryBarTopRowTopRow', () => {
// Failing: See https://github.com/elastic/kibana/issues/92528
describe.skip('QueryBarTopRowTopRow', () => {
const QUERY_INPUT_SELECTOR = 'QueryStringInputUI';
const TIMEPICKER_SELECTOR = 'EuiSuperDatePicker';
const TIMEPICKER_DURATION = '[data-shared-timefilter-duration]';
Expand Down
145 changes: 144 additions & 1 deletion x-pack/plugins/actions/server/usage/actions_telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Object {
id: '1',
actionTypeId: '.server-log',
},
namespaces: ['default'],
},
},
{
Expand All @@ -154,6 +155,7 @@ Object {
id: '2',
actionTypeId: '.slack',
},
namespaces: ['default'],
},
},
],
Expand All @@ -170,6 +172,8 @@ Object {
"__server-log": 1,
"__slack": 1,
},
"countEmailByService": Object {},
"countNamespaces": 1,
"countTotal": 2,
}
`);
Expand Down Expand Up @@ -220,6 +224,7 @@ Object {
id: '1',
actionTypeId: '.server-log',
},
namespaces: ['default'],
},
},
{
Expand All @@ -228,13 +233,35 @@ Object {
id: '2',
actionTypeId: '.slack',
},
namespaces: ['default'],
},
},
],
},
})
);
const telemetry = await getInUseTotalCount(mockEsClient, 'test');
const telemetry = await getInUseTotalCount(mockEsClient, 'test', undefined, [
{
id: 'test',
actionTypeId: '.email',
name: 'test',
isPreconfigured: true,
config: {
tenantId: 'sdsd',
clientId: 'sdfsdf',
},
secrets: {
clientSecret: 'sdfsdf',
},
},
{
id: 'anotherServerLog',
actionTypeId: '.server-log',
name: 'test',
isPreconfigured: true,
secrets: {},
},
]);

expect(mockEsClient.search).toHaveBeenCalledTimes(2);
expect(telemetry).toMatchInlineSnapshot(`
Expand All @@ -245,6 +272,8 @@ Object {
"__server-log": 1,
"__slack": 1,
},
"countEmailByService": Object {},
"countNamespaces": 1,
"countTotal": 4,
}
`);
Expand Down Expand Up @@ -423,6 +452,114 @@ Object {
id: '1',
actionTypeId: '.server-log',
},
namespaces: ['default'],
},
},
{
_source: {
action: {
id: '2',
actionTypeId: '.slack',
},
namespaces: ['default'],
},
},
{
_source: {
action: {
id: '3',
actionTypeId: '.email',
},
namespaces: ['default'],
},
},
],
},
})
);
const telemetry = await getInUseTotalCount(mockEsClient, 'test', undefined, [
{
id: 'anotherServerLog',
actionTypeId: '.server-log',
name: 'test',
isPreconfigured: true,
secrets: {},
},
]);

expect(mockEsClient.search).toHaveBeenCalledTimes(2);
expect(telemetry).toMatchInlineSnapshot(`
Object {
"countByAlertHistoryConnectorType": 1,
"countByType": Object {
"__email": 3,
"__index": 1,
"__server-log": 1,
"__slack": 1,
},
"countEmailByService": Object {
"other": 3,
},
"countNamespaces": 1,
"countTotal": 6,
}
`);
});

test('getInUseTotalCount() accounts for actions namespaces', async () => {
const mockEsClient = elasticsearchClientMock.createClusterClient().asScoped().asInternalUser;
mockEsClient.search.mockReturnValueOnce(
// @ts-expect-error not full search response
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
refs: {
actionRefIds: {
value: {
connectorIds: {
'1': 'action-0',
'123': 'action-1',
'456': 'action-2',
},
total: 3,
},
},
},
preconfigured_actions: {
preconfiguredActionRefIds: {
value: {
total: 3,
actionRefs: {
'preconfigured:preconfigured-alert-history-es-index': {
actionRef: 'preconfigured:preconfigured-alert-history-es-index',
actionTypeId: '.index',
},
'preconfigured:cloud_email': {
actionRef: 'preconfigured:cloud_email',
actionTypeId: '.email',
},
'preconfigured:cloud_email2': {
actionRef: 'preconfigured:cloud_email2',
actionTypeId: '.email',
},
},
},
},
},
},
})
);
mockEsClient.search.mockReturnValueOnce(
// @ts-expect-error not full search response
elasticsearchClientMock.createSuccessTransportRequestPromise({
hits: {
hits: [
{
_source: {
action: {
id: '1',
actionTypeId: '.server-log',
},
namespaces: ['test'],
},
},
{
Expand All @@ -431,6 +568,7 @@ Object {
id: '2',
actionTypeId: '.slack',
},
namespaces: ['default'],
},
},
{
Expand All @@ -439,6 +577,7 @@ Object {
id: '3',
actionTypeId: '.email',
},
namespaces: ['test2'],
},
},
],
Expand All @@ -457,6 +596,10 @@ Object {
"__server-log": 1,
"__slack": 1,
},
"countEmailByService": Object {
"other": 1,
},
"countNamespaces": 3,
"countTotal": 6,
}
`);
Expand Down
Loading

0 comments on commit ac35e2e

Please sign in to comment.