Skip to content

Commit

Permalink
[Ingest pipelines] Add functional smoke tests for serverless (#172480)
Browse files Browse the repository at this point in the history
## Summary

This PR does some refactoring to the functional tests and page objects
for ingest pipelines and enables the same tests for serverless.
  • Loading branch information
yuliacech authored Dec 8, 2023
1 parent 546555f commit f860fa0
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 49 deletions.
73 changes: 42 additions & 31 deletions x-pack/test/functional/apps/ingest_pipelines/ingest_pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@

import { IngestPutPipelineRequest } from '@elastic/elasticsearch/lib/api/types';
import expect from '@kbn/expect';
import path from 'path';
import { FtrProviderContext } from '../../ftr_provider_context';

const TEST_PIPELINE_NAME = 'test';
const TEST_PIPELINE_NAME = 'test_pipeline';

const PIPELINE = {
name: 'test_pipeline',
name: TEST_PIPELINE_NAME,
description: 'My pipeline description.',
version: 1,
};

const PIPELINE_CSV = {
name: 'test_pipeline',
name: TEST_PIPELINE_NAME,
};

export default ({ getPageObjects, getService }: FtrProviderContext) => {
Expand All @@ -32,13 +31,13 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
this.tags('smoke');
before(async () => {
await security.testUser.setRoles(['ingest_pipelines_user']);
// Create a test pipeline
await es.ingest.putPipeline({
id: TEST_PIPELINE_NAME,
body: { processors: [] },
} as IngestPutPipelineRequest);
});
beforeEach(async () => {
await pageObjects.common.navigateToApp('ingestPipelines');
});
after(async () => {
await security.testUser.restoreDefaults();
});

it('Loads the app', async () => {
log.debug('Checking for section heading to say Ingest Pipelines.');
Expand All @@ -47,13 +46,42 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
expect(headingText).to.be('Ingest Pipelines');
});

it('Displays the test pipeline in the list of pipelines', async () => {
await pageObjects.ingestPipelines.increasePipelineListPageSize();
const pipelines = await pageObjects.ingestPipelines.getPipelinesList();
expect(pipelines).to.contain(TEST_PIPELINE_NAME);
describe('Pipelines list', () => {
before(async () => {
// Create a test pipeline
await es.ingest.putPipeline({
id: TEST_PIPELINE_NAME,
body: { processors: [] },
} as IngestPutPipelineRequest);
});

after(async () => {
// Delete the test pipeline
await es.ingest.deletePipeline({ id: TEST_PIPELINE_NAME });
});

it('Displays the test pipeline in the list of pipelines', async () => {
log.debug('Checking that the test pipeline is in the pipelines list.');
await pageObjects.ingestPipelines.increasePipelineListPageSize();
const pipelines = await pageObjects.ingestPipelines.getPipelinesList();
expect(pipelines).to.contain(TEST_PIPELINE_NAME);
});

it('Opens the details flyout', async () => {
log.debug('Clicking the first pipeline in the list.');

await pageObjects.ingestPipelines.clickPipelineLink(0);
const flyoutExists = await pageObjects.ingestPipelines.detailsFlyoutExists();
expect(flyoutExists).to.be(true);
});
});

describe('create pipeline', () => {
describe('Create pipeline', () => {
afterEach(async () => {
// Delete the pipeline that was created
await es.ingest.deletePipeline({ id: TEST_PIPELINE_NAME });
});

it('Creates a pipeline', async () => {
await pageObjects.ingestPipelines.createNewPipeline(PIPELINE);

Expand All @@ -68,12 +96,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

it('Creates a pipeline from CSV', async () => {
await pageObjects.ingestPipelines.navigateToCreateFromCsv();

await pageObjects.common.setFileInputPath(
path.join(__dirname, 'exports', 'example_mapping.csv')
);

await pageObjects.ingestPipelines.createPipelineFromCsv(PIPELINE_CSV);

await pageObjects.ingestPipelines.closePipelineDetailsFlyout();
Expand All @@ -85,17 +107,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

expect(newPipelineExists).to.be(true);
});

afterEach(async () => {
// Delete the pipeline that was created
await es.ingest.deletePipeline({ id: PIPELINE.name });
await security.testUser.restoreDefaults();
});
});

after(async () => {
// Delete the test pipeline
await es.ingest.deletePipeline({ id: TEST_PIPELINE_NAME });
});
});
};
33 changes: 15 additions & 18 deletions x-pack/test/functional/page_objects/ingest_pipelines_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@
* 2.0.
*/

import path from 'path';
import { WebElementWrapper } from '../../../../test/functional/services/lib/web_element_wrapper';
import { FtrProviderContext } from '../ftr_provider_context';

export function IngestPipelinesPageProvider({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const pageObjects = getPageObjects(['header']);
const pageObjects = getPageObjects(['header', 'common']);
const aceEditor = getService('aceEditor');

return {
async sectionHeadingText() {
return await testSubjects.getVisibleText('appTitle');
},

async emptyStateHeaderText() {
return await testSubjects.getVisibleText('title');
},

async createNewPipeline({
name,
description,
Expand All @@ -38,8 +35,6 @@ export function IngestPipelinesPageProvider({ getService, getPageObjects }: FtrP
await testSubjects.click('createPipelineDropdown');
await testSubjects.click('createNewPipeline');

await testSubjects.exists('pipelineForm');

await testSubjects.setValue('nameField > input', name);
await testSubjects.setValue('descriptionField > input', description);

Expand Down Expand Up @@ -72,25 +67,23 @@ export function IngestPipelinesPageProvider({ getService, getPageObjects }: FtrP
return await Promise.all(pipelines.map((pipeline) => getPipelineName(pipeline)));
},

async navigateToCreateFromCsv() {
await testSubjects.click('createPipelineDropdown');
await testSubjects.click('createPipelineFromCsv');

await testSubjects.exists('createFromCsvInstructions');
async clickPipelineLink(index: number) {
const links = await testSubjects.findAll('pipelineDetailsLink');
await links.at(index)?.click();
},

async createPipelineFromCsv({ name }: { name: string }) {
await testSubjects.click('processFileButton');
await testSubjects.click('createPipelineDropdown');
await testSubjects.click('createPipelineFromCsv');

await testSubjects.exists('pipelineMappingsJSONEditor');
await pageObjects.common.setFileInputPath(
path.join(__dirname, '..', 'fixtures', 'ingest_pipeline_example_mapping.csv')
);

await testSubjects.exists('copyToClipboard');
await testSubjects.exists('downloadJson');
await testSubjects.click('processFileButton');

await testSubjects.click('continueToCreate');

await testSubjects.exists('pipelineForm');

await testSubjects.setValue('nameField > input', name);
await testSubjects.click('submitButton');

Expand All @@ -101,6 +94,10 @@ export function IngestPipelinesPageProvider({ getService, getPageObjects }: FtrP
await testSubjects.click('euiFlyoutCloseButton');
},

async detailsFlyoutExists() {
return await testSubjects.exists('pipelineDetails');
},

async increasePipelineListPageSize() {
await testSubjects.click('tablePaginationPopoverButton');
await testSubjects.click(`tablePagination-50-rows`);
Expand Down
3 changes: 3 additions & 0 deletions x-pack/test_serverless/functional/config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export function createTestConfig(options: CreateTestConfigOptions) {
indexManagement: {
pathname: '/app/management/data/index_management',
},
ingestPipelines: {
pathname: '/app/management/ingest/ingest_pipelines',
},
transform: {
pathname: '/app/management/data/transform',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ export default ({ loadTestFile }: FtrProviderContext) => {
loadTestFile(require.resolve('./advanced_settings'));
loadTestFile(require.resolve('./data_views'));
loadTestFile(require.resolve('./disabled_uis'));
loadTestFile(require.resolve('./ingest_pipelines'));
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* 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 expect from '@kbn/expect';
import { IngestPutPipelineRequest } from '@elastic/elasticsearch/lib/api/types';
import { FtrProviderContext } from '../../../ftr_provider_context';

const TEST_PIPELINE_NAME = 'test_pipeline';

const PIPELINE = {
name: TEST_PIPELINE_NAME,
description: 'My pipeline description.',
version: 1,
};

const PIPELINE_CSV = {
name: TEST_PIPELINE_NAME,
};

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['svlCommonPage', 'common', 'ingestPipelines']);
const es = getService('es');
const log = getService('log');

describe('Ingest Pipelines', function () {
this.tags('smoke');
before(async () => {
await pageObjects.svlCommonPage.login();
});
beforeEach(async () => {
await pageObjects.common.navigateToApp('ingestPipelines');
});
after(async () => {
await pageObjects.svlCommonPage.forceLogout();
});

it('Loads the app', async () => {
log.debug('Checking for section heading to say Ingest Pipelines.');

const headingText = await pageObjects.ingestPipelines.sectionHeadingText();
expect(headingText).to.be('Ingest Pipelines');
});

describe('Pipelines list', () => {
before(async () => {
// Create a test pipeline
await es.ingest.putPipeline({
id: TEST_PIPELINE_NAME,
body: { processors: [] },
} as IngestPutPipelineRequest);
});

after(async () => {
// Delete the test pipeline
await es.ingest.deletePipeline({ id: TEST_PIPELINE_NAME });
});

it('Displays the test pipeline in the list of pipelines', async () => {
log.debug('Checking that the test pipeline is in the pipelines list.');
await pageObjects.ingestPipelines.increasePipelineListPageSize();
const pipelines = await pageObjects.ingestPipelines.getPipelinesList();
expect(pipelines).to.contain(TEST_PIPELINE_NAME);
});

it('Opens the details flyout', async () => {
log.debug('Clicking the first pipeline in the list.');

await pageObjects.ingestPipelines.clickPipelineLink(0);
const flyoutExists = await pageObjects.ingestPipelines.detailsFlyoutExists();
expect(flyoutExists).to.be(true);
});
});

describe('Create pipeline', () => {
afterEach(async () => {
// Delete the pipeline that was created
await es.ingest.deletePipeline({ id: TEST_PIPELINE_NAME });
});

it('Creates a pipeline', async () => {
await pageObjects.ingestPipelines.createNewPipeline(PIPELINE);

await pageObjects.ingestPipelines.closePipelineDetailsFlyout();
await pageObjects.ingestPipelines.increasePipelineListPageSize();
const pipelinesList = await pageObjects.ingestPipelines.getPipelinesList();
const newPipelineExists = Boolean(
pipelinesList.find((pipelineName) => pipelineName === PIPELINE.name)
);

expect(newPipelineExists).to.be(true);
});

it('Creates a pipeline from CSV', async () => {
await pageObjects.ingestPipelines.createPipelineFromCsv(PIPELINE_CSV);

await pageObjects.ingestPipelines.closePipelineDetailsFlyout();
await pageObjects.ingestPipelines.increasePipelineListPageSize();
const pipelinesList = await pageObjects.ingestPipelines.getPipelinesList();
const newPipelineExists = Boolean(
pipelinesList.find((pipelineName) => pipelineName === PIPELINE.name)
);

expect(newPipelineExists).to.be(true);
});
});
});
};

0 comments on commit f860fa0

Please sign in to comment.