Skip to content

Commit

Permalink
add more test for fixedFeedbackRate controller implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Babatunde Sanusi <swisskid95@gmail.com>
  • Loading branch information
tunedev committed Sep 11, 2024
1 parent 3c6b739 commit 16508ec
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,29 @@ describe('fixedFeedbackRate controller implementation', () => {
sinon.assert.calledOnce(sleepStub);
sinon.assert.calledWith(sleepStub, 20000);
});

it('should sleep when no successful transactions have occurred', async () => {
txnStats.stats.txCounters.totalSubmitted = 5;
txnStats.stats.txCounters.totalFinished = 2;
txnStats.stats.txCounters.totalSuccessful = 0;
controller.generalSleepTime = 1;

await controller.applyRateControl();

sinon.assert.calledOnce(sleepStub);
sinon.assert.calledWith(sleepStub, 1 * controller.backOffTime);
});

it('should sleep when unfinished transactions are above the threshold', async () => {
txnStats.stats.txCounters.totalSubmitted = 44;
txnStats.stats.txCounters.totalFinished = 40;
controller.unfinishedPerWorker = 1;
controller.backOffTime = 100;

await controller.applyRateControl();

sinon.assert.calledOnce(sleepStub);
sinon.assert.calledWith(sleepStub, 88 * controller.backOffTime);
});
});
});

0 comments on commit 16508ec

Please sign in to comment.