-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
New scripted field tests #9242
New scripted field tests #9242
Conversation
Test failed so it's back on me... |
Setting the timezone to UTC and fixing the expected results to that fixed the previous failures. |
These tests do not currently sort by scripted fields. Are we talking about on the Discover tab in the doc list? |
Yep, on discover or a saved search in a dashboard I think |
@LeeDr the first time I ran the tests I got one error: https://gist.github.com/Bargs/4e63087c383d26bace3bc88168bea41e The second time I ran them everything passed. I wonder if there's some timing issue in that test? |
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.
This looks like a great start for scripted field tests. I left some minor comments but for the most part the code seems to be in good shape!
I'll make some suggestions for additional things we could test. I don't think there's any reason to hold up this PR, I'm just thinking out loud for the future.
- Date and boolean type painless fields. These could really benefit from testing since they're brand new. There was already one bug with filtering on booleans.
- Sorting by all scripted field types on Discover
- Adding filters on scripted fields by clicking on the charts in Visualize
- Adding a range filter by brushing on a histogram based on scripted field
- Test scripted fields in each of the different agg types. Different aggs use scripts differently, for instance significant terms doesn't support them at all
- Ensure that only painless and expression languages are available once Limit scripted fields to painless and expression langs #9172 is merged
- Ensure chart labels are built correctly for scripted fields
await PageObjects.visualize.waitForVisualization(); | ||
await PageObjects.visualize.collapseChart(); | ||
await PageObjects.settings.setPageSize('All'); | ||
var data = await PageObjects.visualize.getDataTableData(); |
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.
All var
s should be updated to const
or let
|
||
bdd.describe('creating and using Painless numeric scripted fields', function describeIndexTests() { | ||
|
||
const scriptedExpressionFieldName = 'ram_expr1'; |
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.
Unused const
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.
fixed
clickFieldListItemVisualize(field) { | ||
return this.findTimeout | ||
.findByCssSelector('li[attr-field="' + field + '"] > a').click(); | ||
} |
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.
This and the method above feel a little too generic, I'd worry about them breaking if we add another link or button. Maybe add data-test-subj attributes for these too?
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.
I didn't fix this. Yes, I agree we need a lot more data-test-subjs. I'd like to get these tests in and have another PR for adding data-test-subjs and using them in the tests.
disableFilter(field) { | ||
return PageObjects.common.findTestSubject('disableFilter-' + field) | ||
.click(); | ||
} |
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.
Can we just remove these if they don't work?
.click() | ||
.then(() => { | ||
return this.findTimeout | ||
.findByCssSelector('a[ng-click="removeAll()"]') |
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.
I wouldn't rely on ng-click values, these could very easily change in the future.
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.
I'd like to get these tests in and have another PR for adding data-test-subjs and using them in the tests.
setScriptedFieldScript(script) { | ||
PageObjects.common.debug('set scripted field script = ' + script); | ||
return this.remote.setFindTimeout(defaultFindTimeout) | ||
.findByCssSelector('textarea[ng-model="editor.field.script"]') |
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.
As with ng-click, I'm worried about relying on ng-model in the selectors here. A simple change in the angular code could break these.
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.
I'd like to get these tests in and have another PR for adding data-test-subjs and using them in the tests.
@@ -565,12 +565,12 @@ export default class VisualizePage { | |||
.then(function getRect() { | |||
return self | |||
.setFindTimeout(defaultFindTimeout) | |||
.findByCssSelector('rect.background') | |||
.findByCssSelector('div.chart-wrapper > div.chart > svg') |
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.
Not sure what this change is for? This method doesn't appear to be used in the scripted field tests.
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.
I reverted that change. Not sure what made me make the initial change. Must have been a problem when running the whole test suite. But it passed for me now without that change.
I'm going to try adding sort to the tests. Meanwhile I'll let jenkins have another pass at them as-is. |
@Bargs I think I know what you had a test failure at one point. Most of our tests delete the .kibana index and let Kibana re-create it, and then we also set the timezone to UTC by updating the config doc directly. But depending on what you do next in Kibana (like create a new index pattern) it can write it's config doc again and clobber the timezone setting we wrote. So I added an after method to the _kibana_settings test suite to set it back to UTC when those tests are done. It doesn't really solve the issue, but works. |
FYI, test output;
|
LGTM. One small request. In the future, when you want to make a big refactoring like this change to async/await could you do that in a separate PR or at least a separate commit? All of the additional noise makes it really difficult to verify the intended fix. And since there's always a chance a refactoring could break something, it adds a lot of unrelated code to review. |
Backports PR #9242 **Commit 1:** [WIP] new scripted field tests * Original sha: 6440101 * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-11-29T14:33:58Z **Commit 2:** Merge branch 'master' into scriptedFieldTests * Original sha: 4590fcb * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-08T19:39:57Z **Commit 3:** Final improvements on 12 new tests for 1 expression and 2 painless scripted fields * Original sha: 7e85c64 * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-09T04:48:45Z **Commit 4:** Add try loops around testing first Discover doc * Original sha: 8dfab84 * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-09T15:50:50Z **Commit 5:** Set timezone to UTC and adjusted data accordingly * Original sha: 78018ad * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-09T17:23:31Z **Commit 6:** Merge branch 'master' into scriptedFieldTests * Original sha: 75eb350 * Authored by Spencer <spalger@users.noreply.github.com> on 2016-12-13T18:13:54Z * Committed by GitHub <noreply@github.com> on 2016-12-13T18:13:54Z **Commit 7:** Added boolean and date Painless scripted field types * Original sha: 1854ee3 * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-15T19:59:04Z **Commit 8:** Remove unused (non-working) methods * Original sha: c190cc5 * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-15T20:07:15Z **Commit 9:** Merge branch 'master' into scriptedFieldTests * Original sha: ca29b91 * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-15T20:08:47Z **Commit 10:** Fix lint error * Original sha: c4f3e6c * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-15T20:18:49Z **Commit 11:** Added several data-test-subj attributes and used them in the tests * Original sha: 0528a55 * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-16T22:28:01Z **Commit 12:** Reverting previous change to getBarChartData * Original sha: 047d912 * Authored by LeeDr <lee.drengenberg@elastic.co> on 2016-12-20T15:01:27Z
* new scripted field tests * Final improvements on 12 new tests for 1 expression and 2 painless scripted fields * Add try loops around testing first Discover doc * Set timezone to UTC and adjusted data accordingly * Added boolean and date Painless scripted field types * Remove unused (non-working) methods * Fix lint error * Added several data-test-subj attributes and used them in the tests * Reverting previous change to getBarChartData
As the comments in the new test/functional/apps/management/_scripted_fields.js describe, 12 new tests for scripted fields.
5 scripted fields are created;
In each case we check that;
The tests can't currently sort by the scripted fields in discover because the sort arrow doesn't show up until you mouse over and we don't have that functionality in our tests yet.
We also can't drag over a chart to filter.
We could probably click an element in a chart to filter, but none of our tests have tried that yet.
Closes #8594