-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[scout] adding unit tests #204567
[scout] adding unit tests #204567
Conversation
@@ -29,7 +29,7 @@ function createClientUrlWithAuth({ serviceName, url, username, password, log }: | |||
return clientUrl.toString(); | |||
} | |||
|
|||
export function createEsClient(config: ScoutServerConfig, log: ToolingLog) { | |||
export function createEsClient(config: ScoutTestConfig, log: ToolingLog) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to differentiate servers configuration and Scout test configuration, that used by Playwright fixtures/tests.
@@ -13,15 +13,15 @@ import Path from 'path'; | |||
import { cloneDeepWith, get, has, toPath } from 'lodash'; | |||
import { REPO_ROOT } from '@kbn/repo-info'; | |||
import { schema } from './schema'; | |||
import { ScoutServerConfig } from '../types'; | |||
import { formatCurrentDate, getProjectType } from './utils'; | |||
import { ScoutServerConfig, ScoutTestConfig } from '../types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScoutServerConfig
is compatible with kbn-test
functionality and used to start the servers, while ScoutTestConfig
is for Playwright tests and exposes hosts, credentials, licence and other test-required data.
return { | ||
serverless: this.get('serverless'), | ||
projectType: this.get('serverless') | ||
? getProjectType(this.get('kbnTestServer.serverArgs')) | ||
: undefined, | ||
isCloud: false, | ||
license: this.get('esTestCluster.license'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be useful for some tests
@@ -75,7 +75,7 @@ export const schema = Joi.object() | |||
|
|||
esTestCluster: Joi.object() | |||
.keys({ | |||
license: Joi.valid('basic', 'trial', 'gold').default('basic'), | |||
license: Joi.valid('basic', 'trial', 'gold').default('trial'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default trial
to match default deployment-agnostic
test design
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
cc @dmlemeshko |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Left a few questions and suggestions, but approved in order to not block.
|
||
expect(result).toBe(expectedPath); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding two negative test cases?
- completely unknown config (e.g.
config = 'unsupportedConfig'
) - a serverless config with invalid type (e.g.
config = 'serverless=unsupportedType'
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good ideas, I actually covered the 2nd one in other area, but missed here. I will add it in the follow-up, as auto-merge was activated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config = 'unsupportedConfig'
I just realised why I skipped it: it is handled by Type check, basically https://github.com/dmlemeshko/kibana/blob/392b1394dea417b40bc32accfc88ab3ec494b4da/packages/kbn-scout/src/config/utils/get_config_file.ts#L13 restricts the argument passed to the function.
Same is actually valid for config = 'serverless=unsupportedType'
Starting backport for target branches: 8.x |
## Summary Adding tests and making adjustments/fixes based on the findings. Note: no integration tests were added to verify servers start as it is mostly equal to `@kbn-test` functionality that has jest integration tests. We can add it later, when Scout has specific logic. How to run: `node scripts/jest --config packages/kbn-scout/jest.config.js` Scope: ``` PASS packages/kbn-scout/src/config/config.test.ts PASS packages/kbn-scout/src/config/loader/read_config_file.test.ts PASS packages/kbn-scout/src/config/utils/get_config_file.test.ts PASS packages/kbn-scout/src/config/utils/load_servers_config.test.ts PASS packages/kbn-scout/src/config/utils/save_scout_test_config.test.ts PASS packages/kbn-scout/src/playwright/config/create_config.test.ts PASS packages/kbn-scout/src/playwright/runner/config_validator.test.ts PASS packages/kbn-scout/src/playwright/runner/flags.test.ts PASS packages/kbn-scout/src/playwright/utils/runner_utils.test.ts PASS packages/kbn-scout/src/servers/flags.test.ts ``` (cherry picked from commit 2ba3247)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary Adding tests and making adjustments/fixes based on the findings. Note: no integration tests were added to verify servers start as it is mostly equal to `@kbn-test` functionality that has jest integration tests. We can add it later, when Scout has specific logic. How to run: `node scripts/jest --config packages/kbn-scout/jest.config.js` Scope: ``` PASS packages/kbn-scout/src/config/config.test.ts PASS packages/kbn-scout/src/config/loader/read_config_file.test.ts PASS packages/kbn-scout/src/config/utils/get_config_file.test.ts PASS packages/kbn-scout/src/config/utils/load_servers_config.test.ts PASS packages/kbn-scout/src/config/utils/save_scout_test_config.test.ts PASS packages/kbn-scout/src/playwright/config/create_config.test.ts PASS packages/kbn-scout/src/playwright/runner/config_validator.test.ts PASS packages/kbn-scout/src/playwright/runner/flags.test.ts PASS packages/kbn-scout/src/playwright/utils/runner_utils.test.ts PASS packages/kbn-scout/src/servers/flags.test.ts ```
# Backport This will backport the following commits from `main` to `8.x`: - [[scout] adding unit tests (#204567)](#204567) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Dzmitry Lemechko","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-19T16:36:07Z","message":"[scout] adding unit tests (#204567)\n\n## Summary\r\n\r\nAdding tests and making adjustments/fixes based on the findings.\r\n\r\nNote: no integration tests were added to verify servers start as it is\r\nmostly equal to `@kbn-test` functionality that has jest integration\r\ntests. We can add it later, when Scout has specific logic.\r\n\r\nHow to run: `node scripts/jest --config\r\npackages/kbn-scout/jest.config.js`\r\n\r\nScope:\r\n\r\n```\r\n PASS packages/kbn-scout/src/config/config.test.ts\r\n PASS packages/kbn-scout/src/config/loader/read_config_file.test.ts\r\n PASS packages/kbn-scout/src/config/utils/get_config_file.test.ts\r\n PASS packages/kbn-scout/src/config/utils/load_servers_config.test.ts\r\n PASS packages/kbn-scout/src/config/utils/save_scout_test_config.test.ts\r\n PASS packages/kbn-scout/src/playwright/config/create_config.test.ts\r\n PASS packages/kbn-scout/src/playwright/runner/config_validator.test.ts\r\n PASS packages/kbn-scout/src/playwright/runner/flags.test.ts\r\n PASS packages/kbn-scout/src/playwright/utils/runner_utils.test.ts\r\n PASS packages/kbn-scout/src/servers/flags.test.ts\r\n```","sha":"2ba3247526331ec152f2d1e236c40635e86b3ce3","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","test:scout"],"title":"[scout] adding unit tests","number":204567,"url":"https://github.com/elastic/kibana/pull/204567","mergeCommit":{"message":"[scout] adding unit tests (#204567)\n\n## Summary\r\n\r\nAdding tests and making adjustments/fixes based on the findings.\r\n\r\nNote: no integration tests were added to verify servers start as it is\r\nmostly equal to `@kbn-test` functionality that has jest integration\r\ntests. We can add it later, when Scout has specific logic.\r\n\r\nHow to run: `node scripts/jest --config\r\npackages/kbn-scout/jest.config.js`\r\n\r\nScope:\r\n\r\n```\r\n PASS packages/kbn-scout/src/config/config.test.ts\r\n PASS packages/kbn-scout/src/config/loader/read_config_file.test.ts\r\n PASS packages/kbn-scout/src/config/utils/get_config_file.test.ts\r\n PASS packages/kbn-scout/src/config/utils/load_servers_config.test.ts\r\n PASS packages/kbn-scout/src/config/utils/save_scout_test_config.test.ts\r\n PASS packages/kbn-scout/src/playwright/config/create_config.test.ts\r\n PASS packages/kbn-scout/src/playwright/runner/config_validator.test.ts\r\n PASS packages/kbn-scout/src/playwright/runner/flags.test.ts\r\n PASS packages/kbn-scout/src/playwright/utils/runner_utils.test.ts\r\n PASS packages/kbn-scout/src/servers/flags.test.ts\r\n```","sha":"2ba3247526331ec152f2d1e236c40635e86b3ce3"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204567","number":204567,"mergeCommit":{"message":"[scout] adding unit tests (#204567)\n\n## Summary\r\n\r\nAdding tests and making adjustments/fixes based on the findings.\r\n\r\nNote: no integration tests were added to verify servers start as it is\r\nmostly equal to `@kbn-test` functionality that has jest integration\r\ntests. We can add it later, when Scout has specific logic.\r\n\r\nHow to run: `node scripts/jest --config\r\npackages/kbn-scout/jest.config.js`\r\n\r\nScope:\r\n\r\n```\r\n PASS packages/kbn-scout/src/config/config.test.ts\r\n PASS packages/kbn-scout/src/config/loader/read_config_file.test.ts\r\n PASS packages/kbn-scout/src/config/utils/get_config_file.test.ts\r\n PASS packages/kbn-scout/src/config/utils/load_servers_config.test.ts\r\n PASS packages/kbn-scout/src/config/utils/save_scout_test_config.test.ts\r\n PASS packages/kbn-scout/src/playwright/config/create_config.test.ts\r\n PASS packages/kbn-scout/src/playwright/runner/config_validator.test.ts\r\n PASS packages/kbn-scout/src/playwright/runner/flags.test.ts\r\n PASS packages/kbn-scout/src/playwright/utils/runner_utils.test.ts\r\n PASS packages/kbn-scout/src/servers/flags.test.ts\r\n```","sha":"2ba3247526331ec152f2d1e236c40635e86b3ce3"}}]}] BACKPORT--> Co-authored-by: Dzmitry Lemechko <[email protected]>
## Summary Adding tests and making adjustments/fixes based on the findings. Note: no integration tests were added to verify servers start as it is mostly equal to `@kbn-test` functionality that has jest integration tests. We can add it later, when Scout has specific logic. How to run: `node scripts/jest --config packages/kbn-scout/jest.config.js` Scope: ``` PASS packages/kbn-scout/src/config/config.test.ts PASS packages/kbn-scout/src/config/loader/read_config_file.test.ts PASS packages/kbn-scout/src/config/utils/get_config_file.test.ts PASS packages/kbn-scout/src/config/utils/load_servers_config.test.ts PASS packages/kbn-scout/src/config/utils/save_scout_test_config.test.ts PASS packages/kbn-scout/src/playwright/config/create_config.test.ts PASS packages/kbn-scout/src/playwright/runner/config_validator.test.ts PASS packages/kbn-scout/src/playwright/runner/flags.test.ts PASS packages/kbn-scout/src/playwright/utils/runner_utils.test.ts PASS packages/kbn-scout/src/servers/flags.test.ts ```
## Summary Adding tests and making adjustments/fixes based on the findings. Note: no integration tests were added to verify servers start as it is mostly equal to `@kbn-test` functionality that has jest integration tests. We can add it later, when Scout has specific logic. How to run: `node scripts/jest --config packages/kbn-scout/jest.config.js` Scope: ``` PASS packages/kbn-scout/src/config/config.test.ts PASS packages/kbn-scout/src/config/loader/read_config_file.test.ts PASS packages/kbn-scout/src/config/utils/get_config_file.test.ts PASS packages/kbn-scout/src/config/utils/load_servers_config.test.ts PASS packages/kbn-scout/src/config/utils/save_scout_test_config.test.ts PASS packages/kbn-scout/src/playwright/config/create_config.test.ts PASS packages/kbn-scout/src/playwright/runner/config_validator.test.ts PASS packages/kbn-scout/src/playwright/runner/flags.test.ts PASS packages/kbn-scout/src/playwright/utils/runner_utils.test.ts PASS packages/kbn-scout/src/servers/flags.test.ts ```
## Summary Adding tests and making adjustments/fixes based on the findings. Note: no integration tests were added to verify servers start as it is mostly equal to `@kbn-test` functionality that has jest integration tests. We can add it later, when Scout has specific logic. How to run: `node scripts/jest --config packages/kbn-scout/jest.config.js` Scope: ``` PASS packages/kbn-scout/src/config/config.test.ts PASS packages/kbn-scout/src/config/loader/read_config_file.test.ts PASS packages/kbn-scout/src/config/utils/get_config_file.test.ts PASS packages/kbn-scout/src/config/utils/load_servers_config.test.ts PASS packages/kbn-scout/src/config/utils/save_scout_test_config.test.ts PASS packages/kbn-scout/src/playwright/config/create_config.test.ts PASS packages/kbn-scout/src/playwright/runner/config_validator.test.ts PASS packages/kbn-scout/src/playwright/runner/flags.test.ts PASS packages/kbn-scout/src/playwright/utils/runner_utils.test.ts PASS packages/kbn-scout/src/servers/flags.test.ts ```
## Summary Adding tests and making adjustments/fixes based on the findings. Note: no integration tests were added to verify servers start as it is mostly equal to `@kbn-test` functionality that has jest integration tests. We can add it later, when Scout has specific logic. How to run: `node scripts/jest --config packages/kbn-scout/jest.config.js` Scope: ``` PASS packages/kbn-scout/src/config/config.test.ts PASS packages/kbn-scout/src/config/loader/read_config_file.test.ts PASS packages/kbn-scout/src/config/utils/get_config_file.test.ts PASS packages/kbn-scout/src/config/utils/load_servers_config.test.ts PASS packages/kbn-scout/src/config/utils/save_scout_test_config.test.ts PASS packages/kbn-scout/src/playwright/config/create_config.test.ts PASS packages/kbn-scout/src/playwright/runner/config_validator.test.ts PASS packages/kbn-scout/src/playwright/runner/flags.test.ts PASS packages/kbn-scout/src/playwright/utils/runner_utils.test.ts PASS packages/kbn-scout/src/servers/flags.test.ts ```
Summary
Adding tests and making adjustments/fixes based on the findings.
Note: no integration tests were added to verify servers start as it is mostly equal to
@kbn-test
functionality that has jest integration tests. We can add it later, when Scout has specific logic.How to run:
node scripts/jest --config packages/kbn-scout/jest.config.js
Scope: