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

[DOCS] Automate connector-listing.png #143605

Merged
merged 21 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8b48710
[DOCS] Automate connector list screenshot
lcawl Oct 21, 2022
b0f0560
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Oct 21, 2022
c3448c7
Update x-pack/test/screenshot_creation/apps/response_ops_docs/stack_a…
lcawl Oct 31, 2022
9199d38
Add connectors app to config.base.js
lcawl Nov 4, 2022
56f118c
Move createConnector to api.ts
lcawl Nov 11, 2022
e82f35b
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Nov 11, 2022
32c6e45
Move deleteConnector to api.ts
lcawl Nov 11, 2022
793e84d
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Nov 11, 2022
9f8e499
Create test_resources.tsx in sample_data
lcawl Nov 11, 2022
6afe1af
Remove sample data methods from ml test_resources.ts
lcawl Nov 11, 2022
4f4e759
[DOCS] Add comment to action-types.asciidoc
lcawl Nov 11, 2022
62bb304
Remove createConnector from utils.ts
lcawl Nov 11, 2022
5ea0c84
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Nov 11, 2022
f79c780
Re-add automated screenshot
lcawl Nov 15, 2022
767f686
Fix type errors
lcawl Nov 17, 2022
898721f
Fix tests for Opsgenie and Tines connectors
lcawl Nov 17, 2022
e883740
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Nov 17, 2022
e821310
Remove redundant supertest
lcawl Nov 17, 2022
df955c6
Merge branch 'main' into alerting-screenshot1
lcawl Nov 17, 2022
701ef86
Remove more unnecessary supertest
lcawl Nov 17, 2022
827e6a1
Merge branch 'main' into alerting-screenshot1
lcawl Nov 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/management/action-types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Rules use connectors to route actions to different destinations like log files,

[role="screenshot"]
image::images/connector-listing.png[Example connector listing in the {rules-ui} UI]
// NOTE: This is an autogenerated screenshot. Do not edit it directly.

[float]
=== Required permissions
Expand Down
Binary file modified docs/management/connectors/images/connector-listing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions x-pack/test/functional/config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ export default async function ({ readConfigFile }) {
observability: {
pathname: '/app/observability',
},
connectors: {
pathname: '/app/management/insightsAndAlerting/triggersActionsConnectors/',
},
},

// choose where screenshots should be saved
Expand Down
46 changes: 46 additions & 0 deletions x-pack/test/functional/services/actions/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export function ActionsAPIServiceProvider({ getService }: FtrProviderContext) {
const kbnSupertest = getService('supertest');

return {
async createConnector({
name,
config,
secrets,
connectorTypeId,
}: {
name: string;
config: Record<string, unknown>;
secrets: Record<string, unknown>;
connectorTypeId: string;
}) {
const { body: createdAction } = await kbnSupertest
.post(`/api/actions/connector`)
.set('kbn-xsrf', 'foo')
.send({
name,
config,
secrets,
connector_type_id: connectorTypeId,
})
.expect(200);

return createdAction;
},

async deleteConnector(id: string) {
return kbnSupertest
.delete(`/api/actions/connector/${id}`)
.set('kbn-xsrf', 'foo')
.expect(204, '');
},
};
}
2 changes: 2 additions & 0 deletions x-pack/test/functional/services/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { FtrProviderContext } from '../../ftr_provider_context';
import { ActionsCommonServiceProvider } from './common';
import { ActionsOpsgenieServiceProvider } from './opsgenie';
import { ActionsTinesServiceProvider } from './tines';
import { ActionsAPIServiceProvider } from './api';

