-
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
Allow histogram fields in average and sum aggregations #66891
Changes from all commits
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 |
---|---|---|
|
@@ -24,37 +24,62 @@ export default function({ getService, getPageObjects }: FtrProviderContext) { | |
return esArchiver.unload('pre_calculated_histogram'); | ||
}); | ||
|
||
const initHistogramBarChart = async () => { | ||
await PageObjects.visualize.navigateToNewVisualization(); | ||
await PageObjects.visualize.clickVerticalBarChart(); | ||
await PageObjects.visualize.clickNewSearch('histogram-test'); | ||
await PageObjects.visChart.waitForVisualization(); | ||
}; | ||
|
||
const getFieldOptionsForAggregation = async (aggregation: string): Promise<string[]> => { | ||
await PageObjects.visEditor.clickBucket('Y-axis', 'metrics'); | ||
await PageObjects.visEditor.selectAggregation(aggregation, 'metrics'); | ||
const fieldValues = await PageObjects.visEditor.getField(); | ||
return fieldValues; | ||
}; | ||
|
||
it('appears correctly in discover', async function() { | ||
await PageObjects.common.navigateToApp('discover'); | ||
const rowData = await PageObjects.discover.getDocTableIndex(1); | ||
expect(rowData.includes('"values": [ 0.3, 1, 3, 4.2, 4.8 ]')).to.be.ok(); | ||
}); | ||
|
||
it('appears in the field options of a Percentiles aggregation', async function() { | ||
await initHistogramBarChart(); | ||
const fieldValues: string[] = await getFieldOptionsForAggregation('Percentiles'); | ||
log.debug('Percentiles Fields = ' + fieldValues); | ||
expect(fieldValues[0]).to.be('histogram-content'); | ||
}); | ||
describe('works in visualizations', () => { | ||
before(async () => { | ||
await PageObjects.visualize.navigateToNewVisualization(); | ||
await PageObjects.visualize.clickDataTable(); | ||
await PageObjects.visualize.clickNewSearch('histogram-test'); | ||
await PageObjects.visChart.waitForVisualization(); | ||
await PageObjects.visEditor.clickMetricEditor(); | ||
}); | ||
|
||
const renderTableForAggregation = async (aggregation: string) => { | ||
await PageObjects.visEditor.selectAggregation(aggregation, 'metrics'); | ||
await PageObjects.visEditor.selectField('histogram-content', 'metrics'); | ||
await PageObjects.visEditor.clickGo(); | ||
|
||
return await PageObjects.visChart.getTableVisContent(); | ||
}; | ||
|
||
it('with percentiles aggregation', async () => { | ||
const data = (await renderTableForAggregation('Percentiles')) as string[][]; | ||
expect(data[0]).to.have.property('length', 7); | ||
// Percentile values are not deterministic, so we can't check for the exact values here, | ||
// but just check they are all within the given range | ||
// see https://github.com/elastic/elasticsearch/issues/49225 | ||
expect(data[0].every((p: string) => Number(p) >= 0.3 && Number(p) <= 5)).to.be(true); | ||
}); | ||
|
||
it('with percentile ranks aggregation', async () => { | ||
const data = await renderTableForAggregation('Percentile Ranks'); | ||
expect(data).to.eql([['0%']]); | ||
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. Nit: This test would be more helpful if it would test a different percentile rank than the default 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. Going to ignore this for now, since the the Percentile Ranks has the same non-deterministic problem than the others, so will rather fix that as soon as that's solved. |
||
}); | ||
|
||
it('with average aggregation', async () => { | ||
const data = await renderTableForAggregation('Average'); | ||
expect(data).to.eql([['2.8510720308359434']]); | ||
}); | ||
|
||
it('with median aggregation', async () => { | ||
// Percentile values (which are used by median behind the scenes) are not deterministic, | ||
// so we can't check for the exact values here, but just check they are all within the given range | ||
// see https://github.com/elastic/elasticsearch/issues/49225 | ||
const data = await renderTableForAggregation('Median'); | ||
const value = Number(data[0][0]); | ||
expect(value).to.be.above(3.0); | ||
expect(value).to.be.below(3.3); | ||
}); | ||
|
||
it('appears in the field options of a Percentile Ranks aggregation', async function() { | ||
const fieldValues: string[] = await getFieldOptionsForAggregation('Percentile Ranks'); | ||
log.debug('Percentile Ranks Fields = ' + fieldValues); | ||
expect(fieldValues[0]).to.be('histogram-content'); | ||
it('with sum aggregation', async () => { | ||
const data = await renderTableForAggregation('Sum'); | ||
expect(data).to.eql([['11834.800000000001']]); | ||
}); | ||
}); | ||
}); | ||
} |
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.
Seems to be an extra wait, should work fine without it since the
clickNewSearch
is waiting forheader.waitUntilLoadingHasFinished();
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.
Better save then sorry ;)