Skip to content

Commit

Permalink
[8.x] [ES|QL] Updates the validation tests (#195847) (#196188)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] Updates the validation tests
(#195847)](#195847)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-14T16:44:40Z","message":"[ES|QL]
Updates the validation tests (#195847)\n\n## Summary\r\n\r\nMoves the
CCS tests to its own file\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"36cf5ab5bb4d6512b06fa9b2b7e7f4383c223b3a","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","Feature:ES|QL","Team:ESQL","v8.16.0"],"title":"[ES|QL]
Updates the validation
tests","number":195847,"url":"https://github.com/elastic/kibana/pull/195847","mergeCommit":{"message":"[ES|QL]
Updates the validation tests (#195847)\n\n## Summary\r\n\r\nMoves the
CCS tests to its own file\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"36cf5ab5bb4d6512b06fa9b2b7e7f4383c223b3a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195847","number":195847,"mergeCommit":{"message":"[ES|QL]
Updates the validation tests (#195847)\n\n## Summary\r\n\r\nMoves the
CCS tests to its own file\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"36cf5ab5bb4d6512b06fa9b2b7e7f4383c223b3a"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <[email protected]>
  • Loading branch information
kibanamachine and stratoula authored Oct 14, 2024
1 parent df849c5 commit a90ae5e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ export const validationFromCommandTestSuite = (setup: helpers.Setup) => {
await expectErrors('fRoM in*ex', []);
await expectErrors('fRoM ind*ex', []);
await expectErrors('fRoM *,-.*', []);
await expectErrors('fRoM remote-*:indexes*', ['Unknown index [remote-*:indexes*]']);
await expectErrors('fRoM remote-*:indexes', ['Unknown index [remote-*:indexes]']);
await expectErrors('fRoM remote-ccs:indexes', ['Unknown index [remote-ccs:indexes]']);
await expectErrors('fRoM a_index, remote-ccs:indexes', [
'Unknown index [remote-ccs:indexes]',
]);
await expectErrors('fRoM .secret_index', []);
await expectErrors('from my-index', []);
});
Expand Down Expand Up @@ -151,16 +145,6 @@ export const validationFromCommandTestSuite = (setup: helpers.Setup) => {
[],
addBracketsWarning()
);
await expectErrors(
`from remote-ccs:indexes ${setWrapping('METADATA _id')}`,
['Unknown index [remote-ccs:indexes]'],
addBracketsWarning()
);
await expectErrors(
`from *:indexes ${setWrapping('METADATA _id')}`,
['Unknown index [*:indexes]'],
addBracketsWarning()
);
});

test('validates fields', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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';

describe('validation', () => {
describe('from command', () => {
describe('FROM <sources> [ METADATA <indices> ]', () => {
describe('... <sources> ...', () => {
test('display errors on unknown indices', async () => {
const { expectErrors } = await setup();
await expectErrors('fRoM remote-*:indexes*', ['Unknown index [remote-*:indexes*]']);
await expectErrors('fRoM remote-*:indexes', ['Unknown index [remote-*:indexes]']);
await expectErrors('fRoM remote-ccs:indexes', ['Unknown index [remote-ccs:indexes]']);
await expectErrors('fRoM a_index, remote-ccs:indexes', [
'Unknown index [remote-ccs:indexes]',
]);
});
});

describe('... METADATA <indices>', () => {
for (const isWrapped of [true, false]) {
function setWrapping(option: string) {
return isWrapped ? `[${option}]` : option;
}

function addBracketsWarning() {
return isWrapped
? ["Square brackets '[]' need to be removed from FROM METADATA declaration"]
: [];
}

describe(`wrapped = ${isWrapped}`, () => {
test('no errors on correct usage, waning on square brackets', async () => {
const { expectErrors } = await setup();
await expectErrors(
`from remote-ccs:indexes ${setWrapping('METADATA _id')}`,
['Unknown index [remote-ccs:indexes]'],
addBracketsWarning()
);
await expectErrors(
`from *:indexes ${setWrapping('METADATA _id')}`,
['Unknown index [*:indexes]'],
addBracketsWarning()
);
});
});
}
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9834,26 +9834,6 @@
"error": [],
"warning": []
},
{
"query": "fRoM remote-*:indexes*",
"error": [],
"warning": []
},
{
"query": "fRoM remote-*:indexes",
"error": [],
"warning": []
},
{
"query": "fRoM remote-ccs:indexes",
"error": [],
"warning": []
},
{
"query": "fRoM a_index, remote-ccs:indexes",
"error": [],
"warning": []
},
{
"query": "fRoM .secret_index",
"error": [],
Expand Down Expand Up @@ -9986,20 +9966,6 @@
"Square brackets '[]' need to be removed from FROM METADATA declaration"
]
},
{
"query": "from remote-ccs:indexes [METADATA _id]",
"error": [],
"warning": [
"Square brackets '[]' need to be removed from FROM METADATA declaration"
]
},
{
"query": "from *:indexes [METADATA _id]",
"error": [],
"warning": [
"Square brackets '[]' need to be removed from FROM METADATA declaration"
]
},
{
"query": "from index [METADATA _id, _source2]",
"error": [
Expand Down Expand Up @@ -10038,16 +10004,6 @@
"error": [],
"warning": []
},
{
"query": "from remote-ccs:indexes METADATA _id",
"error": [],
"warning": []
},
{
"query": "from *:indexes METADATA _id",
"error": [],
"warning": []
},
{
"query": "from index METADATA _id, _source2",
"error": [
Expand Down

0 comments on commit a90ae5e

Please sign in to comment.