压力测试(caliper具体步骤+示例)

Caliper压力测试(具体步骤+示例)

一、Caliper压力测试指南

1. 环境要求

(1)配置基本环境

  • 部署Caliper的计算机需要有外网权限;

    在这里插入图片描述
    在这里插入图片描述

    解决方法:

    #通常情况下,DNS 服务器由你的网络配置提供。你可以查看当前的 DNS 设置:
    
    cat /etc/resolv.conf
    
    oot@thy-virtual-machine:/home/thy/fisco# cat /etc/resolv.conf
    # This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
    # Do not edit.
    #
    # This file might be symlinked as /etc/resolv.conf. If you're looking at
    # /etc/resolv.conf and seeing this text, you have followed the symlink.
    #
    # This is a dynamic resolv.conf file for connecting local clients to the
    # internal DNS stub resolver of systemd-resolved. This file lists all
    # configured search domains.
    #
    # Run "resolvectl status" to see details about the uplink DNS servers
    # currently in use.
    #
    # Third party programs should typically not access this file directly, but only
    # through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
    # different way, replace this symlink by a static file or a different symlink.
    #
    # See man:systemd-resolved.service(8) for details about the supported modes of
    # operation for /etc/resolv.conf.
    
    nameserver 127.0.0.53
    options edns0 trust-ad
    search .
    
    #确保 nameserver 条目指向正确的 DNS 服务器。如果看起来不正确或有问题,可以尝试手动修改为已知可靠的 DNS 服务器,如 Google 的公共 DNS:
    
    echo "nameserver 8.8.8.8" > /etc/resolv.conf 或者
    vim /etc/resolv.conf
    
    # This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
    # Do not edit.
    #
    # This file might be symlinked as /etc/resolv.conf. If you're looking at
    # /etc/resolv.conf and seeing this text, you have followed the symlink.
    #
    # This is a dynamic resolv.conf file for connecting local clients to the
    # internal DNS stub resolver of systemd-resolved. This file lists all
    # configured search domains.
    #
    # Run "resolvectl status" to see details about the uplink DNS servers
    # currently in use.
    #
    # Third party programs should typically not access this file directly, but only
    # through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
    # different way, replace this symlink by a static file or a different symlink.
    #
    # See man:systemd-resolved.service(8) for details about the supported modes of
    # operation for /etc/resolv.conf.
    
    nameserver 8.8.8.8  ####修改为8.8.8.8
    options edns0 trust-ad
    search localdomain
    ~                                                                                                                                   
    ~                                                                                                                                   
    ~                     
    
    #如果你对配置进行了更改,可能需要重新启动 systemd-resolved 服务使其加载新的配置:
    
    sudo systemctl restart systemd-resolved
    
    
  • 操作系统版本需要满足以下要求:Ubuntu >= 16.04、CentOS >= 7或MacOS >= 10.14;

  • 部署Caliper的计算机需要安装有以下软件:python 2.7、make、g++、gcc及git。

2. NodeJS

  • 版本要求:

    NodeJS 8 (LTS), 9, 或 10 (LTS),Caliper尚未在更高的NodeJS版本中进行过验证。

  • 安装指南:

    建议使用nvm(Node Version Manager)安装,nvm的安装方式如下:

# 安装nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash

# 若出现因网络问题导致长时间下载失败,可尝试以下命令
curl -o- https://gitee.com/mirrors/nvm/raw/v0.33.2/install.sh | bash

# 加载nvm配置
source ~/.$(basename $SHELL)rc
# 安装Node.js 8
nvm install 8
# 使用Node.js 8
nvm use 8

查看可用版本:

nvm ls-remote

安装具体版本

nvm install 8.17.0

验证安装:

在这里插入图片描述

3.部署Docker

# 更新包索引
sudo apt-get update
# 安装基础依赖库
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
# 添
### 如何使用Caliper进行区块链性能压力测试配置与执行 #### 测试环境准备 为了确保Caliper能够顺利运行,在开始之前需确认已安装Node.js以及npm。对于Caliper本身的安装,推荐采用全局安装方式以便于命令行调用: ```bash npm install -g @hyperledger/caliper-cli --only=prod ``` 此方法仅安装Caliper的核心组件以减少不必要的依赖项加载时间[^3]。 #### 配置文件编写 应用层通过特定的配置文件定义测试场景,该文件包含了关于底层区块链网络设置的信息和具体的测试参数。一个典型的Caliper配置文件结构如下所示: - `networkConfig`:描述目标区块链系统的连接细节; - `workloadModules`:指明工作负载模块的位置路径; - `caliperBenchmarks`:设定基准测试的具体指标和其他选项。 例如,创建一个新的目录作为项目的根目录,并在此基础上建立必要的子文件夹和JSON/YAML格式的配置文档[^2]。 #### 执行基准测试 当所有的准备工作就绪之后,可以利用CLI工具启动实际的压力测试过程。具体来说就是运用`npx caliper benchmark run`这条指令来触发整个流程。在此之前可能还需要额外指定一些参数,比如要使用的配置文件位置等[^1]。 ```bash npx caliper benchmark run \ --caliper-workspace /path/to/your/project/root/directory \ --caliper-benchmark/configuration your_benchmark_config.yaml \ --caliper-network/configuration network_connection.json ``` 上述命令中的路径应当替换为真实的文件所在之处。这一步骤将会依据所提供的配置自动完成一系列动作——从初始化到最终的结果汇总输出。 #### 结果评估 一旦测试结束,Caliper会自动生成一份详细的HTML格式报告,其中涵盖了诸如吞吐量(TPS)、响应延迟(latency)及成功率(success rate)等多项关键性能指标的数据统计图表。这些可视化的内容有助于直观理解被测对象的表现特征及其潜在瓶颈所在。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

什么都想学。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值