Skip to content
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

Merged
merged 9 commits into from
Dec 19, 2024
Merged

Conversation

dmlemeshko
Copy link
Member

@dmlemeshko dmlemeshko commented Dec 17, 2024

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

@@ -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) {
Copy link
Member Author

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';
Copy link
Member Author

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'),
Copy link
Member Author

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'),
Copy link
Member Author

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

@dmlemeshko dmlemeshko self-assigned this Dec 17, 2024
@dmlemeshko dmlemeshko added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting v9.0.0 test:scout labels Dec 17, 2024
@dmlemeshko dmlemeshko marked this pull request as ready for review December 17, 2024 12:55
@dmlemeshko dmlemeshko requested a review from a team as a code owner December 17, 2024 12:55
@dmlemeshko dmlemeshko enabled auto-merge (squash) December 17, 2024 17:14
@dmlemeshko dmlemeshko added backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) and removed backport:skip This commit does not require backporting labels Dec 18, 2024
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #70 / serverless search UI Serverless Inference Management UI delete action "before each" hook for "deletes modal successfully with usage"
  • [job] [logs] FTR Configs #2 / Spaces app space solution tour solution tour does not show the solution tour after deleting spaces and leave only the default

Metrics [docs]

✅ unchanged

History

cc @dmlemeshko

Copy link
Member

@pheyos pheyos left a 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);
});
});
Copy link
Member

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')

Copy link
Member Author

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

Copy link
Member Author

@dmlemeshko dmlemeshko Dec 19, 2024

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'

@dmlemeshko dmlemeshko merged commit 2ba3247 into elastic:main Dec 19, 2024
12 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12416890020

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 19, 2024
## 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)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Dec 19, 2024
## 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
```
kibanamachine added a commit that referenced this pull request Dec 19, 2024
# 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]>
stratoula pushed a commit to stratoula/kibana that referenced this pull request Jan 2, 2025
## 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
```
benakansara pushed a commit to benakansara/kibana that referenced this pull request Jan 2, 2025
## 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
```
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Jan 13, 2025
## 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
```
viduni94 pushed a commit to viduni94/kibana that referenced this pull request Jan 23, 2025
## 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
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes test:scout v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants