Skip to content

Commit

Permalink
Change doTryNextCluster logic to make it the same. [API-1354] (hazelc…
Browse files Browse the repository at this point in the history
…ast#1403)

* 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 committed Oct 25, 2022
1 parent 1f21026 commit de54c93
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 de54c93

Please sign in to comment.