测试配置用于指定测试的具体运行方式。测试配置是一个YAML文件,HelloWorld合约的测试配置文件内容如下所示:

---
test:
  name: Hello World
  description: This is a helloworld benchmark of FISCO BCOS for caliper
  clients:
    type: local
    number: 1
  rounds:
  - label: get
    description: Test performance of getting name
    txNumber:
    - 10000
    rateControl:
    - type: fixed-rate
      opts:
        tps: 1000
    callback: benchmarks/samples/fisco-bcos/helloworld/get.js
  - label: set
    description: Test performance of setting name
    txNumber:
    - 10000
    rateControl:
    - type: fixed-rate
      opts:
        tps: 1000
    callback: benchmarks/samples/fisco-bcos/helloworld/set.js
monitor:
  type:
  - docker
  docker:
    name:
    - http://192.168.1.1:2375/node0
    - http://192.168.1.2:2375/node1
    - http://192.168.1.3:2375/node2
    - http://192.168.1.4:2375/node3
  interval: 0.1
测试文件中主要包括两部分:
  • 测试内容配置

test项负责对测试内容进行配置。

配置主要集中在round字段中指定如何对区块链系统进行测试。

每一个测试可以包含多轮,每一轮可以向区块链发起不同的测试请求。

具体要HelloWorld合约测试,测试中包含两轮,分别对合约的get接口和set接口进行测试。

在每一轮测试中,可以通过txNumbertxDuration字段指定测试的交易发送数量或执行时间,并通过rateControl字段指定交易发送时的速率控制器,在本节的示例中,使用了QPS为1000的匀速控制器,更多速率控制器的介绍可以参考官方文档

 

  • 性能监视器配置

monitor项负责对测试所使用的性能监视器的进行配置。每项配置项的解释如下:

  1. monitor.type,需要指定为docker,指对docker容器进行监控;
  2. monitor.docker.name,一个包含所有要监视的节点的docker容器名称列表,名字必须以http://开头,其后跟随”{节点的IP}:{节点docker daemon端口}/{docker容器的名称}”;
  3. monitor.interval,监视器的采样间隔,单位为秒。

如果是在本地搭好的链,则可以添加本地性能监视器,相应地监视器的配置更改如下:

monitor:
  type:
  - process
  process:
    - command: node0
      multiOutput: avg
    - command: node1
      multiOutput: avg
    - command: node2
      multiOutput: avg
    - command: node3
      multiOutput: avg
  interval: 0.1

 

其中每项配置项的解释如下:

  1. monitor.type,需要指定为process,只对进程进行监控;
  2. monitor.process,一个包含所有要监视的进称列表,其中每个进程的command属性为一个正则表达式,表示进程名称;每个进程还可以有一个arguments属性(未在上述示例中使用到),表示进程的参数。Caliper会先使用ps命令搜索commad + arguments,然后匹配以得到目标的进程的进程ID及系统资源的使用情况。每个进程的multiOutput属性用于指定结果的输出方式,目前支持平均值(avg)及总和(sum)两种方式;
  3. monitor.interval,监视器的采样间隔,单位为秒。

需要注意的是,进程监控目前暂不支持监控进程对网络和磁盘的使用情况。

https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/tutorial/stress_testing.html?docker-compose