-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[ES|QL] Validation tests agains Elasticsearch #270445
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
Open
bartoval
wants to merge
21
commits into
elastic:main
Choose a base branch
from
bartoval:validation-tests-es
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4747623
validation tests again ES
bartoval f773273
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine 1b3af55
refactor
bartoval dfd9f85
Merge branch 'main' into validation-tests-es
bartoval 231d877
fix ci errors
bartoval 0e3ccb1
Run client-side validator live in integration tests
bartoval 1221080
Merge branch 'main' into validation-tests-es
bartoval a58f9b5
fix typo
bartoval 4e80467
Add validation Jest integration coverage
bartoval 521eb55
Merge branch 'main' into validation-tests-es
bartoval d5d8506
refactor
bartoval 6e8e64c
wiring unit tests
bartoval eb56889
Merge branch 'main' into validation-tests-es
bartoval c137f37
cleanup
bartoval 278bb7d
Merge branch 'main' into validation-tests-es
bartoval c472c97
remove JSON generation from validation.test.ts and FRT tests
bartoval 4fc78f3
pilot migration of validation.tests.ts
bartoval ff5ef4c
Changes from node scripts/lint_ts_projects --fix
kibanamachine 8270329
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine 85496fa
avoid validation redoundancy in file names
bartoval cb72f2a
Merge branch 'main' into validation-tests-es
stratoula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/platform/packages/shared/kbn-esql-language/jest.integration.config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| module.exports = { | ||
| preset: '@kbn/test/jest_integration_node', | ||
| rootDir: '../../../../..', | ||
| roots: ['<rootDir>/src/platform/packages/shared/kbn-esql-language'], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ages/shared/kbn-esql-language/src/language/validation/__tests__/column_existence_suite.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import { times } from 'lodash'; | ||
| import type { Setup } from './helpers'; | ||
|
|
||
| export const runColumnExistenceValidationSuite = (setup: Setup) => { | ||
| describe('column existence checks', () => { | ||
| it('looks behind current command', async () => { | ||
| const { expectErrors } = await setup(); | ||
| await expectErrors('FROM index | DROP keywordField | KEEP keywordField', [ | ||
| 'Unknown column "keywordField"', | ||
| ]); | ||
| }); | ||
|
|
||
| it('treats FORK branches separately', async () => { | ||
| const { expectErrors } = await setup(); | ||
| await expectErrors('FROM index | FORK (DROP keywordField) (KEEP keywordField)', []); | ||
| }); | ||
|
|
||
| it('makes STATS generated columns available after inline WHERE filters', async () => { | ||
| const { expectErrors } = await setup(); | ||
| await expectErrors( | ||
| 'FROM index | STATS COUNT() WHERE integerField > 0 | EVAL result = `COUNT() WHERE integerField > 0` + 1', | ||
| [] | ||
| ); | ||
| }); | ||
|
|
||
| it('returns a warning instead of an error when unmapped_fields is LOAD or NULLIFY', async () => { | ||
| const { expectErrors } = await setup(); | ||
| await expectErrors( | ||
| 'SET unmapped_fields = "LOAD"; FROM index | WHERE unmapped == ""', | ||
| [], | ||
| [ | ||
| `"unmapped" column isn't mapped in any searched indices.\nIf you are not intentionally referencing an unmapped field,\ncheck that the field exists or that it is spelled correctly in your query.`, | ||
| ] | ||
| ); | ||
| }); | ||
|
|
||
| it('returns one warning for each instance of the same unmapped column', async () => { | ||
| const { expectErrors } = await setup(); | ||
| await expectErrors( | ||
| 'SET unmapped_fields = "LOAD"; FROM index | WHERE unmapped == "" | KEEP unmapped', | ||
| [], | ||
|
|
||
| times( | ||
| 2, | ||
| () => | ||
| `"unmapped" column isn't mapped in any searched indices.\nIf you are not intentionally referencing an unmapped field,\ncheck that the field exists or that it is spelled correctly in your query.` | ||
| ) | ||
| ); | ||
| }); | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...kages/shared/kbn-esql-language/src/language/validation/__tests__/commands_license.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import { setup } from './helpers'; | ||
| import { runValidationCommandsLicenseSuite } from './commands_license_suite'; | ||
|
|
||
| runValidationCommandsLicenseSuite(setup); |
36 changes: 36 additions & 0 deletions
36
...ages/shared/kbn-esql-language/src/language/validation/__tests__/commands_license_suite.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import type { Setup } from './helpers'; | ||
|
|
||
| export const runValidationCommandsLicenseSuite = (setup: Setup) => { | ||
| describe('Command license validation', () => { | ||
| it('Should allows licensed commands when user has required license', async () => { | ||
| const { expectErrors, callbacks } = await setup(); | ||
|
|
||
| callbacks.getLicense = jest.fn(async () => ({ | ||
| hasAtLeast: (license?: string) => license?.toLowerCase() === 'platinum', | ||
| })); | ||
|
|
||
| await expectErrors('FROM a_index | CHANGE_POINT doubleField', []); | ||
| }); | ||
|
|
||
| it('should blocks licensed commands when user lacks required license', async () => { | ||
| const { expectErrors, callbacks } = await setup(); | ||
|
|
||
| callbacks.getLicense = jest.fn(async () => ({ | ||
| hasAtLeast: (license?: string) => license?.toLowerCase() !== 'platinum', | ||
| })); | ||
|
|
||
| await expectErrors('FROM a_index | CHANGE_POINT doubleField', [ | ||
| 'CHANGE_POINT requires a PLATINUM license.', | ||
| ]); | ||
| }); | ||
| }); | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.