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

[8.x] [ES|QL] Updates the validation tests (#195847) #196188

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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