Config.yaml是Caliper中用于配置测试参数的YAML格式文件,它包括测试网络的连接信息、测试的轮数、测试数据的生成方式、测试结果的存储方式等。在区块链测试中,它是非常重要的配置文件,可以用于控制测试的各个方面,从而进行全面和深入的性能测试。
本文将详细解释config.yaml文件的每个字段,包括测试名称、测试描述、客户端类型、测试轮次、测试标签、测试描述、测试交易数量、速率控制、测试回调函数、监控信息等。同时,还将介绍如何根据不同的测试需求来修改和调整config.yaml文件。
配置文件详解
config.yaml
是一个YAML格式的配置文件,用于配置测试的相关参数。下面我们逐一解释每个字段的含义。
test
test
字段是整个配置文件的最外层,用于描述测试的基本信息。具体包括:
-
name
:测试名称。 -
description
:测试描述。 -
clients
:客户端信息。包括客户端类型和数量。
rounds
rounds
字段用于描述测试的轮次,每个轮次对应一组测试。其中,每个轮次又包括以下字段:
-
label
:测试标签,用于区分不同的测试轮次。 -
description
:测试描述。 -
txNumber
:测试交易数量,即每个轮次要执行的交易数。 -
rateControl
:速率控制。支持fixed-rate
和fixed-count
两种类型,分别表示按照固定速率和固定数量执行交易。 -
callback
:测试回调函数。指定测试所使用的JavaScript文件,用于执行具体的测试操作。
monitor
monitor
字段用于描述测试过程中的监控信息。具体包括:
-
type
:监控类型,支持docker
和process
两种类型。 -
docker
:用于指定要监控的Docker容器名称。 -
process
:用于指定要监控的进程信息。 -
interval
:监控的时间间隔。
除了上述字段外,config.yaml
还支持其他一些配置参数,比如:
-
blockchain
:用于指定区块链网络的连接信息。 -
workload
:用于指定测试数据的生成方式。 -
storage
:用于指定测试结果的存储方式。
入门案例
---
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
- process
docker: # 监控节点
name:
- node0
- node1
- node2
- node3
process: # 监控进程
- command: node
arguments: fiscoBcosClientWorker.js
multiOutput: avg
interval: 0.5