Skip to content

Commit

Permalink
[8.5] [DOCS] Automate connector-listing.png (#143605) (#145661)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored Nov 23, 2022
1 parent ac61f40 commit b3ea3bf
Show file tree
Hide file tree
Showing 15 changed files with 207 additions and 39 deletions.
1 change: 1 addition & 0 deletions docs/management/action-types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,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 {rac-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/triggersActions/connectors',
},
},

// 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, '');
},
};
}
15 changes: 15 additions & 0 deletions x-pack/test/functional/services/actions/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 { ActionsAPIServiceProvider } from './api';

export function ActionsServiceProvider(context: FtrProviderContext) {
return {
api: ActionsAPIServiceProvider(context),
};
}
4 changes: 4 additions & 0 deletions x-pack/test/functional/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ import { SearchSessionsService } from './search_sessions';
import { ObservabilityProvider } from './observability';
// import { CompareImagesProvider } from './compare_images';
import { CasesServiceProvider } from './cases';
import { ActionsServiceProvider } from './actions';
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 @@ -130,6 +132,8 @@ export const services = {
searchSessions: SearchSessionsService,
observability: ObservabilityProvider,
// compareImages: CompareImagesProvider,
actions: ActionsServiceProvider,
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 @@
/*
* 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');
},
};
}
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 default function ({ loadTestFile }: FtrProviderContext) {
describe('stack alerting', function () {
loadTestFile(require.resolve('./list_view'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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 default function ({ getService, getPageObjects }: FtrProviderContext) {
const commonScreenshots = getService('commonScreenshots');
const screenshotDirectories = ['response_ops_docs', 'stack_alerting'];
const pageObjects = getPageObjects(['common', 'header']);
const actions = getService('actions');

describe('list view', function () {
let serverLogConnectorId: string;

before(async () => {
const connectorName = `server-log-connector`;
({ id: serverLogConnectorId } = await createServerLogConnector(connectorName));
});

after(async () => {
await actions.api.deleteConnector(serverLogConnectorId);
});

it('connectors list screenshot', async () => {
await pageObjects.common.navigateToApp('connectors');
await pageObjects.header.waitUntilLoadingHasFinished();
await commonScreenshots.takeScreenshot(
'connector-listing',
screenshotDirectories,
1400,
1024
);
});
});

const createServerLogConnector = async (name: string) => {
return actions.api.createConnector({
name,
config: {},
secrets: {},
connectorTypeId: '.server-log',
});
};
}
2 changes: 1 addition & 1 deletion x-pack/test/screenshot_creation/ftr_provider_context.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { GenericFtrProviderContext } from '@kbn/test';

import { pageObjects } from '../functional/page_objects';
import { pageObjects } from './page_objects';
import { services } from './services';

export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;
16 changes: 16 additions & 0 deletions x-pack/test/screenshot_creation/page_objects/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 { pageObjects as xpackFunctionalPageObjects } from '../../functional/page_objects';
import { TriggersActionsPageProvider } from '../../functional_with_es_ssl/page_objects/triggers_actions_ui_page';
import { RuleDetailsPageProvider } from '../../functional_with_es_ssl/page_objects/rule_details';

export const pageObjects = {
...xpackFunctionalPageObjects,
triggersActionsUI: TriggersActionsPageProvider,
ruleDetailsUI: RuleDetailsPageProvider,
};

0 comments on commit b3ea3bf

Please sign in to comment.