-
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 dashboard tests using elasticdump #7298
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
988be91
New dashboard tests using elasticdump
1333cbe
Add missing Dashboard test files.
53ede1a
Remove some unused vars.
ac4a0ed
Move updateConfigDoc method out of scenario_manager and into its own …
4ebe29e
Moved elasticdump methods from common to support/elastic_dump.js
f28fc89
Correct a dashboard test sub-suite name.
411bacd
Some cleanup from review comments.
1566cc3
Remove unused self.
9fe89d9
Removed un-used requires.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{".kibana":{"mappings":{"config":{"properties":{"buildNum":{"type":"keyword"}}},"index-pattern":{"properties":{"fields":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"timeFieldName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"title":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}},"search":{"properties":{"columns":{"type":"text"},"description":{"type":"text"},"hits":{"type":"integer"},"kibanaSavedObjectMeta":{"properties":{"searchSourceJSON":{"type":"text"}}},"sort":{"type":"text"},"title":{"type":"text"},"version":{"type":"integer"}}},"visualization":{"properties":{"description":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"kibanaSavedObjectMeta":{"properties":{"searchSourceJSON":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}},"title":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"uiStateJSON":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"version":{"type":"integer"},"visState":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}},"server":{"properties":{"uuid":{"type":"keyword"}}},"dashboard":{"properties":{"description":{"type":"text"},"hits":{"type":"integer"},"kibanaSavedObjectMeta":{"properties":{"searchSourceJSON":{"type":"text"}}},"optionsJSON":{"type":"text"},"panelsJSON":{"type":"text"},"timeFrom":{"type":"text"},"timeRestore":{"type":"boolean"},"timeTo":{"type":"text"},"title":{"type":"text"},"uiStateJSON":{"type":"text"},"version":{"type":"integer"}}}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import { | ||
bdd, | ||
common, | ||
dashboardPage, | ||
headerPage, | ||
scenarioManager, | ||
esClient, | ||
elasticDump | ||
} from '../../../support'; | ||
|
||
(function () { | ||
var expect = require('expect.js'); | ||
|
||
(function () { | ||
bdd.describe('dashboard tab', function describeIndexTests() { | ||
|
||
bdd.before(function () { | ||
|
||
var fromTime = '2015-09-19 06:31:44.000'; | ||
var toTime = '2015-09-23 18:31:44.000'; | ||
|
||
common.debug('Starting dashboard before method'); | ||
common.debug('navigateToApp dashboard'); | ||
return esClient.delete('.kibana') | ||
.then(function () { | ||
return common.try(function () { | ||
return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); | ||
}); | ||
}) | ||
// and load a set of makelogs data | ||
.then(function loadkibana4() { | ||
common.debug('load kibana index with visualizations'); | ||
return elasticDump.elasticLoad('dashboard','.kibana'); | ||
}) | ||
.then(function () { | ||
return scenarioManager.loadIfEmpty('logstashFunctional'); | ||
}) | ||
.then(function () { | ||
return common.navigateToApp('dashboard'); | ||
}) | ||
.catch(common.handleError(this)); | ||
}); | ||
|
||
|
||
bdd.describe('add visualizations to dashboard', function dashboardTest() { | ||
var visualizations = ['Visualization漢字 AreaChart', | ||
'Visualization☺漢字 DataTable', | ||
'Visualization漢字 LineChart', | ||
'Visualization PieChart', | ||
'Visualization TileMap', | ||
'Visualization☺ VerticalBarChart', | ||
'Visualization MetricChart' | ||
]; | ||
|
||
|
||
bdd.it('should be able to add visualizations to dashboard', function addVisualizations() { | ||
|
||
function addVisualizations(arr) { | ||
return arr.reduce(function (promise, vizName) { | ||
return promise | ||
.then(function () { | ||
return dashboardPage.addVisualization(vizName); | ||
}); | ||
}, Promise.resolve()); | ||
} | ||
|
||
return addVisualizations(visualizations) | ||
.then(function () { | ||
common.debug('done adding visualizations'); | ||
}); | ||
|
||
}); | ||
|
||
bdd.it('set the timepicker time to that which contains our test data', function setTimepicker() { | ||
var fromTime = '2015-09-19 06:31:44.000'; | ||
var toTime = '2015-09-23 18:31:44.000'; | ||
var testSubName = 'Dashboard Test 1'; | ||
|
||
// .then(function () { | ||
common.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); | ||
return headerPage.setAbsoluteRange(fromTime, toTime) | ||
.then(function sleep() { | ||
return common.sleep(4000); | ||
}) | ||
.then(function takeScreenshot() { | ||
common.debug('Take screenshot'); | ||
common.saveScreenshot('./screenshot-' + testSubName + '.png'); | ||
}) | ||
.catch(common.handleError(this)); | ||
}); | ||
|
||
bdd.it('should save and load dashboard', function saveAndLoadDashboard() { | ||
var testSubName = 'Dashboard Test 1'; | ||
// save time on the dashboard? | ||
return dashboardPage.saveDashboard(testSubName) | ||
// click New Dashboard just to clear the one we just created | ||
.then(function () { | ||
return dashboardPage.clickNewDashboard(); | ||
}) | ||
.then(function () { | ||
return dashboardPage.loadSavedDashboard(testSubName); | ||
}) | ||
.catch(common.handleError(this)); | ||
}); | ||
|
||
bdd.it('should have all the expected visualizations', function checkVisualizations() { | ||
return common.tryForTime(10000, function () { | ||
return dashboardPage.getPanelTitles() | ||
.then(function (panelTitles) { | ||
common.log('visualization titles = ' + panelTitles); | ||
expect(panelTitles).to.eql(visualizations); | ||
}); | ||
}) | ||
.catch(common.handleError(this)); | ||
}); | ||
|
||
bdd.it('should have all the expected initial sizes', function checkVisualizationSizes() { | ||
var visObjects = [ { dataCol: '1', dataRow: '1', dataSizeX: '3', dataSizeY: '2', title: 'Visualization漢字 AreaChart' }, | ||
{ dataCol: '4', dataRow: '1', dataSizeX: '3', dataSizeY: '2', title: 'Visualization☺漢字 DataTable' }, | ||
{ dataCol: '7', dataRow: '1', dataSizeX: '3', dataSizeY: '2', title: 'Visualization漢字 LineChart' }, | ||
{ dataCol: '10', dataRow: '1', dataSizeX: '3', dataSizeY: '2', title: 'Visualization PieChart' }, | ||
{ dataCol: '1', dataRow: '3', dataSizeX: '3', dataSizeY: '2', title: 'Visualization TileMap' }, | ||
{ dataCol: '4', dataRow: '3', dataSizeX: '3', dataSizeY: '2', title: 'Visualization☺ VerticalBarChart' }, | ||
{ dataCol: '7', dataRow: '3', dataSizeX: '3', dataSizeY: '2', title: 'Visualization MetricChart' } | ||
]; | ||
return common.tryForTime(10000, function () { | ||
return dashboardPage.getPanelData() | ||
.then(function (panelTitles) { | ||
common.log('visualization titles = ' + panelTitles); | ||
expect(panelTitles).to.eql(visObjects); | ||
}); | ||
}) | ||
.catch(common.handleError(this)); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
}()); | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { bdd, remote, scenarioManager, defaultTimeout } from '../../../support'; | ||
|
||
(function () { | ||
bdd.describe('dashboard app', function () { | ||
this.timeout = defaultTimeout; | ||
|
||
bdd.before(function () { | ||
return remote.setWindowSize(1200,800); | ||
}); | ||
|
||
require('./_dashboard'); | ||
}); | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { common, config} from './'; | ||
|
||
export default (function () { | ||
var util = require('util'); | ||
var path = require('path'); | ||
var url = require('url'); | ||
var resolve = require('path').resolve; | ||
var Elasticdump = require('elasticdump').elasticdump; | ||
|
||
function ElasticDump() { | ||
} | ||
|
||
ElasticDump.prototype = { | ||
constructor: ElasticDump, | ||
|
||
/* | ||
** This function is basically copied from | ||
** https://github.com/taskrabbit/elasticsearch-dump/blob/master/bin/elasticdump | ||
** and allows calling elasticdump for importing or exporting data from Elasticsearch | ||
*/ | ||
elasticdumpModule: function elasticdumpModule(myinput, myoutput, index, mytype) { | ||
var self = this; | ||
|
||
var options = { | ||
limit: 100, | ||
offset: 0, | ||
debug: false, | ||
type: mytype, | ||
delete: false, | ||
all: false, | ||
maxSockets: null, | ||
input: myinput, | ||
'input-index': null, | ||
output: myoutput, | ||
'output-index': index, | ||
inputTransport: null, | ||
outputTransport: null, | ||
searchBody: null, | ||
sourceOnly: false, | ||
jsonLines: false, | ||
format: '', | ||
'ignore-errors': false, | ||
scrollTime: '10m', | ||
timeout: null, | ||
skip: null, | ||
toLog: null, | ||
}; | ||
// common.debug(options); | ||
var dumper = new Elasticdump(options.input, options.output, options); | ||
|
||
dumper.on('log', function (message) { common.debug(message); }); | ||
// dumper.on('debug', function (message) { common.debug(message); }); | ||
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. can we remove the commented out code if it's not needed? here and on line 48 |
||
dumper.on('error', function (error) { common.debug('error', 'Error Emitted => ' + (error.message || JSON.stringify(error))); }); | ||
|
||
var promise = new Promise(function (resolve, reject) { | ||
dumper.dump(function (error, totalWrites) { | ||
if (error) { | ||
common.debug('THERE WAS AN ERROR :-('); | ||
reject(Error(error)); | ||
} else { | ||
resolve ('elasticdumpModule success'); | ||
} | ||
}); | ||
}); | ||
return promise; | ||
}, | ||
|
||
/* | ||
** Dumps data from Elasticsearch into json files. | ||
** Takes a simple filename as input like 'dashboard' (for dashboard tests). | ||
** Appends ''.mapping.json' and '.data.json' for the actual filenames. | ||
** Writes files to the Kibana root dir. | ||
** Fails if the files already exist, so consider appending a timestamp to filename. | ||
*/ | ||
elasticDump: function elasticDump(index, file) { | ||
var self = this; | ||
common.debug('Dumping mapping from ' + url.format(config.servers.elasticsearch) + '/' + index | ||
+ ' to (' + file + '.mapping.json)'); | ||
return this.elasticdumpModule(url.format(config.servers.elasticsearch), | ||
file + '.mapping.json', index, 'mapping') | ||
.then(function () { | ||
common.debug('Dumping data from ' + url.format(config.servers.elasticsearch) + '/' + index | ||
+ ' to (' + file + '.data.json)'); | ||
return self.elasticdumpModule(url.format(config.servers.elasticsearch), | ||
file + '.data.json', index, 'data'); | ||
}); | ||
}, | ||
|
||
/* | ||
** Loads data from json files into Elasticsearch. | ||
** Takes a simple filename as input like 'dashboard' (for dashboard tests). | ||
** Appends ''.mapping.json' and '.data.json' for the actual filenames. | ||
** Path /test/fixtures/dump_data is hard-coded | ||
*/ | ||
elasticLoad: function elasticLoad(file, index) { | ||
// TODO: should we have a flag to delete the index first? | ||
// or use scenarioManager.unload(index) ? <<- currently this | ||
var self = this; | ||
common.debug('Loading mapping (test/fixtures/dump_data/' + file + '.mapping.json) into ' | ||
+ url.format(config.servers.elasticsearch) + '/' + index); | ||
return this.elasticdumpModule('test/fixtures/dump_data/' + file + '.mapping.json', | ||
url.format(config.servers.elasticsearch), index, 'mapping') | ||
.then(function () { | ||
common.debug('Loading data (test/fixtures/dump_data/' + file + '.data.json) into ' | ||
+ url.format(config.servers.elasticsearch) + '/' + index); | ||
return self.elasticdumpModule('test/fixtures/dump_data/' + file + '.data.json', | ||
url.format(config.servers.elasticsearch), index, 'data'); | ||
}); | ||
}, | ||
}; | ||
|
||
return ElasticDump; | ||
}()); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 used