From f860fa04a441d76e5232eed6881513d5b343e3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yulia=20=C4=8Cech?= <6585477+yuliacech@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:30:12 +0100 Subject: [PATCH] [Ingest pipelines] Add functional smoke tests for serverless (#172480) ## Summary This PR does some refactoring to the functional tests and page objects for ingest pipelines and enables the same tests for serverless. --- .../apps/ingest_pipelines/ingest_pipelines.ts | 73 +++++++----- .../ingest_pipeline_example_mapping.csv} | 0 .../page_objects/ingest_pipelines_page.ts | 33 +++--- .../test_serverless/functional/config.base.ts | 3 + .../test_suites/common/management/index.ts | 1 + .../common/management/ingest_pipelines.ts | 111 ++++++++++++++++++ 6 files changed, 172 insertions(+), 49 deletions(-) rename x-pack/test/functional/{apps/ingest_pipelines/exports/example_mapping.csv => fixtures/ingest_pipeline_example_mapping.csv} (100%) create mode 100644 x-pack/test_serverless/functional/test_suites/common/management/ingest_pipelines.ts diff --git a/x-pack/test/functional/apps/ingest_pipelines/ingest_pipelines.ts b/x-pack/test/functional/apps/ingest_pipelines/ingest_pipelines.ts index ec9f8815cd664..3fae7aa9ecc87 100644 --- a/x-pack/test/functional/apps/ingest_pipelines/ingest_pipelines.ts +++ b/x-pack/test/functional/apps/ingest_pipelines/ingest_pipelines.ts @@ -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) => { @@ -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.'); @@ -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); @@ -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(); @@ -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 }); }); }); }; diff --git a/x-pack/test/functional/apps/ingest_pipelines/exports/example_mapping.csv b/x-pack/test/functional/fixtures/ingest_pipeline_example_mapping.csv similarity index 100% rename from x-pack/test/functional/apps/ingest_pipelines/exports/example_mapping.csv rename to x-pack/test/functional/fixtures/ingest_pipeline_example_mapping.csv diff --git a/x-pack/test/functional/page_objects/ingest_pipelines_page.ts b/x-pack/test/functional/page_objects/ingest_pipelines_page.ts index b3f9e7735ad1c..3e0bc23869bb7 100644 --- a/x-pack/test/functional/page_objects/ingest_pipelines_page.ts +++ b/x-pack/test/functional/page_objects/ingest_pipelines_page.ts @@ -5,12 +5,13 @@ * 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 { @@ -18,10 +19,6 @@ export function IngestPipelinesPageProvider({ getService, getPageObjects }: FtrP return await testSubjects.getVisibleText('appTitle'); }, - async emptyStateHeaderText() { - return await testSubjects.getVisibleText('title'); - }, - async createNewPipeline({ name, description, @@ -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); @@ -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'); @@ -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`); diff --git a/x-pack/test_serverless/functional/config.base.ts b/x-pack/test_serverless/functional/config.base.ts index 538316b61e80f..643c537940484 100644 --- a/x-pack/test_serverless/functional/config.base.ts +++ b/x-pack/test_serverless/functional/config.base.ts @@ -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', }, diff --git a/x-pack/test_serverless/functional/test_suites/common/management/index.ts b/x-pack/test_serverless/functional/test_suites/common/management/index.ts index 5d8304de55503..90ae534dc8610 100644 --- a/x-pack/test_serverless/functional/test_suites/common/management/index.ts +++ b/x-pack/test_serverless/functional/test_suites/common/management/index.ts @@ -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')); }); }; diff --git a/x-pack/test_serverless/functional/test_suites/common/management/ingest_pipelines.ts b/x-pack/test_serverless/functional/test_suites/common/management/ingest_pipelines.ts new file mode 100644 index 0000000000000..c9a5b730cc00e --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/common/management/ingest_pipelines.ts @@ -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); + }); + }); + }); +};