Skip to content

Commit

Permalink
Add fixed-load rate controller to calliper generator (#1592)
Browse files Browse the repository at this point in the history
* Add fixed-load rate controller to calliper generator

Signed-off-by: Vivek jha <[email protected]>

* add tests

Signed-off-by: Vivek jha <[email protected]>

* review changes

Signed-off-by: Vivek jha <[email protected]>

* bug fix

Signed-off-by: Vivek jha <[email protected]>

* Update index.js

Signed-off-by: Vivek jha <[email protected]>

---------

Signed-off-by: Vivek jha <[email protected]>
  • Loading branch information
duckling69 authored Jul 1, 2024
1 parent 8ec4e00 commit 08f732a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/generator-caliper/generators/benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ module.exports = class extends Generator {
{name: 'Fixed Rate', value: 'fixed-rate'},
{name: 'Fixed Backlog', value: 'fixed-backlog'},
{name: 'Linear Rate', value: 'linear-rate'},
{name: 'Fixed Feedback Rate', value: 'fixed-feedback-rate'}
{name: 'Fixed Feedback Rate', value: 'fixed-feedback-rate'},
{name: 'Fixed Load', value: 'fixed-load'}
],
when: () => !this.options.rateController
}, {
Expand Down Expand Up @@ -272,6 +273,10 @@ module.exports = class extends Generator {
answersObject.opts = 'tps: 100, unfinished_per_client: 100';
this._configWrite();
break;
case 'fixed-load':
answersObject.opts = 'startTps: 10, transactionLoad: 20';
this._configWrite();
break;
}
}

Expand Down
12 changes: 12 additions & 0 deletions packages/generator-caliper/test/benchmark/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ describe ('benchmark configuration generator', () => {
fileContains.should.equal(true);
});

it ('should use the fixed-load controller in config.yaml if user answered "Fixed Load" for rate controller prompt', async () => {
options.txDuration = 30;
options.rateController = 'fixed-load';
await runGenerator();

const config = yaml.safeLoad(fs.readFileSync(tmpConfigPath),'utf8');
const configStr = JSON.stringify(config);
const fileContains = configStr.includes('"type":"fixed-load"');

fileContains.should.equal(true);
});

it ('should ask for the txDuration if user answered "txDuration" for tyType prompt', async () => {
options.txType = 'txDuration';
options.txDuration = 30;
Expand Down

0 comments on commit 08f732a

Please sign in to comment.