Skip to content

Commit

Permalink
Change doTryNextCluster logic to make it the same. [API-1354] (#1403)
Browse files Browse the repository at this point in the history
* Make ReadResultSet iterable [API-1315]

* Make ReadResultSet iterable [API-1315]

* Changes made according to comments on PR.[API-1315]

* Change doTryNextCluster logic to make it the same. [API-1354]
  • Loading branch information
harunalpak authored Oct 25, 2022
1 parent 62a2183 commit e1d228b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ClusterFailoverService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ClusterFailoverService {
}

private doTryNextCluster(tryCount: number, fn: TryNextFn): Promise<boolean> {
if (!this.lifecycleService.isRunning() || tryCount >= this.maxTryCount) {
if (!this.lifecycleService.isRunning() || tryCount >= (this.maxTryCount * this.candidateClusters.length)) {
return Promise.resolve(false);
}

Expand Down
6 changes: 3 additions & 3 deletions test/unit/ClusterFailoverServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ describe('ClusterFailoverServiceTest', function () {
const result = await service.tryNextCluster(fn);

expect(result).to.be.false;
expect(cnt).to.be.equal(maxTryCount);
expect(fn.callCount).to.be.equal(maxTryCount);
expect(service.current()).to.be.equal(contexts[maxTryCount % contexts.length]);
expect(cnt).to.be.equal(maxTryCount * contexts.length);
expect(fn.callCount).to.be.equal(maxTryCount * contexts.length);
expect(service.current()).to.be.equal(contexts[(maxTryCount * contexts.length) % contexts.length]);
});
});

0 comments on commit e1d228b

Please sign in to comment.