diff --git a/.travis.yml b/.travis.yml index 16cf2d990..66da671d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: -- "8" +- "10" services: - docker diff --git a/package.json b/package.json index a7ab9992a..e9870f0fb 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "bootstrap": "lerna bootstrap", "pretest": "npm run licchk", "licchk": "license-check-and-add", - "test": "lerna run test" + "test": "lerna run test", + "version-fix": "node ./packages/caliper-publish/publish.js version fix" }, "engines": { "node": ">=8.10.0", diff --git a/packages/caliper-cli/lib/lib/config.yaml b/packages/caliper-cli/lib/lib/config.yaml index 8fdb7f272..0bb4ae624 100644 --- a/packages/caliper-cli/lib/lib/config.yaml +++ b/packages/caliper-cli/lib/lib/config.yaml @@ -32,20 +32,20 @@ sut: # The name/key of the SDK binding 1.0.0: # Specifies the packages and their versions to install - packages: ['grpc@1.10.1', 'fabric-ca-client@1.1.0', 'fabric-client@1.1.0', 'fabric-protos@2.0.0-snapshot.1', 'fabric-network@1.4.0'] + packages: ['grpc@1.10.1', 'fabric-ca-client@1.1.0', 'fabric-client@1.1.0', 'fabric-protos@2.0.0-snapshot.1'] # The settings to apply during binding. The first setting whose versionRegexp matches the node version will be used settings: - *new-node-old-grpc 1.1.0: - packages: ['grpc@1.10.1', 'fabric-ca-client@1.1.0', 'fabric-client@1.1.0', 'fabric-protos@2.0.0-snapshot.1', 'fabric-network@1.4.0'] + packages: ['grpc@1.10.1', 'fabric-ca-client@1.1.0', 'fabric-client@1.1.0', 'fabric-protos@2.0.0-snapshot.1'] settings: - *new-node-old-grpc 1.2.0: - packages: ['grpc@1.10.1', 'fabric-ca-client@1.2.0', 'fabric-client@1.2.0', 'fabric-protos@2.0.0-snapshot.1', 'fabric-network@1.4.0'] + packages: ['grpc@1.10.1', 'fabric-ca-client@1.2.0', 'fabric-client@1.2.0', 'fabric-protos@2.0.0-snapshot.1'] settings: - *new-node-old-grpc 1.3.0: - packages: ['grpc@1.14.2', 'fabric-ca-client@1.3.0', 'fabric-client@1.3.0', 'fabric-protos@2.0.0-snapshot.1', 'fabric-network@1.4.0'] + packages: ['grpc@1.14.2', 'fabric-ca-client@1.3.0', 'fabric-client@1.3.0', 'fabric-protos@2.0.0-snapshot.1'] 1.4.0: packages: ['grpc@1.14.2', 'fabric-ca-client@1.4.0', 'fabric-client@1.4.0', 'fabric-protos@2.0.0-snapshot.1', 'fabric-network@1.4.0'] 1.4.1: @@ -99,14 +99,14 @@ sut: ethereum: 1.2.1: ðereum-latest - packages: ['web3@1.2.0'] + packages: ['web3@1.2.2'] latest: *ethereum-latest besu: 1.3.2: - packages: ['web3@1.2.0'] + packages: ['web3@1.2.2'] 1.3: - packages: ['web3@1.2.0'] + packages: ['web3@1.2.2'] 1.4: &besu-latest - packages: ['web3@1.2.0'] + packages: ['web3@1.2.2'] latest: *besu-latest diff --git a/packages/caliper-core/lib/common/messaging/mqtt-master.js b/packages/caliper-core/lib/common/messaging/mqtt-master.js index 77f883971..d57d640fc 100644 --- a/packages/caliper-core/lib/common/messaging/mqtt-master.js +++ b/packages/caliper-core/lib/common/messaging/mqtt-master.js @@ -115,6 +115,7 @@ class MqttMasterMessenger extends MessengerInterface { * Clean up any resources associated with the messenger. */ async dispose() { + Logger.info('Disconnecting from MQTT service'); const messengerDisconnectedPromise = new Promise((resolve, reject) => { this.messengerDisconnectedPromise = { resolve: resolve, @@ -122,7 +123,8 @@ class MqttMasterMessenger extends MessengerInterface { }; }); - this.mqttClient.end(false, undefined, () => { + this.mqttClient.end(false, {}, () => { + Logger.info('MQTT connection closed'); this.messengerDisconnectedPromise.resolve(); }); diff --git a/packages/caliper-core/lib/common/messaging/mqtt-worker.js b/packages/caliper-core/lib/common/messaging/mqtt-worker.js index 75a02d165..5c5d3d7a7 100644 --- a/packages/caliper-core/lib/common/messaging/mqtt-worker.js +++ b/packages/caliper-core/lib/common/messaging/mqtt-worker.js @@ -124,6 +124,7 @@ class MqttWorkerMessenger extends MessengerInterface { * Clean up any resources associated with the messenger. */ async dispose() { + Logger.info('Disconnecting from MQTT service'); const messengerDisconnectedPromise = new Promise((resolve, reject) => { this.messengerDisconnectedPromise = { resolve: resolve, @@ -131,7 +132,8 @@ class MqttWorkerMessenger extends MessengerInterface { }; }); - this.mqttClient.end(true, undefined, () => { + this.mqttClient.end(false, {}, () => { + Logger.info('MQTT connection closed'); this.messengerDisconnectedPromise.resolve(); }); diff --git a/packages/caliper-core/lib/common/prometheus/prometheus-push-client.js b/packages/caliper-core/lib/common/prometheus/prometheus-push-client.js index 338b108f6..5860eb228 100644 --- a/packages/caliper-core/lib/common/prometheus/prometheus-push-client.js +++ b/packages/caliper-core/lib/common/prometheus/prometheus-push-client.js @@ -99,7 +99,7 @@ class PrometheusPushClient { useGateway(method, body) { Logger.debug(`Prometheus client sending body ${body} to target ${this.requestParams.href}`); // Convert body to binary, the newline is important - body = new Buffer(body + '\n', 'binary'); + body = Buffer.from(body + '\n', 'binary'); // Assign request options const options = Object.assign(this.requestParams, { diff --git a/packages/caliper-core/lib/master/orchestrators/monitor-orchestrator.js b/packages/caliper-core/lib/master/orchestrators/monitor-orchestrator.js index 8a9a3d533..e9d4a4fd8 100644 --- a/packages/caliper-core/lib/master/orchestrators/monitor-orchestrator.js +++ b/packages/caliper-core/lib/master/orchestrators/monitor-orchestrator.js @@ -125,6 +125,7 @@ class MonitorOrchestrator { * @async */ async stopAllMonitors() { + logger.info('Stopping all monitors'); if(this.started === true) { for (let key of this.monitors.keys()) { diff --git a/packages/caliper-core/lib/master/orchestrators/worker-orchestrator.js b/packages/caliper-core/lib/master/orchestrators/worker-orchestrator.js index 1cf65713d..7254e0395 100644 --- a/packages/caliper-core/lib/master/orchestrators/worker-orchestrator.js +++ b/packages/caliper-core/lib/master/orchestrators/worker-orchestrator.js @@ -56,7 +56,7 @@ class WorkerOrchestrator { this.workerArguments = workerArguments; this.workers = {}; - this.workerObjects = []; + this.workerObjects = []; // used in the process communications this.updates = {id:0, data:[]}; // contains txUpdated messages this.results = []; // cumulative results @@ -486,16 +486,17 @@ class WorkerOrchestrator { } /** - * Stop all test workers (child processes) + * Stop all test workers and disconnect from messenger */ async stop() { + logger.info('Sending exit message to connected workers'); this.messenger.send(['all'], TYPES.EXIT, {}); - await this.messenger.dispose(); - for (let workerObject of this.workerObjects) { - workerObject.kill(); - } + // Internally spawned workers are killed within the messenger handling of 'exit', but clean the array of processes here this.workerObjects = []; + + // dispose of master messenger + await this.messenger.dispose(); } /** @@ -538,13 +539,13 @@ class WorkerOrchestrator { logger.info(`Launching worker ${index} of ${this.number}`); // Spawn the worker. The index is assigned upon connection - let cliPath = process.argv[1]; - let workerCommands = ['launch', 'worker']; - let remainingArgs = process.argv.slice(4); + const cliPath = process.argv[1]; + const workerCommands = ['launch', 'worker']; + const remainingArgs = process.argv.slice(4); - let nodeArgs = workerCommands.concat(remainingArgs); + const nodeArgs = workerCommands.concat(remainingArgs); - let worker = childProcess.fork(cliPath, nodeArgs, { + const worker = childProcess.fork(cliPath, nodeArgs, { env: process.env, cwd: process.cwd() }); diff --git a/packages/caliper-core/lib/master/report/report-builder.js b/packages/caliper-core/lib/master/report/report-builder.js index 1934e470d..38f0e818c 100644 --- a/packages/caliper-core/lib/master/report/report-builder.js +++ b/packages/caliper-core/lib/master/report/report-builder.js @@ -16,7 +16,7 @@ const Config = require('../../common/config/config-util'); const Utils = require('../../common/utils/caliper-utils'); -const Logger = Utils.getLogger('caliper-flow'); +const Logger = Utils.getLogger('report-builder'); const fs = require('fs'); const Mustache = require('mustache'); const path = require('path'); diff --git a/packages/caliper-core/lib/worker/client/caliper-local-client.js b/packages/caliper-core/lib/worker/client/caliper-local-client.js index 73298fd33..84955152f 100644 --- a/packages/caliper-core/lib/worker/client/caliper-local-client.js +++ b/packages/caliper-core/lib/worker/client/caliper-local-client.js @@ -21,7 +21,8 @@ const bc = require('../../common/core/blockchain.js'); const RateControl = require('../rate-control/rateControl.js'); const PrometheusClient = require('../../common/prometheus/prometheus-push-client'); -const Logger = CaliperUtils.getLogger('caliper-local-client.js'); +const Logger = CaliperUtils.getLogger('caliper-local-client'); + /** * Class for Client Interaction */ diff --git a/packages/caliper-core/lib/worker/client/message-handler.js b/packages/caliper-core/lib/worker/client/message-handler.js index 1b1c940d7..fec86a67d 100644 --- a/packages/caliper-core/lib/worker/client/message-handler.js +++ b/packages/caliper-core/lib/worker/client/message-handler.js @@ -30,6 +30,7 @@ class MessageHandler { * @param {Messenger} messenger the Messenger to use for communication with the orchestrator */ constructor(handlers, messenger) { + if (!handlers.init) { let msg = 'Handler for "init" is not specified'; logger.error(msg); @@ -236,7 +237,7 @@ class MessageHandler { case 'exit': { logger.info('Handling "exit" message'); await context.messenger.dispose(); - logger.info(`Handled "exit" message for worker ${context.workerId}`); + logger.info(`Handled "exit" message for worker ${context.workerId}, exiting process`); process.exit(0); break; } diff --git a/packages/caliper-fabric/lib/adaptor-versions/v1/fabric-gateway-v1.js b/packages/caliper-fabric/lib/adaptor-versions/v1/fabric-gateway-v1.js index 7326b339b..9f96781e0 100644 --- a/packages/caliper-fabric/lib/adaptor-versions/v1/fabric-gateway-v1.js +++ b/packages/caliper-fabric/lib/adaptor-versions/v1/fabric-gateway-v1.js @@ -17,12 +17,13 @@ const FabricClient = require('fabric-client'); const { DefaultEventHandlerStrategies, DefaultQueryHandlerStrategies, FileSystemWallet, Gateway, InMemoryWallet, X509WalletMixin } = require('fabric-network'); const { google, common } = require('fabric-protos'); -const { BlockchainInterface, CaliperUtils, TxStatus, Version, ConfigUtil } = require('@hyperledger/caliper-core'); +const { BlockchainInterface, CaliperUtils, TxStatus, ConfigUtil } = require('@hyperledger/caliper-core'); const logger = CaliperUtils.getLogger('adapters/fabric'); const FabricNetwork = require('../../fabricNetwork.js'); const ConfigValidator = require('../../configValidator.js'); const fs = require('fs'); +const semver = require('semver'); const EventStrategies = { msp_all : DefaultEventHandlerStrategies.MSPID_SCOPE_ALLFORTX, @@ -139,7 +140,7 @@ class Fabric extends BlockchainInterface { super(networkConfig); this.bcType = 'fabric'; this.workspaceRoot = workspace_root; - this.version = new Version(require('fabric-client/package').version); + this.version = require('fabric-client/package').version; this.network = undefined; if (typeof networkConfig === 'string') { @@ -160,6 +161,7 @@ class Fabric extends BlockchainInterface { this.wallet = undefined; this.userContracts = new Map(); this.userGateways = new Map(); + this.peerCache = new Map(); // this value is hardcoded, if it's used, that means that the provided timeouts are not sufficient this.configSmallestTimeout = 1000; @@ -189,11 +191,6 @@ class Fabric extends BlockchainInterface { this.fileWalletPath = this.networkUtil.getFileWalletPath(); this.defaultInvoker = Array.from(this.networkUtil.getClients())[0]; - // Network Wallet/Gateway is only available in SDK versions greater than v1.4.0 - if (this.version.lessThan('1.4.0')) { - throw new Error(`Fabric SDK ${this.version.toString()} is not supported when using a Fabric Gateway object, use at least version 1.4.0`); - } - this._prepareWallet(); } @@ -916,6 +913,7 @@ class Fabric extends BlockchainInterface { strategy: EventStrategies[this.eventStrategy] }, queryHandlerOptions: { + requestTimeout: this.configDefaultTimeout, strategy: QueryStrategies[this.queryStrategy] } }; @@ -1388,6 +1386,27 @@ class Fabric extends BlockchainInterface { return channelJoined; } + /** + * Initialize channel objects for use in peer targeting. Requires user gateways to have been + * formed in advance. + */ + async _initializePeerCache() { + + for (const userName of this.userGateways.keys()) { + const gateway = this.userGateways.get(userName); + // Loop over known channel names + const channelNames = this.networkUtil.getChannels(); + for (const channelName of channelNames) { + const network = await gateway.getNetwork(channelName); + const channel = network.getChannel(); + // Add all peers + for (const peerObject of channel.getChannelPeers()) { + this.peerCache.set(peerObject.getName(), peerObject); + } + } + } + } + /** * Conditionally initializes a wallet depending on user provided options * @private @@ -1500,11 +1519,11 @@ class Fabric extends BlockchainInterface { // Add transient data if present // - passed as key value pairing such as {"hello":"world"} - if (invokeSettings.transientData) { + if (invokeSettings.transientMap) { const transientData = {}; - const keys = Array.from(Object.keys(invokeSettings.transientData)); + const keys = Array.from(Object.keys(invokeSettings.transientMap)); keys.forEach((key) => { - transientData[key] = Buffer.from(invokeSettings.transientData[key]); + transientData[key] = Buffer.from(invokeSettings.transientMap[key]); }); transaction.setTransient(transientData); } @@ -1515,10 +1534,14 @@ class Fabric extends BlockchainInterface { const targetPeerObjects = []; for (const name of invokeSettings.targetPeers) { const peer = this.peerCache.get(name); - targetPeerObjects.push(peer); + if (peer) { + targetPeerObjects.push(peer); + } } // Set the peer objects in the transaction - transaction.setEndorsingPeers(targetPeerObjects); + if (targetPeerObjects.length > 0) { + transaction.setEndorsingPeers(targetPeerObjects); + } } try { @@ -1615,6 +1638,13 @@ class Fabric extends BlockchainInterface { // - within submit/evaluate, a contract will be used for a nominated user await this._initializeContracts(); + // - use gateways to build a peer cache if the version supports it + if (semver.satisfies(semver.coerce(this.version), '>=1.4.5')) { + await this._initializePeerCache(); + } else { + logger.warn(`Bound SDK ${this.version} is unable to use target peers; to enable target peer nomination for a gateway transaction, bind Caliper to Fabric 1.4.5 and above`); + } + // We are done - return the networkUtil object return { networkInfo: this.networkUtil, @@ -1763,6 +1793,9 @@ class Fabric extends BlockchainInterface { logger.info(`disconnecting gateway for user ${userName}`); gateway.disconnect(); } + + // Clear peer cache + this.peerCache.clear(); } } diff --git a/packages/caliper-fabric/lib/adaptor-versions/v2/fabric-gateway-v2.js b/packages/caliper-fabric/lib/adaptor-versions/v2/fabric-gateway-v2.js index 6cb63a7c8..0efbc0efb 100644 --- a/packages/caliper-fabric/lib/adaptor-versions/v2/fabric-gateway-v2.js +++ b/packages/caliper-fabric/lib/adaptor-versions/v2/fabric-gateway-v2.js @@ -16,12 +16,13 @@ const { DefaultEventHandlerStrategies, DefaultQueryHandlerStrategies, Gateway, Wallets } = require('fabric-network'); const { BlockchainInterface, CaliperUtils, TxStatus, Version, ConfigUtil } = require('@hyperledger/caliper-core'); -const logger = CaliperUtils.getLogger('adapters/fabric'); const FabricNetwork = require('../../fabricNetwork.js'); const ConfigValidator = require('../../configValidator.js'); const RegistrarHelper = require('./registrarHelper'); +const logger = CaliperUtils.getLogger('adapters/fabric'); + const EventStrategies = { msp_all : DefaultEventHandlerStrategies.MSPID_SCOPE_ALLFORTX, msp_any : DefaultEventHandlerStrategies.MSPID_SCOPE_ANYFORTX, @@ -135,10 +136,6 @@ class Fabric extends BlockchainInterface { throw new Error('[FabricNetwork.constructor] Parameter \'networkConfig\' is neither a file path nor an object'); } - // validate the network - ConfigValidator.validateNetwork(this.network, CaliperUtils.getFlowOptions(), - this.configDiscovery, true); - this.clientIndex = clientIndex; this.txIndex = -1; this.networkUtil = new FabricNetwork(this.network, workspace_root); @@ -159,6 +156,9 @@ class Fabric extends BlockchainInterface { this.configDiscovery = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.Discovery, false); this.eventStrategy = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.EventStrategy, 'msp_all'); this.queryStrategy = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.QueryStrategy, 'msp_single'); + + // validate the network + ConfigValidator.validateNetwork(this.network, CaliperUtils.getFlowOptions(), this.configDiscovery, true); } //////////////////////////////// @@ -449,11 +449,11 @@ class Fabric extends BlockchainInterface { // Add transient data if present // - passed as key value pairing such as {"hello":"world"} - if (invokeSettings.transientData) { + if (invokeSettings.transientMap) { const transientData = {}; - const keys = Array.from(Object.keys(invokeSettings.transientData)); + const keys = Array.from(Object.keys(invokeSettings.transientMap)); keys.forEach((key) => { - transientData[key] = Buffer.from(invokeSettings.transientData[key]); + transientData[key] = Buffer.from(invokeSettings.transientMap[key]); }); transaction.setTransient(transientData); } @@ -690,6 +690,9 @@ class Fabric extends BlockchainInterface { logger.info(`disconnecting gateway for user ${userName}`); gateway.disconnect(); } + + // Clear peer cache + this.peerCache.clear(); }} module.exports = Fabric; diff --git a/packages/caliper-fabric/lib/fabric.js b/packages/caliper-fabric/lib/fabric.js index 86f4322d4..0e44fe725 100644 --- a/packages/caliper-fabric/lib/fabric.js +++ b/packages/caliper-fabric/lib/fabric.js @@ -29,14 +29,14 @@ const Fabric = class extends BlockchainInterface { constructor(workerIndex) { super(); // Switch adaptors based on installed packages - // - will either have fabric-client, or fabric-network + // - will either have fabric-network, or fabric-client let version; - if (CaliperUtils.moduleIsInstalled('fabric-client')) { - const packageVersion = require('fabric-client/package').version; - version = semver.coerce(packageVersion); - } else if (CaliperUtils.moduleIsInstalled('fabric-network')) { + if (CaliperUtils.moduleIsInstalled('fabric-network')) { const packageVersion = require('fabric-network/package').version; version = semver.coerce(packageVersion); + } else if (CaliperUtils.moduleIsInstalled('fabric-client')) { + const packageVersion = require('fabric-client/package').version; + version = semver.coerce(packageVersion); } else { const msg = 'Unable to detect required Fabric binding packages'; throw new Error(msg); @@ -52,7 +52,12 @@ const Fabric = class extends BlockchainInterface { if (!useGateway) { modulePath = './adaptor-versions/v1/fabric-v1.js'; } else { - modulePath = './adaptor-versions/v1/fabric-gateway-v1.js'; + // gateway with default event handlers appears in SDK > 1.4.2 + if (semver.satisfies(version, '>=1.4.2')) { + modulePath = './adaptor-versions/v1/fabric-gateway-v1.js'; + } else { + throw new Error('Caliper currently only supports Fabric gateway based operation using Fabric-SDK 1.4.2 and higher. Please retry with a different SDK binding'); + } } } else if (semver.satisfies(version, '=2.x')) { if (!useGateway) { diff --git a/packages/caliper-fisco-bcos/package.json b/packages/caliper-fisco-bcos/package.json index 84cdd7e33..fab95ffba 100644 --- a/packages/caliper-fisco-bcos/package.json +++ b/packages/caliper-fisco-bcos/package.json @@ -90,4 +90,4 @@ "lines": 5 }, "license": "Apache-2.0" -} +} \ No newline at end of file diff --git a/packages/caliper-sawtooth/lib/sawtooth.js b/packages/caliper-sawtooth/lib/sawtooth.js index f786fa6ff..ebcc35def 100644 --- a/packages/caliper-sawtooth/lib/sawtooth.js +++ b/packages/caliper-sawtooth/lib/sawtooth.js @@ -317,7 +317,7 @@ class Sawtooth extends BlockchainInterface { const data = (JSON.parse(body)).data; if (data.length > 0) { const stateDataBase64 = data[0].data; - const stateDataBuffer = new Buffer(stateDataBase64, 'base64'); + const stateDataBuffer = Buffer.from(stateDataBase64, 'base64'); const stateData = stateDataBuffer.toString('hex'); txStatus.SetStatusSuccess(); diff --git a/packages/caliper-tests-integration/besu_tests/config/docker-compose.yml b/packages/caliper-tests-integration/besu_tests/config/docker-compose.yml index 0a29285fa..be2e4cac8 100644 --- a/packages/caliper-tests-integration/besu_tests/config/docker-compose.yml +++ b/packages/caliper-tests-integration/besu_tests/config/docker-compose.yml @@ -24,4 +24,4 @@ services: - ./keys:/root/.ethereum/keystore ports: - 8545-8547:8545-8547 - command: --revert-reason-enabled --rpc-http-enabled --rpc-http-host 0.0.0.0 --host-whitelist=* --rpc-http-apis admin,eth,miner,web3,net --graphql-http-enabled --discovery-enabled=false + command: --revert-reason-enabled --rpc-ws-enabled --rpc-ws-host 0.0.0.0 --host-whitelist=* --rpc-ws-apis admin,eth,miner,web3,net --graphql-http-enabled --discovery-enabled=false diff --git a/packages/caliper-tests-integration/fabric_tests/phase4/benchconfig.yaml b/packages/caliper-tests-integration/fabric_tests/phase4/benchconfig.yaml index 2f5136a86..0d3c71f3a 100644 --- a/packages/caliper-tests-integration/fabric_tests/phase4/benchconfig.yaml +++ b/packages/caliper-tests-integration/fabric_tests/phase4/benchconfig.yaml @@ -19,16 +19,12 @@ test: number: 2 rounds: - label: init1 - txNumber: 100 - rateControl: { type: 'fixed-rate', opts: { tps: 20 } } - callback: ../init.js - - label: init2 - txNumber: 200 - rateControl: { type: 'fixed-feedback-rate', opts: { tps: 20, unfinished_per_client: 5 } } + txNumber: 50 + rateControl: { type: 'fixed-rate', opts: { tps: 5 } } callback: ../init.js - label: query - txNumber: 100 - rateControl: { type: 'linear-rate', opts: { startingTps: 10, finishingTps: 20 } } + txNumber: 50 + rateControl: { type: 'linear-rate', opts: { startingTps: 5, finishingTps: 10 } } callback: ../query.js observer: interval: 1 diff --git a/packages/caliper-tests-integration/fabric_tests/phase5/benchconfig.yaml b/packages/caliper-tests-integration/fabric_tests/phase5/benchconfig.yaml index 028b27009..64b8ac482 100644 --- a/packages/caliper-tests-integration/fabric_tests/phase5/benchconfig.yaml +++ b/packages/caliper-tests-integration/fabric_tests/phase5/benchconfig.yaml @@ -19,22 +19,38 @@ test: number: 2 rounds: - label: init1 - txNumber: 100 - rateControl: { type: 'fixed-rate', opts: { tps: 20 } } - callback: ../init.js - - label: init2 - txNumber: 200 - rateControl: { type: 'fixed-feedback-rate', opts: { tps: 20, unfinished_per_client: 5 } } + txNumber: 25 + rateControl: { type: 'fixed-rate', opts: { tps: 5 } } callback: ../init.js - label: query - txNumber: 100 - rateControl: { type: 'linear-rate', opts: { startingTps: 10, finishingTps: 20 } } + txNumber: 25 + rateControl: { type: 'linear-rate', opts: { startingTps: 5, finishingTps: 10 } } callback: ../query.js observer: interval: 1 - type: local + type: prometheus monitor: interval: 1 - type: ['process'] - process: - processes: [{ command: 'node', arguments: 'fabricClientWorker.js', multiOutput: 'avg' }] + type: ['prometheus'] + prometheus: + url: "http://localhost:9090" + push_url: "http://localhost:9091" + metrics: + ignore: [prometheus, pushGateway, cadvisor, grafana, node-exporter] + include: + Endorse Time (s): + query: rate(endorser_propsal_duration_sum{chaincode="marbles:v0"}[1m])/rate(endorser_propsal_duration_count{chaincode="marbles:v0"}[1m]) + step: 1 + label: instance + statistic: avg + Max Memory (MB): + query: sum(container_memory_rss{name=~".+"}) by (name) + step: 10 + label: name + statistic: max + multiplier: 0.000001 + charting: + polar: + metrics: [Max Memory (MB)] + bar: + metrics: [all] diff --git a/packages/caliper-tests-integration/fabric_tests/phase5/networkconfig.yaml b/packages/caliper-tests-integration/fabric_tests/phase5/networkconfig.yaml index bc9bb5823..fb2f075a8 100644 --- a/packages/caliper-tests-integration/fabric_tests/phase5/networkconfig.yaml +++ b/packages/caliper-tests-integration/fabric_tests/phase5/networkconfig.yaml @@ -14,8 +14,145 @@ name: Fabric version: "1.0" +mutual-tls: true caliper: blockchain: fabric - command: - end: docker-compose -p caliper down;(test -z \"$(docker ps -aq)\") || docker rm $(docker ps -aq);(test -z \"$(docker images dev* -q)\") || docker rmi $(docker images dev* -q);rm -rf /tmp/hfc-* + +clients: + client0.org1.example.com: + client: + organization: Org1 + credentialStore: + path: /tmp/hfc-kvs/org1 + cryptoStore: + path: /tmp/hfc-cvs/org1 + clientPrivateKey: + path: ../config/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/key.pem + clientSignedCert: + path: ../config/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem + + client0.org2.example.com: + client: + organization: Org2 + credentialStore: + path: /tmp/hfc-kvs/org2 + cryptoStore: + path: /tmp/hfc-cvs/org2 + clientPrivateKey: + path: ../config/crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/key.pem + clientSignedCert: + path: ../config/crypto-config/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem + +channels: + mychannel: + created: true + orderers: + - orderer0.example.com + - orderer1.example.com + peers: + peer0.org1.example.com: + eventSource: true + peer0.org2.example.com: + eventSource: true + + chaincodes: + - id: marbles + contractID: mymarbles + version: v0 + language: node + path: src/marbles/node + metadataPath: src/marbles/node/metadata + yourchannel: + created: true + orderers: + - orderer0.example.com + - orderer1.example.com + peers: + peer0.org1.example.com: + eventSource: true + peer0.org2.example.com: + eventSource: true + + chaincodes: + - id: marbles + contractID: yourmarbles + version: v0 + language: golang + path: marbles/go + metadataPath: src/marbles/go/metadata + +organizations: + Org1: + mspid: Org1MSP + peers: + - peer0.org1.example.com + certificateAuthorities: + - ca.org1.example.com + adminPrivateKey: + path: ../config/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/key.pem + signedCert: + path: ../config/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem + + Org2: + mspid: Org2MSP + peers: + - peer0.org2.example.com + certificateAuthorities: + - ca.org2.example.com + adminPrivateKey: + path: ../config/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/key.pem + signedCert: + path: ../config/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem + +orderers: + orderer0.example.com: + url: grpcs://localhost:7050 + grpcOptions: + ssl-target-name-override: orderer0.example.com + tlsCACerts: + path: ../config/crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp/tlscacerts/tlsca.example.com-cert.pem + orderer1.example.com: + url: grpcs://localhost:8050 + grpcOptions: + ssl-target-name-override: orderer1.example.com + tlsCACerts: + path: ../config/crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/msp/tlscacerts/tlsca.example.com-cert.pem + +peers: + peer0.org1.example.com: + url: grpcs://localhost:7051 + grpcOptions: + ssl-target-name-override: peer0.org1.example.com + grpc.keepalive_time_ms: 600000 + tlsCACerts: + path: ../config/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem + + peer0.org2.example.com: + url: grpcs://localhost:8051 + grpcOptions: + ssl-target-name-override: peer0.org2.example.com + grpc.keepalive_time_ms: 600000 + tlsCACerts: + path: ../config/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/tlscacerts/tlsca.org2.example.com-cert.pem + +certificateAuthorities: + ca.org1.example.com: + url: https://localhost:7054 + httpOptions: + verify: false + tlsCACerts: + path: ../config/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem + registrar: + - enrollId: admin + enrollSecret: adminpw + + ca.org2.example.com: + url: https://localhost:8054 + httpOptions: + verify: false + tlsCACerts: + path: ../config/crypto-config/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem + registrar: + - enrollId: admin + enrollSecret: adminpw diff --git a/packages/caliper-tests-integration/fabric_tests/phase6/benchconfig.yaml b/packages/caliper-tests-integration/fabric_tests/phase6/benchconfig.yaml new file mode 100644 index 000000000..028b27009 --- /dev/null +++ b/packages/caliper-tests-integration/fabric_tests/phase6/benchconfig.yaml @@ -0,0 +1,40 @@ +# +# 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. +# + +--- +test: + workers: + type: local + number: 2 + rounds: + - label: init1 + txNumber: 100 + rateControl: { type: 'fixed-rate', opts: { tps: 20 } } + callback: ../init.js + - label: init2 + txNumber: 200 + rateControl: { type: 'fixed-feedback-rate', opts: { tps: 20, unfinished_per_client: 5 } } + callback: ../init.js + - label: query + txNumber: 100 + rateControl: { type: 'linear-rate', opts: { startingTps: 10, finishingTps: 20 } } + callback: ../query.js +observer: + interval: 1 + type: local +monitor: + interval: 1 + type: ['process'] + process: + processes: [{ command: 'node', arguments: 'fabricClientWorker.js', multiOutput: 'avg' }] diff --git a/packages/caliper-tests-integration/fabric_tests/phase6/networkconfig.yaml b/packages/caliper-tests-integration/fabric_tests/phase6/networkconfig.yaml new file mode 100644 index 000000000..bc9bb5823 --- /dev/null +++ b/packages/caliper-tests-integration/fabric_tests/phase6/networkconfig.yaml @@ -0,0 +1,21 @@ +# +# 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. +# + +name: Fabric +version: "1.0" + +caliper: + blockchain: fabric + command: + end: docker-compose -p caliper down;(test -z \"$(docker ps -aq)\") || docker rm $(docker ps -aq);(test -z \"$(docker images dev* -q)\") || docker rmi $(docker images dev* -q);rm -rf /tmp/hfc-* diff --git a/packages/caliper-tests-integration/fabric_tests/query.js b/packages/caliper-tests-integration/fabric_tests/query.js index 1d084d354..d98c9cf46 100644 --- a/packages/caliper-tests-integration/fabric_tests/query.js +++ b/packages/caliper-tests-integration/fabric_tests/query.js @@ -30,7 +30,8 @@ module.exports.run = async function() { let marbleOwner = owners[txIndex % owners.length]; let args = { chaincodeFunction: 'queryMarblesByOwner', - chaincodeArguments: [marbleOwner] + chaincodeArguments: [marbleOwner], + targetPeers: ['peer0.org1.example.com'] }; let targetCC = txIndex % 2 === 0 ? 'mymarbles' : 'yourmarbles'; diff --git a/packages/caliper-tests-integration/fabric_tests/run.sh b/packages/caliper-tests-integration/fabric_tests/run.sh index 39d69497f..4dcb2679b 100755 --- a/packages/caliper-tests-integration/fabric_tests/run.sh +++ b/packages/caliper-tests-integration/fabric_tests/run.sh @@ -86,8 +86,8 @@ if [[ ${rc} != 0 ]]; then exit ${rc}; fi -# PHASE 4 again: testing through the gateway API -${CALL_METHOD} launch master --caliper-workspace phase4 --caliper-flow-only-test --caliper-fabric-gateway-usegateway +# PHASE 5: testing through the gateway API +${CALL_METHOD} launch master --caliper-workspace phase5 --caliper-flow-only-test --caliper-fabric-gateway-usegateway rc=$? if [[ ${rc} != 0 ]]; then echo "Failed CI step 6"; @@ -95,16 +95,30 @@ if [[ ${rc} != 0 ]]; then exit ${rc}; fi -# PHASE 5: just disposing of the network -${CALL_METHOD} launch master --caliper-workspace phase5 --caliper-flow-only-end +# UNBIND 1.4.7 SDK, using the package dir as CWD +# Note: do not use env variables for unbinding settings, as subsequent launch calls will pick them up and bind again +if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then + ${CALL_METHOD} unbind --caliper-bind-sut fabric:1.4.7 --caliper-bind-cwd ./../../caliper-fabric/ --caliper-bind-args="--save-dev" --caliper-projectconfig ./caliper.yaml +fi +# BIND with 2.1.0 SDK, using the package dir as CWD +# Note: do not use env variables for unbinding settings, as subsequent launch calls will pick them up and bind again +if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then + ${CALL_METHOD} bind --caliper-bind-sut fabric:2.1.0 --caliper-bind-cwd ./../../caliper-fabric/ --caliper-bind-args="--save-dev" +fi + +# PHASE 6: testing through the gateway API (v2 SDK) +${CALL_METHOD} launch master --caliper-workspace phase5 --caliper-flow-only-test --caliper-fabric-gateway-usegateway rc=$? if [[ ${rc} != 0 ]]; then echo "Failed CI step 7"; + dispose; exit ${rc}; fi -# unbind during CI tests, using the package dir as CWD -# Note: do not use env variables for unbinding settings, as subsequent launch calls will pick them up and bind again -if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then - ${CALL_METHOD} unbind --caliper-bind-sut fabric:1.4.7 --caliper-bind-cwd ./../../caliper-fabric/ --caliper-bind-args="--save-dev" --caliper-projectconfig ./caliper.yaml +# PHASE 7: just disposing of the network +${CALL_METHOD} launch master --caliper-workspace phase6 --caliper-flow-only-end --caliper-fabric-gateway-usegateway +rc=$? +if [[ ${rc} != 0 ]]; then + echo "Failed CI step 8"; + exit ${rc}; fi diff --git a/packages/generator-caliper/package.json b/packages/generator-caliper/package.json index 6a1d7e26a..24c1deb31 100644 --- a/packages/generator-caliper/package.json +++ b/packages/generator-caliper/package.json @@ -33,7 +33,7 @@ "yosay": "^2.0.1" }, "devDependencies": { - "js-yaml": "^3.12.0", + "js-yaml": "^3.13.1", "fs-extra": "8.1.0", "yeoman-assert": "^3.1.1", "yeoman-test": "^1.7.0",