From 727fb131b535e4677c53918ec987d96c46723a64 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Tue, 5 Dec 2023 13:14:28 +0100 Subject: [PATCH] [Grok Debugger] Add functional serverless tests (#172545) --- .../common/grok_debugger/grok_debugger.ts | 52 +++++++++++++++++++ .../test_suites/common/grok_debugger/index.ts | 14 +++++ .../common_configs/config.group1.ts | 1 + .../security/common_configs/config.group1.ts | 1 + 4 files changed, 68 insertions(+) create mode 100644 x-pack/test_serverless/functional/test_suites/common/grok_debugger/grok_debugger.ts create mode 100644 x-pack/test_serverless/functional/test_suites/common/grok_debugger/index.ts diff --git a/x-pack/test_serverless/functional/test_suites/common/grok_debugger/grok_debugger.ts b/x-pack/test_serverless/functional/test_suites/common/grok_debugger/grok_debugger.ts new file mode 100644 index 0000000000000..6c4be69abbf18 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/common/grok_debugger/grok_debugger.ts @@ -0,0 +1,52 @@ +/* + * 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 { FtrProviderContext } from '../../../ftr_provider_context'; + +export default ({ getPageObjects, getService }: FtrProviderContext) => { + const PageObjects = getPageObjects(['common', 'grokDebugger']); + const browser = getService('browser'); + const security = getService('security'); + const testSubjects = getService('testSubjects'); + const retry = getService('retry'); + + describe('Grok Debugger', function () { + before(async () => { + // Increase window height to ensure "Simulate" button is shown above the + // fold. Otherwise it can't be clicked by the browser driver. + await browser.setWindowSize(1600, 1000); + await security.testUser.setRoles(['global_devtools_read', 'ingest_pipelines_user']); + await PageObjects.common.navigateToApp('dev_tools', { hash: '/grokdebugger' }); + await retry.waitFor('Grok Debugger Header to be visible', async () => { + return testSubjects.isDisplayed('grokDebuggerContainer'); + }); + }); + + after(async () => { + await security.testUser.restoreDefaults(); + }); + + it('Loads the app', async () => { + await retry.waitForWithTimeout('Grok Debugger to be visible', 15000, async () => { + return await (await PageObjects.grokDebugger.simulateButton()).isDisplayed(); + }); + }); + + it('Accept and parse input with built-in grok pattern', async () => { + const eventInput = 'SegerCommaBob'; + const patternInput = '%{USERNAME:u}'; + const response = await PageObjects.grokDebugger.executeGrokSimulation( + eventInput, + patternInput, + null + ); + expect(response).to.eql({ u: 'SegerCommaBob' }); + }); + }); +}; diff --git a/x-pack/test_serverless/functional/test_suites/common/grok_debugger/index.ts b/x-pack/test_serverless/functional/test_suites/common/grok_debugger/index.ts new file mode 100644 index 0000000000000..8b3d1238be058 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/common/grok_debugger/index.ts @@ -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('Serverless Common UI - Grok debugger', function () { + loadTestFile(require.resolve('./grok_debugger')); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group1.ts b/x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group1.ts index 4269eb39f0df8..15faebf98adb3 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group1.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group1.ts @@ -17,6 +17,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { require.resolve('../../common/management'), require.resolve('../../common/platform_security'), require.resolve('../../common/reporting'), + require.resolve('../../common/grok_debugger'), ], junit: { reportName: 'Serverless Observability Functional Tests - Common Group 1', diff --git a/x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts b/x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts index 04d393b044933..6b7f226d5d967 100644 --- a/x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts +++ b/x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts @@ -17,6 +17,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { require.resolve('../../common/management'), require.resolve('../../common/platform_security'), require.resolve('../../common/reporting'), + require.resolve('../../common/grok_debugger'), ], junit: { reportName: 'Serverless Security Functional Tests - Common Group 1',