-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Async Discover search test #64388
Changes from 23 commits
11628db
674130c
421d7db
64c3150
ad9e362
ad80789
8530255
e3fa31c
13b4462
6d2178a
8413697
46538a8
fdccf5c
dcb02d9
e501378
48a1f24
4672fd4
208ba76
72b15a9
0348d9b
aa58dc9
169c36e
c238e60
2a0d480
4afcc20
615a85f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,121 @@ | ||||
/* | ||||
* 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"}', | ||||
}); | ||||
}); | ||||
|
||||
after(async function afterAll() { | ||||
await kibanaServer.uiSettings.replace({}); | ||||
await kibanaServer.uiSettings.update({}); | ||||
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||
await esArchiver.unload('logstash_functional'); | ||||
await esArchiver.load('empty_kibana'); | ||||
}); | ||||
|
||||
it('query should show failed shards pop up', async function () { | ||||
/* 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 } " | ||||
// ); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, makes sense to keeps this here |
||||
|
||||
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 () { | ||||
// 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 | ||||
// ); | ||||
// }); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just wonder if it would make sense, extracting these code into helper functions, uncommenting the usage of those? |
||||
|
||||
// await PageObjects.common.navigateToApp('discover'); | ||||
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'); | ||||
}); | ||||
}); | ||||
}); | ||||
} |
There was a problem hiding this comment.
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
kibana/test/functional/page_objects/time_picker.ts
Line 58 in 3ee0bf2