elasticsearch-watchdog
Version:
A watchdog of elasticsearch - cluster nodes' statuses monitor, auto restart, keep PRIMARY node unique.
60 lines (53 loc) • 1.58 kB
JavaScript
var chai = require('chai'),
should = chai.should(),
expect = chai.expect,
path = require('path'),
Watchdog = require('../');
describe('start watching', function(){
var confPath;
before(function(){
confPath = path.resolve(__dirname, '..', 'example/confs/single.yml');
});
after(function(){
confPath = null;
});
describe('by programmatic', function(){
it('should goes fine', function(done){
try {
var wd = Watchdog({conf: confPath});
wd.on('info', function(info){
expect(info).to.be.an('object');
expect(info.type).to.match(/^(info|error)$/)
// clean house
wd.end();
// when we receive first information, just end it.
done();
});
wd.watching();
} catch (err) {
expect(err).to.not.exist;
done();
}
});
it('should returns with correct status', function(done){
try {
var wd = Watchdog({conf: confPath});
expect(wd.status).to.equal(Watchdog.status.WAITING);
wd.on('info', function(info){
expect(info).to.be.an('object');
expect(info.type).to.match(/^(info|error)$/)
expect(wd.status).to.equal(Watchdog.status.WATCHING);
// when we receive first information, just end it.
// clean house
wd.end();
expect(wd.status).to.equal(Watchdog.status.RECALL);
done();
});
wd.watching();
} catch (err) {
expect(err).to.not.exist;
done();
}
});
});
});