export function ActionsServiceProvider(context: FtrProviderContext) {
const common = ActionsCommonServiceProvider(context);

return {
api: ActionsAPIServiceProvider(context),
common: ActionsCommonServiceProvider(context),
opsgenie: ActionsOpsgenieServiceProvider(context, common),
tines: ActionsTinesServiceProvider(context, common),
Expand Down
2 changes: 2 additions & 0 deletions x-pack/test/functional/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import { CasesServiceProvider } from './cases';
import { ActionsServiceProvider } from './actions';
import { RulesServiceProvider } from './rules';
import { AiopsProvider } from './aiops';
import { SampleDataServiceProvider } from './sample_data';

// define the name and providers for services that should be
// available to your tests. If you don't specify anything here
Expand Down Expand Up @@ -136,4 +137,5 @@ export const services = {
rules: RulesServiceProvider,
cases: CasesServiceProvider,
aiops: AiopsProvider,
sampleData: SampleDataServiceProvider,
};
34 changes: 0 additions & 34 deletions x-pack/test/functional/services/ml/test_resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,39 +630,5 @@ export function MachineLearningTestResourcesProvider(
async clearAdvancedSettingProperty(propertyName: string) {
await kibanaServer.uiSettings.unset(propertyName);
},

async installKibanaSampleData(sampleDataId: 'ecommerce' | 'flights' | 'logs') {
log.debug(`Installing Kibana sample data '${sampleDataId}'`);

const { body, status } = await supertest
.post(`/api/sample_data/${sampleDataId}`)
.set(COMMON_REQUEST_HEADERS);
mlApi.assertResponseStatusCode(200, status, body);

log.debug(` > Installed`);
},

async removeKibanaSampleData(sampleDataId: 'ecommerce' | 'flights' | 'logs') {
log.debug(`Removing Kibana sample data '${sampleDataId}'`);

const { body, status } = await supertest
.delete(`/api/sample_data/${sampleDataId}`)
.set(COMMON_REQUEST_HEADERS);
mlApi.assertResponseStatusCode(204, status, body);

log.debug(` > Removed`);
},

async installAllKibanaSampleData() {
await this.installKibanaSampleData('ecommerce');
await this.installKibanaSampleData('flights');
await this.installKibanaSampleData('logs');
},

async removeAllKibanaSampleData() {
await this.removeKibanaSampleData('ecommerce');
await this.removeKibanaSampleData('flights');
await this.removeKibanaSampleData('logs');
},
};
}
15 changes: 15 additions & 0 deletions x-pack/test/functional/services/sample_data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';
import { SampleDataTestResourcesServiceProvider } from './test_resources';

export function SampleDataServiceProvider(context: FtrProviderContext) {
return {
testResources: SampleDataTestResourcesServiceProvider(context),
};
}
37 changes: 37 additions & 0 deletions x-pack/test/functional/services/sample_data/test_resources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export function SampleDataTestResourcesServiceProvider({ getService }: FtrProviderContext) {
const supertest = getService('supertest');

return {
async installKibanaSampleData(sampleDataId: 'ecommerce' | 'flights' | 'logs') {
await supertest.post(`/api/sample_data/${sampleDataId}`).set('kbn-xsrf', 'true').expect(200);
},

async removeKibanaSampleData(sampleDataId: 'ecommerce' | 'flights' | 'logs') {
await supertest
.delete(`/api/sample_data/${sampleDataId}`)
.set('kbn-xsrf', 'true')
.expect(204);
},

async installAllKibanaSampleData() {
await this.installKibanaSampleData('ecommerce');
await this.installKibanaSampleData('flights');
await this.installKibanaSampleData('logs');
},

async removeAllKibanaSampleData() {
await this.removeKibanaSampleData('ecommerce');
await this.removeKibanaSampleData('flights');
await this.removeKibanaSampleData('logs');
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
const updatedConnectorName = `${connectorName}updated`;
const createdAction = await createSlackConnector({
name: connectorName,
supertest,
getService,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up from my previous comment about removing supertest as a prop, we'll just need to carry those changes through to here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed in bc960b34ee5c4c7b76fa0b8934a00725c4aca863

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry what I meant was that line 80 in this file is no longer needed either. createSlackConnector doesn't use supertest anymore.

});
objectRemover.add(createdAction.id, 'action', 'actions');
await browser.refresh();
Expand Down Expand Up @@ -176,7 +176,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
const connectorName = generateUniqueKey();
const createdAction = await createSlackConnector({
name: connectorName,
supertest,
getService,
});
objectRemover.add(createdAction.id, 'action', 'actions');
await browser.refresh();
Expand Down Expand Up @@ -205,10 +205,10 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex

it('should delete a connector', async () => {
const connectorName = generateUniqueKey();
await createSlackConnector({ name: connectorName, supertest });
await createSlackConnector({ name: connectorName, getService });
const createdAction = await createSlackConnector({
name: generateUniqueKey(),
supertest,
getService,
});
objectRemover.add(createdAction.id, 'action', 'actions');
await browser.refresh();
Expand All @@ -234,10 +234,10 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex

it('should bulk delete connectors', async () => {
const connectorName = generateUniqueKey();
await createSlackConnector({ name: connectorName, supertest });
await createSlackConnector({ name: connectorName, getService });
const createdAction = await createSlackConnector({
name: generateUniqueKey(),
supertest,
getService,
});
objectRemover.add(createdAction.id, 'action', 'actions');
await browser.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { ObjectRemover } from '../../../lib/object_remover';
import { generateUniqueKey } from '../../../lib/get_test_data';
import { createConnector, createSlackConnectorAndObjectRemover, getConnectorByName } from './utils';
import { createSlackConnectorAndObjectRemover, getConnectorByName } from './utils';

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const testSubjects = getService('testSubjects');
Expand Down Expand Up @@ -366,12 +366,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
};

const createOpsgenieConnector = async (name: string) => {
return createConnector({
return actions.api.createConnector({
name,
config: { apiUrl: 'https//test.com' },
secrets: { apiKey: '1234' },
connectorTypeId: '.opsgenie',
supertest,
});
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { ObjectRemover } from '../../../lib/object_remover';
import { generateUniqueKey } from '../../../lib/get_test_data';
import { createConnector, getConnectorByName } from './utils';
import { getConnectorByName } from './utils';
import {
tinesAgentWebhook,
tinesStory1,
Expand Down Expand Up @@ -267,12 +267,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

const createTinesConnector = async (name: string) => {
return createConnector({
return actions.api.createConnector({
name,
config: { url: simulatorUrl },
secrets: { email: '[email protected]', token: 'apiToken' },
connectorTypeId: '.tines',
supertest,
});
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const createSlackConnectorAndObjectRemover = async ({
const testData = getTestActionData();
const createdAction = await createSlackConnector({
name: testData.name,
supertest,
getService,
});
objectRemover.add(createdAction.id, 'action', 'actions');

Expand All @@ -32,17 +32,17 @@ export const createSlackConnectorAndObjectRemover = async ({

export const createSlackConnector = async ({
name,
supertest,
getService,
}: {
name: string;
supertest: SuperTest.SuperTest<SuperTest.Test>;
getService: FtrProviderContext['getService'];
}) => {
const connector = await createConnector({
const actions = getService('actions');
const connector = await actions.api.createConnector({
name,
config: {},
secrets: { webhookUrl: 'https://test.com' },
connectorTypeId: '.slack',
supertest,
});

return connector;
Expand All @@ -59,30 +59,3 @@ export const getConnectorByName = async (
const i = findIndex(body, (c: any) => c.name === name);
return body[i];
};

export const createConnector = async ({
name,
config,
secrets,
connectorTypeId,
supertest,
}: {
name: string;
config: Record<string, unknown>;
secrets: Record<string, unknown>;
connectorTypeId: string;
supertest: SuperTest.SuperTest<SuperTest.Test>;
}) => {
const { body: createdAction } = await supertest
.post(`/api/actions/connector`)
.set('kbn-xsrf', 'foo')
.send({
name,
config,
secrets,
connector_type_id: connectorTypeId,
})
.expect(200);

return createdAction;
};
5 changes: 3 additions & 2 deletions x-pack/test/screenshot_creation/apps/ml_docs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ export const LOGS_INDEX_PATTERN = 'kibana_sample_data_logs';
export default function ({ getPageObject, getService, loadTestFile }: FtrProviderContext) {
const browser = getService('browser');
const ml = getService('ml');
const sampleData = getService('sampleData');
const securityPage = getPageObject('security');

describe('machine learning docs', function () {
this.tags(['ml']);

before(async () => {
await ml.testResources.installAllKibanaSampleData();
await sampleData.testResources.installAllKibanaSampleData();
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.testResources.disableKibanaAnnouncements();
await browser.setWindowSize(1920, 1080);
});

after(async () => {
await securityPage.forceLogout();
await ml.testResources.removeAllKibanaSampleData();
await sampleData.testResources.removeAllKibanaSampleData();
await ml.testResources.resetKibanaTimeZone();
await ml.testResources.resetKibanaAnnouncements();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ export const LOGS_INDEX_PATTERN = 'kibana_sample_data_logs';
export default function ({ getPageObject, getService, loadTestFile }: FtrProviderContext) {
const browser = getService('browser');
const ml = getService('ml');
const sampleData = getService('sampleData');
const securityPage = getPageObject('security');

describe('response ops docs', function () {
this.tags(['responseOps']);

before(async () => {
await ml.testResources.installAllKibanaSampleData();
await sampleData.testResources.installAllKibanaSampleData();
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.testResources.disableKibanaAnnouncements();
await browser.setWindowSize(1920, 1080);
Expand All @@ -33,11 +34,12 @@ export default function ({ getPageObject, getService, loadTestFile }: FtrProvide

after(async () => {
await securityPage.forceLogout();
await ml.testResources.removeAllKibanaSampleData();
await sampleData.testResources.removeAllKibanaSampleData();
await ml.testResources.resetKibanaTimeZone();
await ml.testResources.resetKibanaAnnouncements();
});

loadTestFile(require.resolve('./stack_alerting'));
loadTestFile(require.resolve('./stack_cases'));
loadTestFile(require.resolve('./observability_cases'));
});
Expand Down
Loading