mirror of
https://github.com/elastic/kibana.git
synced 2025-04-22 00:45:43 -04:00
# Backport This will backport the following commits from `main` to `8.7`: - [[ftr] fix scripts/functional_tests to respect cli flags (#155734)](https://github.com/elastic/kibana/pull/155734) <!--- 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-04-26T16:33:54Z","message":"[ftr] fix scripts/functional_tests to respect cli flags (#155734)\n\n## Summary\r\n\r\nThis\r\n[failure](https://buildkite.com/elastic/kibana-on-merge/builds/29091#01879988-ecd2-4e4f-bfb4-108939f145a1)\r\nclearly shows that `--bail` flag is ignored when passed to\r\n`scripts/functional_tests.js` script, and since\r\n`scripts/functional_tests.js --help` list these flags I think we need to\r\nfix it:\r\n\r\n```\r\n --include-tag Tags that suites must include to be run, can be included multiple times\r\n --exclude-tag Tags that suites must NOT include to be run, can be included multiple times\r\n --include Files that must included to be run, can be included multiple times\r\n --exclude Files that must NOT be included to be run, can be included multiple times\r\n --grep Pattern to select which tests to run\r\n --bail Stop the test run at the first failure\r\n --dry-run Report tests without executing them\r\n --updateBaselines Replace baseline screenshots with whatever is generated from the test\r\n --updateSnapshots Replace inline and file snapshots with whatever is generated from the test\r\n```\r\n\r\nI was able to reproduce it locally:\r\n1. Break\r\n[test/functional/apps/console/_console.ts](test/functional/apps/console/_console.ts)\r\nby adding `expect(1).to.be(2);` in the first `it` function\r\n2. Run `node scripts/functional_tests.js --bail --config\r\ntest/functional/apps/console/config.ts`\r\nActual: Tests continue to run after failure\r\nExpected: Stop tests after first failure\r\n\r\nIt turned out `scripts/functional_test_runner.js` respects the flags so\r\nI just copied the logic from\r\n[packages/kbn-test/src/functional_test_runner/cli.ts](https://github.com/elastic/kibana/blob/main/packages/kbn-test/src/functional_test_runner/cli.ts#L41-L63)\r\n\r\nLet me know if you think we need to add jest tests.\r\n\r\n\r\nTested:\r\n\r\n```\r\nnode scripts/functional_tests.js --bail --config test/functional/apps/console/config.ts --grep \"multiple requests output\"\r\n```","sha":"4211e03a5f7651afeea492e44116eb614b54f00c","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v7.17.10","v8.8.0","v8.7.2"],"number":155734,"url":"https://github.com/elastic/kibana/pull/155734","mergeCommit":{"message":"[ftr] fix scripts/functional_tests to respect cli flags (#155734)\n\n## Summary\r\n\r\nThis\r\n[failure](https://buildkite.com/elastic/kibana-on-merge/builds/29091#01879988-ecd2-4e4f-bfb4-108939f145a1)\r\nclearly shows that `--bail` flag is ignored when passed to\r\n`scripts/functional_tests.js` script, and since\r\n`scripts/functional_tests.js --help` list these flags I think we need to\r\nfix it:\r\n\r\n```\r\n --include-tag Tags that suites must include to be run, can be included multiple times\r\n --exclude-tag Tags that suites must NOT include to be run, can be included multiple times\r\n --include Files that must included to be run, can be included multiple times\r\n --exclude Files that must NOT be included to be run, can be included multiple times\r\n --grep Pattern to select which tests to run\r\n --bail Stop the test run at the first failure\r\n --dry-run Report tests without executing them\r\n --updateBaselines Replace baseline screenshots with whatever is generated from the test\r\n --updateSnapshots Replace inline and file snapshots with whatever is generated from the test\r\n```\r\n\r\nI was able to reproduce it locally:\r\n1. Break\r\n[test/functional/apps/console/_console.ts](test/functional/apps/console/_console.ts)\r\nby adding `expect(1).to.be(2);` in the first `it` function\r\n2. Run `node scripts/functional_tests.js --bail --config\r\ntest/functional/apps/console/config.ts`\r\nActual: Tests continue to run after failure\r\nExpected: Stop tests after first failure\r\n\r\nIt turned out `scripts/functional_test_runner.js` respects the flags so\r\nI just copied the logic from\r\n[packages/kbn-test/src/functional_test_runner/cli.ts](https://github.com/elastic/kibana/blob/main/packages/kbn-test/src/functional_test_runner/cli.ts#L41-L63)\r\n\r\nLet me know if you think we need to add jest tests.\r\n\r\n\r\nTested:\r\n\r\n```\r\nnode scripts/functional_tests.js --bail --config test/functional/apps/console/config.ts --grep \"multiple requests output\"\r\n```","sha":"4211e03a5f7651afeea492e44116eb614b54f00c"}},"sourceBranch":"main","suggestedTargetBranches":["7.17","8.7"],"targetPullRequestStates":[{"branch":"7.17","label":"v7.17.10","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/155734","number":155734,"mergeCommit":{"message":"[ftr] fix scripts/functional_tests to respect cli flags (#155734)\n\n## Summary\r\n\r\nThis\r\n[failure](https://buildkite.com/elastic/kibana-on-merge/builds/29091#01879988-ecd2-4e4f-bfb4-108939f145a1)\r\nclearly shows that `--bail` flag is ignored when passed to\r\n`scripts/functional_tests.js` script, and since\r\n`scripts/functional_tests.js --help` list these flags I think we need to\r\nfix it:\r\n\r\n```\r\n --include-tag Tags that suites must include to be run, can be included multiple times\r\n --exclude-tag Tags that suites must NOT include to be run, can be included multiple times\r\n --include Files that must included to be run, can be included multiple times\r\n --exclude Files that must NOT be included to be run, can be included multiple times\r\n --grep Pattern to select which tests to run\r\n --bail Stop the test run at the first failure\r\n --dry-run Report tests without executing them\r\n --updateBaselines Replace baseline screenshots with whatever is generated from the test\r\n --updateSnapshots Replace inline and file snapshots with whatever is generated from the test\r\n```\r\n\r\nI was able to reproduce it locally:\r\n1. Break\r\n[test/functional/apps/console/_console.ts](test/functional/apps/console/_console.ts)\r\nby adding `expect(1).to.be(2);` in the first `it` function\r\n2. Run `node scripts/functional_tests.js --bail --config\r\ntest/functional/apps/console/config.ts`\r\nActual: Tests continue to run after failure\r\nExpected: Stop tests after first failure\r\n\r\nIt turned out `scripts/functional_test_runner.js` respects the flags so\r\nI just copied the logic from\r\n[packages/kbn-test/src/functional_test_runner/cli.ts](https://github.com/elastic/kibana/blob/main/packages/kbn-test/src/functional_test_runner/cli.ts#L41-L63)\r\n\r\nLet me know if you think we need to add jest tests.\r\n\r\n\r\nTested:\r\n\r\n```\r\nnode scripts/functional_tests.js --bail --config test/functional/apps/console/config.ts --grep \"multiple requests output\"\r\n```","sha":"4211e03a5f7651afeea492e44116eb614b54f00c"}},{"branch":"8.7","label":"v8.7.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co> |
||
---|---|---|
.. | ||
jest_integration | ||
jest_integration_node | ||
jest_node | ||
src | ||
types/ftr_globals | ||
index.ts | ||
jest-preset.js | ||
jest.config.js | ||
jest.integration.config.js | ||
kibana.jsonc | ||
package.json | ||
README.mdx | ||
tsconfig.json |
--- id: kibDevDocsOpsTest slug: /kibana-dev-docs/ops/test title: '@kbn/test' description: A package provide ways to run tests date: 2022-08-15 tags: ['kibana', 'dev', 'contributor', 'operations', 'cli', 'dev', 'mode', 'test'] --- # Kibana Testing Library The @kbn/test package provides ways to run tests. Currently only functional testing is provided by this library, with unit and other testing possibly added here. ## Functional Testing ### Dependencies Functional testing methods exist in the `src/functional_tests` directory. They depend on the Functional Test Runner, which is found in [`{KIBANA_ROOT}/src/functional_test_runner`](../../src/functional_test_runner). Ideally libraries provided by kibana packages such as this one should not depend on kibana source code that lives in [`{KIBANA_ROOT}/src`](../../src). The goal is to start pulling test and development utilities out into packages so they can be used across Kibana and plugins. Accordingly the Functional Test Runner itself will be pulled out into a package (or part of a package), and this package's dependence on it will not be an issue. ### Exposed methods #### `runTests(configPaths: Array<string>)` For each config file specified in configPaths, starts Elasticsearch and Kibana once, runs tests specified in that config file, and shuts down Elasticsearch and Kibana once completed. (Repeats for every config file.) `configPaths`: array of strings, each an absolute path to a config file that looks like [this](../../test/functional/config.base.js), following the config schema specified [here](../../src/functional_test_runner/lib/config/schema.js). Internally the method that starts Elasticsearch comes from [kbn-es](../../packages/kbn-es). #### `startServers(configPath: string)` Starts Elasticsearch and Kibana servers given a specified config. `configPath`: absolute path to a config file that looks like [this](../../test/functional/config.base.js), following the config schema specified [here](../../src/functional_test_runner/lib/config/schema.js). Allows users to start another process to run just the tests while keeping the servers running with this method. Start servers _and_ run tests using the same config file ([see how](../../scripts/README.md)). ## Rationale ### Single config per setup We think it makes sense to specify the tests to run along with the particular server configuration for Elasticsearch and Kibana servers, because the tests expect a particular configuration. For example, saml api integration tests expect certain xml files to exist in Elasticsearch's config directory, and certain saml specific options to be passed in via the command line (or alternatively via the `.yml` config file) to both Elasticsearch and Kibana. It makes sense to keep all these config options together with the list of test files. ### Multiple configs running in succession We also think it makes sense to have a test runner intelligently (but simply) start servers, run tests, tear down servers, and repeat for each config, uninterrupted. There's nothing special about each kind of config that specifies running some set of functional tests against some kind of Elasticsearch/Kibana servers. There doesn't need to be a separate job to run each kind of setup/test/teardown. These can all be orchestrated sequentially via the current `runTests` implementation. This is how we envision tests to run on CI. This inherently means that grouping test files in configs matters, such that a group of test files that depends on a particular server config appears together in that config's `testFiles` list. Given how quickly and easily we can start servers using [@kbn/es](../../packages/kbn-es), it should not impact performance to logically group tests by domain even if multiple groups of tests share the same server config. We can think about how to group test files together across domains when that time comes.