-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7298 from LeeDr/dashboardTests
New dashboard tests using elasticdump
- Loading branch information
Showing
13 changed files
with
578 additions
and
8 deletions.
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,109 @@ | ||
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 = { | ||
|
||
/* | ||
** 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 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, | ||
}; | ||
var dumper = new Elasticdump(options.input, options.output, options); | ||
|
||
dumper.on('log', function (message) { common.debug(message); }); | ||
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.