forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes elastic#2377 - Migrate config from > GA
- Closes elastic#2377 - Added testing framework for server side tests - Fixed jshint - Added config migration - Added framework for server initialization
- Loading branch information
1 parent
caaca43
commit 2b98020
Showing
11 changed files
with
169 additions
and
18 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
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,30 @@ | ||
var config = require('../config'); | ||
var semver = require('semver'); | ||
var rcVersionRegex = /(\d+\.\d+\.\d+)\-rc(\d+)/i; | ||
|
||
module.exports = function (doc) { | ||
if (/beta|snapshot/i.test(doc._id)) return false; | ||
if (doc._id === config.package.version) return false; | ||
|
||
var packageVersion, packageRcRelease, version, rcRelease; | ||
packageRcRelease = rcRelease = Infinity; | ||
var matches = doc._id.match(rcVersionRegex); | ||
var packageMatches = config.package.version.match(rcVersionRegex); | ||
|
||
if (matches) { | ||
version = matches[1]; | ||
rcRelease = parseInt(matches[2], 10); | ||
} else { | ||
version = doc._id; | ||
} | ||
|
||
if (packageMatches) { | ||
packageVersion = packageMatches[1]; | ||
packageRcRelease = parseInt(packageMatches[2], 10); | ||
} else { | ||
packageVersion = config.package.version; | ||
} | ||
|
||
if (semver.gte(version, packageVersion) && rcRelease >= packageRcRelease) return false; | ||
return true; | ||
}; |
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,29 @@ | ||
var config = require('../config'); | ||
var elasticsearch = require('elasticsearch'); | ||
var upgrade = require('./upgradeConfig'); | ||
var client = new elasticsearch.Client({ | ||
host: config.elasticsearch | ||
}); | ||
|
||
module.exports = function () { | ||
var options = { | ||
index: '.kibana', | ||
type: 'config', | ||
body: { | ||
size: 1000, | ||
sort: [ { buildNum: { order: 'desc' } } ], | ||
query: { | ||
filtered: { | ||
filter: { | ||
bool: { | ||
must_not: [ { query: { match: { _id: '@@version' } } } ] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
return client.search(options).then(upgrade); | ||
}; | ||
|
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,10 @@ | ||
var Promise = require('bluebird'); | ||
var migrateConfig = require('./migrateConfig'); | ||
|
||
module.exports = function () { | ||
var tasks = [ | ||
migrateConfig() | ||
]; | ||
|
||
return Promise.all(tasks); | ||
}; |
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,28 @@ | ||
var Promise = require('bluebird'); | ||
var isUpgradeable = require('./isUpgradeable'); | ||
var config = require('../config'); | ||
var _ = require('lodash'); | ||
var elasticsearch = require('elasticsearch'); | ||
var client = new elasticsearch.Client({ | ||
host: config.elasticsearch | ||
}); | ||
|
||
module.exports = function (response) { | ||
var newConfig = {}; | ||
// Check to see if there are any doc. If not then we can assume | ||
// nothing needs to be done | ||
if (response.hits.hits.length === 0) return Promise.resolve(null); | ||
|
||
// Look for upgradeable configs. If none of them are upgradeable | ||
// then resolve with null. | ||
var body = _.find(response.hits.hits, isUpgradeable); | ||
if (body) return Promise.resolve(null); | ||
|
||
return client.create({ | ||
index: '.kibana', | ||
type: 'config', | ||
id: config.package.version, | ||
body: body | ||
}); | ||
|
||
}; |
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,8 @@ | ||
module.exports = { | ||
options: { | ||
timeout: 2000, | ||
ignoreLeaks: false, | ||
reporter: 'dot' | ||
}, | ||
all: { src: ['<%= root %>/test/server/unit/**/*.js']} | ||
}; |
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,27 @@ | ||
var isUpgradeable = require('../../../../src/server/lib/isUpgradeable'); | ||
var expect = require('expect.js'); | ||
var util = require('util'); | ||
var package = require('../../../../package.json'); | ||
|
||
describe('lib/isUpgradeable', function () { | ||
|
||
function upgradeDoc(_id, version, bool) { | ||
it(util.format('should return %s for %s <= %s', bool, _id, version), function () { | ||
var doc = { _id: _id }; | ||
package.version = version; | ||
expect(isUpgradeable(doc)).to.be(bool); | ||
}); | ||
} | ||
|
||
upgradeDoc('1.0.0-beta1', package.version, false); | ||
upgradeDoc(package.version, package.version, false); | ||
upgradeDoc('4.0.0-RC1', '4.0.0-RC2', true); | ||
upgradeDoc('4.0.0-rc2', '4.0.0-rc1', false); | ||
upgradeDoc('4.0.0-rc2', '4.0.0', true); | ||
upgradeDoc('4.0.0-rc2', '4.0.2', true); | ||
upgradeDoc('4.0.1', '4.1.0-rc', true); | ||
upgradeDoc('4.0.0-rc1', '4.0.0', true); | ||
upgradeDoc('4.0.0-rc1-snapshot', '4.0.0', false); | ||
upgradeDoc('4.1.0-rc1-snapshot', '4.1.0-rc1', false); | ||
|
||
}); |