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

New scripted field tests #9242

Merged
merged 12 commits into from
Dec 20, 2016
Merged

New scripted field tests #9242

merged 12 commits into from
Dec 20, 2016

Conversation

LeeDr
Copy link

@LeeDr LeeDr commented Nov 29, 2016

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;

  1. expression
  2. painless number
  3. painless string
  4. painless boolean
  5. painless date

In each case we check that;

  1. we create the scripted field
  2. the script produces the expected result in the doc view of discover
  3. that we can filter by a value of the scripted field
  4. that we can click the Visualize button for the scripted field and get the expected results

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

@LeeDr LeeDr added the test label Nov 29, 2016
@tbragin tbragin added the Feature:Scripted Fields Scripted fields features label Nov 30, 2016
@LeeDr LeeDr changed the title [WIP] new scripted field tests New scripted field tests Dec 9, 2016
@LeeDr LeeDr added the review label Dec 9, 2016
@LeeDr LeeDr removed the review label Dec 9, 2016
@LeeDr
Copy link
Author

LeeDr commented Dec 9, 2016

Test failed so it's back on me...

@LeeDr LeeDr added the review label Dec 9, 2016
@LeeDr
Copy link
Author

LeeDr commented Dec 9, 2016

Setting the timezone to UTC and fixing the expected results to that fixed the previous failures.

@Bargs Bargs self-requested a review December 9, 2016 18:26
@LeeDr
Copy link
Author

LeeDr commented Dec 9, 2016

These tests do not currently sort by scripted fields. Are we talking about on the Discover tab in the doc list?

@Bargs
Copy link
Contributor

Bargs commented Dec 9, 2016

Yep, on discover or a saved search in a dashboard I think

@Bargs
Copy link
Contributor

Bargs commented Dec 12, 2016

@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?

Copy link
Contributor

@Bargs Bargs left a 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();
Copy link
Contributor

Choose a reason for hiding this comment

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

All vars should be updated to const or let


bdd.describe('creating and using Painless numeric scripted fields', function describeIndexTests() {

const scriptedExpressionFieldName = 'ram_expr1';
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused const

Copy link
Author

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();
}
Copy link
Contributor

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?

Copy link
Author

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();
}
Copy link
Contributor

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()"]')
Copy link
Contributor

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.

Copy link
Author

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"]')
Copy link
Contributor

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.

Copy link
Author

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')
Copy link
Contributor

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.

Copy link
Author

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.

@LeeDr
Copy link
Author

LeeDr commented Dec 13, 2016

I'm going to try adding sort to the tests. Meanwhile I'll let jenkins have another pass at them as-is.

@tbragin
Copy link
Contributor

tbragin commented Dec 14, 2016

Thanks for working on this @LeeDr and @Bargs !

@LeeDr
Copy link
Author

LeeDr commented Dec 15, 2016

@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.

@LeeDr
Copy link
Author

LeeDr commented Dec 16, 2016

FYI, test output;

>> PASS: chrome on any platform - kibana - settings app - creating and using Lucence expression scripted fields - should create scripted field (4981ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Lucence expression scripted fields - should see scripted field value in Discover (9050ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Lucence expression scripted fields - should filter by scripted field value in Discover (865ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Lucence expression scripted fields - should visualize scripted field in vertical bar chart (1625ms)
>> 0/4 tests failed

>> PASS: chrome on any platform - kibana - settings app - creating and using Painless numeric scripted fields - should create scripted field (4849ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless numeric scripted fields - should see scripted field value in Discover (8710ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless numeric scripted fields - should filter by scripted field value in Discover (954ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless numeric scripted fields - should visualize scripted field in vertical bar chart (1333ms)
>> 0/4 tests failed

>> PASS: chrome on any platform - kibana - settings app - creating and using Painless string scripted fields - should create scripted field (5092ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless string scripted fields - should see scripted field value in Discover (8658ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless string scripted fields - should filter by scripted field value in Discover (1047ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless string scripted fields - should visualize scripted field in vertical bar chart (895ms)
>> 0/4 tests failed

>> PASS: chrome on any platform - kibana - settings app - creating and using Painless boolean scripted fields - should create scripted field (4955ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless boolean scripted fields - should see scripted field value in Discover (8797ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless boolean scripted fields - should filter by scripted field value in Discover (2399ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless boolean scripted fields - should visualize scripted field in vertical bar chart (1019ms)
>> 0/4 tests failed

>> PASS: chrome on any platform - kibana - settings app - creating and using Painless date scripted fields - should create scripted field (5487ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless date scripted fields - should see scripted field value in Discover (6812ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless date scripted fields - should filter by scripted field value in Discover (650ms)
>> PASS: chrome on any platform - kibana - settings app - creating and using Painless date scripted fields - should visualize scripted field in vertical bar chart (898ms)
>> 0/4 tests failed

@Bargs
Copy link
Contributor

Bargs commented Dec 20, 2016

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.

@LeeDr LeeDr merged commit 0cbec2c into elastic:master Dec 20, 2016
elastic-jasper added a commit that referenced this pull request Dec 20, 2016
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
LeeDr pushed a commit that referenced this pull request Jan 2, 2017
* 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
@LeeDr LeeDr deleted the scriptedFieldTests branch May 23, 2017 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants