Fabric2.3 uses Caliper for performance testing (nanny-level demonstration, personal testing is feasible)

It is necessary to use Caliper to perform performance tests on Fabric 2.3.3 that has been built in Ubuntu 20.04, and collect two performance indicators, throughput and delay.

1 Install Caliper

Running Caliper depends on Node. The download and installation of Node will not be repeated here.

First, caliper-benchmarks needs to be downloaded to the specified file path location. Because after reading the relevant configuration files of caliper-benchmarks, I found that its yaml file uses a relative path to locate the files in the test-network, and it needs to be downloaded to the upper-level directory of fabric-sample to execute correctly. Of course, you can also download it to a location at will, and then modify the configuration content of caliper-benchmarks, it's okay. As shown, this is where I downloaded it

 Then execute:

git clone https://github.com/hyperledger/caliper-benchmarks

Then open the caliper-benchmarks folder

cd caliper-benchmarks

Execute the following command to install the specified version of hyperledger caliper

npm init -y
npm install --only=prod @hyperledger/[email protected]  # 0.4.2对应的是fabric2.x,0.3.2对应fabric1.x
npx caliper bind --caliper-bind-sut fabric:2.4  # 绑定,这里用的2.4,因为2.3无,2.2也可以

 After binding, use the following command to view the installed caliper version

npx caliper --version

2 Deploy the chaincode

Execute sequentially

cd ../fabric-samples/test-network  # 回到test-network文件夹
./network.sh down
./network.sh up createChannel

Here, we will deploy the fabcar sample that comes with caliper for testing

./network.sh deployCC -ccn fabcar -ccp ../../caliper-benchmarks/src/fabric/samples/fabcar/go -ccl go

3 to test

After the deployment is successful, go back to the caliper-benchmarks directory

cd ../../caliper-benchmarks/

We will execute the test case matching the fabcar we just deployed

npx caliper launch manager \
--caliper-workspace ./ \
--caliper-networkconfig networks/fabric/test-network.yaml \
--caliper-benchconfig benchmarks/samples/fabric/fabcar/config.yaml \
--caliper-flow-only-test \
--caliper-fabric-gateway-enabled

 This is the performance test that has already started, and the test results are shown in the figure below

 It can be seen that we conducted four tests. Succ in this report is the number of successful transactions, Latency is the delay, and Throughput is the throughput. Moreover, the test result will also be saved in report.html under the caliper-benchmarks folder in the form of an html file.

4 other

This blog focuses on the complete presentation of the operation process of using Caliper to perform performance testing on Fabric. During the execution process, in fact, many problems will still be encountered, such as the go path cannot be found, the npm dependency download is incomplete, the virtual machine server has problems, and so on. It is recommended to check the information, do not be discouraged. I have been through it, and I can overcome it.

Then students who can see this blog should have tried many solutions, and also found out that I am using this

git clone https://github.com/hyperledger/caliper-benchmarks

instead of

git clone https://github.com/hyperledger/caliper

 Yes. If you are in caliper and you have to use python2 when you go to node-gpy, considering that the current Linux distributions are all pre-installed with pyhton3 and other factors that are inconvenient to uninstall python3, if you still want to follow along Go the old way, I suggest you use anaconda, create a pyhton2 environment, then enter the python2 environment to solve this problem, and then challenge the next pit.


If you need to go deeper, you can refer to this new work

Interpretation of Caliper, modify the configuration file, adjust the transaction volume for performance testing (Chinese first release)

Guess you like

Origin blog.csdn.net/Sbs5218/article/details/126038751
Recommended