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

Async Discover search test #64388

Merged
merged 26 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
11628db
add x-pack test for discover async search with scripted field
Apr 23, 2020
674130c
one test for failed shards and one that *should* work but fails on BC8
Apr 23, 2020
421d7db
speed up setScriptedFieldScript by 20 sec for most cases
Apr 23, 2020
64c3150
use index pattern with scripted fields from esArchive
Apr 24, 2020
ad9e362
merge
Apr 29, 2020
ad80789
enable test for failed shards
Apr 30, 2020
8530255
Merge branch 'master' into asyncSearchTest
elasticmachine Apr 30, 2020
e3fa31c
added more to esArchive files to eliminate steps from test
May 8, 2020
13b4462
Merge branch 'asyncSearchTest' of github.com:LeeDr/kibana into asyncS…
May 8, 2020
6d2178a
Merge branch 'master' of github.com:elastic/kibana into asyncSearchTest
May 8, 2020
8413697
Merge branch 'master' into asyncSearchTest
elasticmachine May 8, 2020
46538a8
Merge branch 'master' into asyncSearchTest
elasticmachine May 13, 2020
fdccf5c
Merge branch 'master' into asyncSearchTest
elasticmachine May 15, 2020
dcb02d9
Merge branch 'master' into asyncSearchTest
elasticmachine Jun 23, 2020
e501378
Merge branch 'master' of github.com:elastic/kibana into asyncSearchTest
Jun 23, 2020
48a1f24
fix lint errors
Jun 23, 2020
4672fd4
Merge branch 'master' of github.com:elastic/kibana into asyncSearchTest
Jun 23, 2020
208ba76
remove prefer_v2_templates: true
Jun 23, 2020
72b15a9
Merge branch 'asyncSearchTest' of github.com:LeeDr/kibana into asyncS…
Jun 23, 2020
0348d9b
delete bad yarn.lock file
Jun 24, 2020
aa58dc9
Merge branch 'master' of github.com:elastic/kibana into asyncSearchTest
Jun 24, 2020
169c36e
restore yarn.lock file
Jun 24, 2020
c238e60
Merge branch 'master' into asyncSearchTest
elasticmachine Jun 24, 2020
2a0d480
Merge branch 'master' into asyncSearchTest
elasticmachine Jun 29, 2020
4afcc20
un-commented the setup code but put it in unreachable condition
Jun 29, 2020
615a85f
Merge branch 'asyncSearchTest' of github.com:LeeDr/kibana into asyncS…
Jun 29, 2020
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
6 changes: 4 additions & 2 deletions test/functional/page_objects/settings_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,10 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider
async setScriptedFieldScript(script: string) {
log.debug('set scripted field script = ' + script);
const aceEditorCssSelector = '[data-test-subj="editorFieldScript"] .ace_editor';
await find.clickByCssSelector(aceEditorCssSelector);
for (let i = 0; i < 1000; i++) {
const editor = await find.byCssSelector(aceEditorCssSelector);
await editor.click();
const existingText = await editor.getVisibleText();
for (let i = 0; i < existingText.length; i++) {
await browser.pressKeys(browser.keys.BACK_SPACE);
}
await browser.pressKeys(...script.split(''));
Expand Down
124 changes: 124 additions & 0 deletions x-pack/test/functional/apps/discover/async_scripted_fields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

// Tests for scripted field in default distribution where async search is used
import expect from '@kbn/expect';

export default function ({ getService, getPageObjects }) {
const kibanaServer = getService('kibanaServer');
// const log = getService('log');
const retry = getService('retry');
const esArchiver = getService('esArchiver');
const log = getService('log');
const testSubjects = getService('testSubjects');

const PageObjects = getPageObjects(['common', 'settings', 'discover', 'timePicker']);
const queryBar = getService('queryBar');

describe('async search with scripted fields', function () {
this.tags(['skipFirefox']);

before(async function () {
await esArchiver.load('kibana_scripted_fields_on_logstash');
await esArchiver.loadIfNeeded('logstash_functional');
// changing the timepicker default here saves us from having to set it in Discover (~8s)
await kibanaServer.uiSettings.update({
'timepicker:timeDefaults':
'{ "from": "Sep 18, 2015 @ 19:37:13.000", "to": "Sep 23, 2015 @ 02:30:09.000"}',
});
Comment on lines +27 to +31
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is nice, imagine how much time would be saved if we regularly do it that way. which reminds me, I recently created a helper for that, in the TimePickerProvider, but it's using a different start, end time

async setDefaultAbsoluteRangeViaUiSettings() {

});

after(async function afterAll() {
await kibanaServer.uiSettings.replace({});
await kibanaServer.uiSettings.update({});
Comment on lines +35 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a question, there is no way to replace a single uiSetting ? just asking because of

async resetDefaultAbsoluteRangeViaUiSettings() {

await esArchiver.unload('logstash_functional');
await esArchiver.load('empty_kibana');
});

it('query should show failed shards pop up', async function () {
if (false) {
/* If you had to modify the scripted fields, you could un-comment all this, run it, use es_archiver to update 'kibana_scripted_fields_on_logstash'
*/
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.createIndexPattern('logsta');
await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
await PageObjects.settings.addScriptedField(
'sharedFail',
'painless',
'string',
null,
'1',
// Scripted field below with multiple string checking actually should cause share failure message
// bcause it's not checking if all the fields it uses exist in each doc (and they don't)
"if (doc['response.raw'].value == '200') { return 'good ' + doc['url.raw'].value } else { return 'bad ' + doc['machine.os.raw'].value } "
);
}

await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern('logsta*');

await retry.tryForTime(20000, async function () {
// wait for shards failed message
const shardMessage = await testSubjects.getVisibleText('euiToastHeader');
log.debug(shardMessage);
expect(shardMessage).to.be('1 of 3 shards failed');
});
});

it('query return results with valid scripted field', async function () {
if (false) {
/* the commented-out steps below were used to create the scripted fields in the logstash-* index pattern
which are now saved in the esArchive.
*/

await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
const startingCount = parseInt(await PageObjects.settings.getScriptedFieldsTabCount());
await PageObjects.settings.clickScriptedFieldsTab();
await log.debug('add scripted field');
await PageObjects.settings.addScriptedField(
'goodScript',
'painless',
'string',
null,
'1',
// Scripted field below with should work
"if (doc['response.raw'].value == '200') { if (doc['url.raw'].size() > 0) { return 'good ' + doc['url.raw'].value } else { return 'good' } } else { if (doc['machine.os.raw'].size() > 0) { return 'bad ' + doc['machine.os.raw'].value } else { return 'bad' } }"
);
await retry.try(async function () {
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(
startingCount + 1
);
});

await PageObjects.settings.addScriptedField(
'goodScript2',
'painless',
'string',
null,
'1',
// Scripted field below which should work
"if (doc['url.raw'].size() > 0) { String tempString = \"\"; for ( int i = (doc['url.raw'].value.length() - 1); i >= 0 ; i--) { tempString = tempString + (doc['url.raw'].value).charAt(i); } return tempString; } else { return \"emptyUrl\"; }"
);
await retry.try(async function () {
expect(parseInt(await PageObjects.settings.getScriptedFieldsTabCount())).to.be(
startingCount + 2
);
});
}

await PageObjects.discover.selectIndexPattern('logstash-*');
await queryBar.setQuery('php* OR *jpg OR *css*');
await testSubjects.click('querySubmitButton');
await retry.tryForTime(30000, async function () {
expect(await PageObjects.discover.getHitCount()).to.be('13,301');
});
});
});
}
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function ({ loadTestFile }: FtrProviderContext) {

loadTestFile(require.resolve('./feature_controls'));
loadTestFile(require.resolve('./preserve_url'));
loadTestFile(require.resolve('./async_scripted_fields'));
loadTestFile(require.resolve('./reporting'));
});
}
Binary file not shown.
Loading