retrieveServices() { for (const [key, val] of Object.entries(this.dependencies)) { const path = `/${this.root}/${val.interface}/providers`; this.client.getChildren( path, this.watchService.bind(this), this.resolveService(path, key, val) ); } }
it("ZK is down while getting data", function (done) { zkClient.getChildren.restore(); sandbox.stub(zkClient, "getChildren", function (path, cb) { cb(null, ["one", "two"], 1);
_onProvisionChange() { const zkPath = PROVISIONS; this._withRandomDelayIfTest( () => this._client.getChildren(zkPath, event => { this._log.debug('got provision event', { zkPath: `${this._zkEndpoint}${zkPath}`, event, }); this._onProvisionChange(); }, (err, children) => { if (err) { this._log.error('list failed', { zkPath: `${this._zkEndpoint}${zkPath}`, error: err }); return; } this._provisions = children; if (this._isLeader) { this._redispatchProvisions(); } }) ); }
it("Succeed to load tasks and found in pending (should restore)", function (done) { var deleted = false; zkClient.getChildren.restore(); sandbox.stub(zkClient, "getChildren", function (path, cb) { cb(null, ["one", "two", "three"], 1);
zkClient.removeRecur = function removeRecur(path, cb) { async.waterfall([ next => zkClient.getChildren(path, next), (children, stat, next) => async.eachLimit( children, 2,
it("Succeed to load tasks but not found in pending (should kill)", function (done) { zkClient.getChildren.restore();
it("Succeed to load tasks with environment and found in pending (should restore)", function (done) { var deleted = false; zkClient.getChildren.restore(); sandbox.stub(zkClient, "getChildren", function (path, cb) { cb(null, ["one", "two", "three"], 1);
it("Succeed to load tasks with partial environment and found in pending (should restore)", function (done) { var deleted = false; zkClient.getChildren.restore(); sandbox.stub(zkClient, "getChildren", function (path, cb) { cb(null, ["one", "two", "three"], 1);
_onLeaderChange() { // monitor leader change const zkPath = LEADERS; this._withRandomDelayIfTest( () => this._client.getChildren(zkPath, event => { this._log.debug('got leader event', { zkPath: `${this._zkEndpoint}${zkPath}`, event }); this._onLeaderChange(); }, (err, children) => { if (err) { this._log.error('list failed', { zkPath: `${this._zkEndpoint}${zkPath}`, error: err }); return; } this._isLeader = this._amILeader(children); this._log.debug('updated leader', { zkPath: `${this._zkEndpoint}${zkPath}`, children, iamLeader: this._isLeader }); if (this._isLeader) { this._redispatchProvisions(); } }) ); }
it("Succeed to load tasks and found in pending but no runtimeInfo (should delete from zk)", function (done) { zkClient.getChildren.restore();
it("Succeed to load task list but fail to load task", function (done) { zkClient.getChildren.restore(); sandbox.stub(zkClient, "getChildren", function (path, cb) { cb(null, ["one", "two"], 1);
_onOwnerChange() { const zkPath = OWNERS; this._withRandomDelayIfTest( () => this._client.getChildren(zkPath, event => { this._log.debug('got owner event', { zkPath: `${this._zkEndpoint}${zkPath}`, event }); this._onOwnerChange(); }, (err, children) => { if (err) { this._log.error('list failed', { zkPath: `${this._zkEndpoint}${zkPath}`, error: err }); return; } this._owners = children; this._log.debug('owners updated', { zkPath: `${this._zkEndpoint}${zkPath}`, owners: this._owners }); if (this._isLeader) { this._redispatchProvisions(); } }) ); }
it("Succeed to load tasks and no tasks", function (done) { zkClient.getChildren.restore(); sandbox.stub(zkClient, "getChildren", function (path, cb) { cb(null, [], 1);