mirror of
https://github.com/elastic/kibana.git
synced 2025-04-21 16:29:04 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [[kbn-journeys] add optional beforeSteps hook (#151717)](https://github.com/elastic/kibana/pull/151717) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Dzmitry Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2023-02-22T17:53:00Z","message":"[kbn-journeys] add optional beforeSteps hook (#151717)\n\n## Summary\r\n\r\nRelated to #151613\r\n\r\nThere might be cases when we need to add extra wait for Kibana plugin to\r\nbe ready before starting loading test data with `esArchiver` /\r\n`kbnArchiver`.\r\n\r\nCurrently journey lifecycle looks like this:\r\n\r\n- `onSetup` wrapped with mocha `before` hook\r\n - in parallel \r\n - `setupBrowserAndPage` (including EBT tracker setup)\r\n - load ES data / Kibana saved objects\r\n - `setupApm`\r\n- steps execution (each step wrapped with mocha `it` function)\r\n- `onTeardown` wrapped with mocha `after` hook\r\n - `tearDownBrowserAndPage` (including closing EBT tracker)\r\n - `teardownApm`\r\n - load ES data / Kibana saved objects\r\n\r\nbeforeSteps hook purpose is to make sure Kibana/ES state is ready for\r\njourney execution and not load test data, since it won't be unloaded\r\nduring `after` hook:\r\n\r\n- `onSetup` wrapped with mocha `before` hook\r\n - `setupBrowserAndPage` (including EBT tracker setup)\r\n- run beforeSteps hook -> prepare Kibana/ES for data ingestion / steps\r\nexecution\r\n - load ES data / Kibana saved objects\r\n - `setupApm`\r\n\r\nHow to use:\r\n\r\n```\r\nexport const journey = new Journey({\r\n beforeSteps: async ({ kibanaServer, retry }) => {\r\n retry.try(async () => {\r\n const response = await kibanaServer.request({\r\n path: '/internal/cloud_security_posture/status?check=init',\r\n method: 'GET',\r\n });\r\n return response.status === 200;\r\n });\r\n },\r\n esArchives: [...],\r\n kbnArchives: [...],\r\n})\r\n .step({...})\r\n .step({...})\r\n```","sha":"6c33644b5324df412acd71d2a6433e93c6e17904","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","wg:performance","v8.7.0","v8.8.0","v8.6.3"],"number":151717,"url":"https://github.com/elastic/kibana/pull/151717","mergeCommit":{"message":"[kbn-journeys] add optional beforeSteps hook (#151717)\n\n## Summary\r\n\r\nRelated to #151613\r\n\r\nThere might be cases when we need to add extra wait for Kibana plugin to\r\nbe ready before starting loading test data with `esArchiver` /\r\n`kbnArchiver`.\r\n\r\nCurrently journey lifecycle looks like this:\r\n\r\n- `onSetup` wrapped with mocha `before` hook\r\n - in parallel \r\n - `setupBrowserAndPage` (including EBT tracker setup)\r\n - load ES data / Kibana saved objects\r\n - `setupApm`\r\n- steps execution (each step wrapped with mocha `it` function)\r\n- `onTeardown` wrapped with mocha `after` hook\r\n - `tearDownBrowserAndPage` (including closing EBT tracker)\r\n - `teardownApm`\r\n - load ES data / Kibana saved objects\r\n\r\nbeforeSteps hook purpose is to make sure Kibana/ES state is ready for\r\njourney execution and not load test data, since it won't be unloaded\r\nduring `after` hook:\r\n\r\n- `onSetup` wrapped with mocha `before` hook\r\n - `setupBrowserAndPage` (including EBT tracker setup)\r\n- run beforeSteps hook -> prepare Kibana/ES for data ingestion / steps\r\nexecution\r\n - load ES data / Kibana saved objects\r\n - `setupApm`\r\n\r\nHow to use:\r\n\r\n```\r\nexport const journey = new Journey({\r\n beforeSteps: async ({ kibanaServer, retry }) => {\r\n retry.try(async () => {\r\n const response = await kibanaServer.request({\r\n path: '/internal/cloud_security_posture/status?check=init',\r\n method: 'GET',\r\n });\r\n return response.status === 200;\r\n });\r\n },\r\n esArchives: [...],\r\n kbnArchives: [...],\r\n})\r\n .step({...})\r\n .step({...})\r\n```","sha":"6c33644b5324df412acd71d2a6433e93c6e17904"}},"sourceBranch":"main","suggestedTargetBranches":["8.7","8.6"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151717","number":151717,"mergeCommit":{"message":"[kbn-journeys] add optional beforeSteps hook (#151717)\n\n## Summary\r\n\r\nRelated to #151613\r\n\r\nThere might be cases when we need to add extra wait for Kibana plugin to\r\nbe ready before starting loading test data with `esArchiver` /\r\n`kbnArchiver`.\r\n\r\nCurrently journey lifecycle looks like this:\r\n\r\n- `onSetup` wrapped with mocha `before` hook\r\n - in parallel \r\n - `setupBrowserAndPage` (including EBT tracker setup)\r\n - load ES data / Kibana saved objects\r\n - `setupApm`\r\n- steps execution (each step wrapped with mocha `it` function)\r\n- `onTeardown` wrapped with mocha `after` hook\r\n - `tearDownBrowserAndPage` (including closing EBT tracker)\r\n - `teardownApm`\r\n - load ES data / Kibana saved objects\r\n\r\nbeforeSteps hook purpose is to make sure Kibana/ES state is ready for\r\njourney execution and not load test data, since it won't be unloaded\r\nduring `after` hook:\r\n\r\n- `onSetup` wrapped with mocha `before` hook\r\n - `setupBrowserAndPage` (including EBT tracker setup)\r\n- run beforeSteps hook -> prepare Kibana/ES for data ingestion / steps\r\nexecution\r\n - load ES data / Kibana saved objects\r\n - `setupApm`\r\n\r\nHow to use:\r\n\r\n```\r\nexport const journey = new Journey({\r\n beforeSteps: async ({ kibanaServer, retry }) => {\r\n retry.try(async () => {\r\n const response = await kibanaServer.request({\r\n path: '/internal/cloud_security_posture/status?check=init',\r\n method: 'GET',\r\n });\r\n return response.status === 200;\r\n });\r\n },\r\n esArchives: [...],\r\n kbnArchives: [...],\r\n})\r\n .step({...})\r\n .step({...})\r\n```","sha":"6c33644b5324df412acd71d2a6433e93c6e17904"}},{"branch":"8.6","label":"v8.6.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co> |
||
---|---|---|
.. | ||
journey | ||
services | ||
BUILD.bazel | ||
index.ts | ||
jest.config.js | ||
kibana.jsonc | ||
package.json | ||
README.mdx | ||
tsconfig.json |
--- id: kibDevDocsOpsJourneys slug: /kibana-dev-docs/ops/journeys title: Journeys description: A new style of functional test, focused on performance testing for now tags: ['kibana', 'dev', 'contributor', 'operations', 'performance', 'functional', 'testing'] --- Journeys are a slightly newer take on Functional Tests, currently powered by [playwright](https://playwright.dev/docs). A Journey is a single pathway through Kibana and looks something like this: ```ts import { Journey } from '@kbn/journeys'; import { subj } from '@kbn/test-subj-selector'; export const journey = new Journey({ esArchives: [ ... ], kbnArchives: [ ... ], scalabilitySetup: { ... }, }) .step('Go to Discover Page', async ({ page, kbnUrl }) => { await page.goto(kbnUrl.get(`/app/discover`)); await page.waitForSelector(subj('discoverDocTable')); }) .step('Expand the first document', async ({ page }) => { const expandButtons = page.locator(subj('docTableExpandToggleColumn')); await expandButtons.first().click(); await page.locator('text="Expanded document"'); }); ```