Hyperledger Caliper tutorial for Composer network

2019-08-18 22:50发布

问题:

I want to execute a performance evaluation test on a deployed Hyperledger Composer business network using Hyperledger Caliper.

Into the official documentation there is a section for the Composer configuration but I think that it's not very user friendly for those approaching this framework for the first time and I cannot find a better basic step-by-step tutorial for configuring and running an evaluation test.

回答1:

Check that all the prerequisites are installed:

  • NodeJS 8 (LTS), 9, or 10 (LTS) higher versions are not supported as the dependancy chain does not permit this

  • node-gyp

  • Docker
  • Docker-compose

Build Caliper:

  • Run npm install in Caliper root folder to install base dependencies locally
  • Run npm run repoclean in Caliper root folder to ensure that all the packages are clean
  • Run npm run bootstrap to bootstrap the packages in the Caliper repository. This will install all package dependancies and link any cross dependancies. It will take some time to finish installation. If it is interrupted by ctrl+c, please recover the file package.json first and then run npm run bootstrap again.

Do not run any of the above commands with sudo, as it will cause the bootstrap process to fail

Install the Caliper CLI

Execute the following command from the packages/caliper-tests-integration directory:

npm run e2e_install

Run a Sample Benchmark

from caliper/packages/caliper-samples/ run

caliper benchmark run -c benchmark/composer/config.yaml -n network/fabric-v1.3/2org1peercouchdb/composer.json -w ../caliper-samples/

where the parameters means:

-w : path to a workspace directory (required)
-c : relative path from the workspace to the benchmark configuration file (required).
-n : relative path from the workspace to the config file of the blockchain network under test (required).

To create tests for your Business Network you need to modify the config.yaml and composer.json files. You also have to create a .js file where you need to implement the test to be runned, and specify the path to this file in the callback section of config.yaml file.

For more informations check https://hyperledger.github.io/caliper/docs/1_Getting_Started.html