-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Create interface and base class for workload modules - Load workload modules with the factory approach - Update CI test workloads to class format - Extend CI workload arguments where needed to make workloads deterministic - Increase frequency of TX updates in CI tests to increase monitor accuracy - Update workload module paths in the benchconfig files to precise relative path - Create separate artifacts for Fabric v2 CI phase Signed-off-by: Attila Klenik <[email protected]>
- Loading branch information
Showing
43 changed files
with
1,860 additions
and
861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,4 @@ | |
} | ||
}, | ||
"license": "Apache-2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
packages/caliper-core/lib/worker/workload/workloadModuleBase.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const WorkloadModuleInterface = require('./workloadModuleInterface'); | ||
const Logger = require('./../../common/utils/caliper-utils').getLogger('workload-module-base'); | ||
|
||
/** | ||
* Utility base class for the user-implemented workload modules used for assembling TXs for the SUT. | ||
*/ | ||
class WorkloadModuleBase extends WorkloadModuleInterface { | ||
/** | ||
* Initialize an instance of the WorkloadModuleBase class. | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
Logger.debug('Constructing workload module'); | ||
|
||
/** | ||
* The 0-based index of the worker instantiating the workload module. | ||
* @type {number} | ||
*/ | ||
this.workerIndex = -1; | ||
|
||
/** | ||
* The total number of workers participating in the round. | ||
* @type {number} | ||
*/ | ||
this.totalWorkers = -1; | ||
|
||
/** | ||
* The 0-based index of the currently executing round. | ||
* @type {number} | ||
*/ | ||
this.roundIndex = -1; | ||
|
||
/** | ||
* The user-provided arguments for the round from the benchmark configuration file. | ||
* @type {Object} | ||
*/ | ||
this.roundArguments = undefined; | ||
|
||
/** | ||
* The adapter of the underlying SUT. | ||
* @type {BlockchainInterface} | ||
*/ | ||
this.sutAdapter = undefined; | ||
|
||
/** | ||
* The custom context object provided by the SUT adapter. | ||
* @type {Object} | ||
*/ | ||
this.sutContext = undefined; | ||
} | ||
|
||
/** | ||
* Initialize the workload module with the given parameters. | ||
* @param {number} workerIndex The 0-based index of the worker instantiating the workload module. | ||
* @param {number} totalWorkers The total number of workers participating in the round. | ||
* @param {number} roundIndex The 0-based index of the currently executing round. | ||
* @param {Object} roundArguments The user-provided arguments for the round from the benchmark configuration file. | ||
* @param {BlockchainInterface} sutAdapter The adapter of the underlying SUT. | ||
* @param {Object} sutContext The custom context object provided by the SUT adapter. | ||
* @async | ||
*/ | ||
async initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext) { | ||
Logger.debug(`Workload module initialized with: workerIndex=${workerIndex}, totalWorkers=${totalWorkers}, roundIndex=${roundIndex}, roundArguments=${JSON.stringify(roundArguments)}`); | ||
this.workerIndex = workerIndex; | ||
this.totalWorkers = totalWorkers; | ||
this.roundIndex = roundIndex; | ||
this.roundArguments = roundArguments; | ||
this.sutAdapter = sutAdapter; | ||
this.sutContext = sutContext; | ||
} | ||
|
||
/** | ||
* Clean up the workload module at the end of the round. | ||
* @async | ||
*/ | ||
async cleanupWorkloadModule() { | ||
// NOOP by default | ||
Logger.debug('Cleaning up workload module: NOOP'); | ||
} | ||
} | ||
|
||
|
||
module.exports = WorkloadModuleBase; |
54 changes: 54 additions & 0 deletions
54
packages/caliper-core/lib/worker/workload/workloadModuleInterface.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Interface for the user-implemented workload modules used for assembling TXs for the SUT. | ||
*/ | ||
class WorkloadModuleInterface { | ||
/** | ||
* Initialize the workload module with the given parameters. | ||
* @param {number} workerIndex The 0-based index of the worker instantiating the workload module. | ||
* @param {number} totalWorkers The total number of workers participating in the round. | ||
* @param {number} roundIndex The 0-based index of the currently executing round. | ||
* @param {object} roundArguments The user-provided arguments for the round from the benchmark configuration file. | ||
* @param {BlockchainInterface} sutAdapter The adapter of the underlying SUT. | ||
* @param {object} sutContext The custom context object provided by the SUT adapter. | ||
* @async | ||
*/ | ||
async initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext) { | ||
throw new Error('WorkloadModuleInterface.initializeWorkloadModule() must be implemented in derived class'); | ||
} | ||
|
||
/** | ||
* Assemble the next TX content(s) and submit it to the SUT adapter. | ||
* @return {Promise<TxStatus[]>} The promises for the TX results as returned by the SUT adapter. | ||
* @async | ||
*/ | ||
async submitTransaction() { | ||
throw new Error('WorkloadModuleInterface.submitTransaction() must be implemented in derived class'); | ||
} | ||
|
||
/** | ||
* Clean up the workload module at the end of the round. | ||
* @async | ||
*/ | ||
async cleanupWorkloadModule() { | ||
throw new Error('WorkloadModuleInterface.cleanupWorkloadModule() must be implemented in derived class'); | ||
} | ||
} | ||
|
||
|
||
module.exports = WorkloadModuleInterface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.