You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Hyperledger Caliper测试Hyperledger Composer性能的可行性及配置指导

Absolutely! You can absolutely use Hyperledger Caliper to run performance tests on a Hyperledger Composer network deployed on Hyperledger Fabric. Since Composer is built directly on top of Fabric, the process just involves tweaking Caliper's configuration to target the underlying Fabric infrastructure powering your Composer business network. Below is a step-by-step guide to get this set up:

Prerequisites

First, make sure you have these in place:

  • A running Hyperledger Composer business network (deployed to a Fabric network)
  • Hyperledger Caliper installed locally (matching version compatibility with your Fabric/Composer setup)
  • Administrative access to your Composer network (with a valid identity card)
Key Configuration Steps

1. Extract the Fabric Connection Profile from Composer

Composer uses a wrapped version of Fabric's connection profile. To get the raw profile Caliper needs:

  • Export your Composer admin identity card using:
    composer card export -c admin@your-business-network-name
    
  • Unzip the exported .card file. Inside, you'll find a connection.json file—this is the standard Fabric connection profile you'll use for Caliper.
  • Verify the file includes all your Fabric nodes (orderers, peers, CAs) and correct paths to TLS certificates (if TLS is enabled). Adjust paths to match where Caliper will run (e.g., absolute paths if needed).

2. Configure Caliper's Network Settings

Create or modify a networkConfig.yaml file for Caliper with these details:

networks:
  fabric:
    type: fabric
    version: 1.4.x # Match your Fabric version (Composer v0.20 uses Fabric 1.4)
    connectionProfile: ./path/to/extracted/connection.json
    wallets:
      type: "fabric-wallet"
      path: "./caliper-wallet"
  • Next, populate the caliper-wallet directory with your Composer admin identity:
    • From the unzipped .card file, copy the credentials folder's contents (certificate and private key) into a subfolder of caliper-wallet (e.g., ./caliper-wallet/admin).
    • Rename the certificate to cert.pem and the private key to priv_sk (matching Fabric wallet conventions).

3. Set Up the Benchmark Configuration

Create a benchmark.yaml file to define your test parameters:

tests:
  - label: "composer-asset-creation-test"
    description: "Performance test for creating assets via Composer transactions"
    workers:
      number: 5
    rounds:
      - label: "create-sample-asset"
        description: "Invoke the CreateSampleAsset transaction"
        txNumber: 100
        rateControl:
          type: "fixed-rate"
          opts:
            tps: 10
        workload:
          module: "./workloads/createAsset.js"
          arguments:
            chaincodeID: "your-business-network-name@0.0.1" # Get this from Composer
            channelName: "your-fabric-channel-name"
  • Find your Composer chaincode ID: Run composer network list -c admin@your-business-network-name—the chaincode ID follows the format {network-name}@{version}.

4. Write the Caliper Workload Script

Create a workloads/createAsset.js script to invoke Composer transactions (Composer transactions are called via Fabric's invoke chaincode method):

const caliper = require('@hyperledger/caliper-core');

module.exports.createWorkload = async function (workerIndex, args) {
    const fabricClient = await caliper.getConnectorClient();
    const channel = fabricClient.getChannel(args.channelName);
    const chaincodeId = args.chaincodeID;

    // Construct Composer transaction arguments: [transactionName, param1, param2, ...]
    const txArgs = [
        'CreateSampleAsset',
        `asset-${workerIndex}-${Date.now()}`,
        'test-value',
        'test-owner'
    ];

    const request = {
        chaincodeId: chaincodeId,
        fcn: 'invoke',
        args: txArgs,
        channelId: args.channelName
    };

    return channel.sendTransactionProposal(request);
};
  • Adjust the transaction name and parameters to match your Composer business network's defined transactions.

5. Run the Performance Test

Execute the test with this Caliper command:

npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networkConfig.yaml --caliper-benchconfig benchmark.yaml --caliper-flow-only-test
  • Add --caliper-logging debug if you need detailed logs to troubleshoot issues.
Critical Notes
  • Version Compatibility: Ensure your Caliper version supports your Fabric/Composer stack. For example:
    • Composer v0.20.x → Fabric 1.4.x → Caliper v0.4.x
  • Identity Permissions: The admin identity you use must have the necessary Fabric channel/chaincode permissions to execute the Composer transactions (this is usually set up during Composer network deployment, but double-check if tests fail with permission errors).
  • Resource Allocation: Make sure your Fabric network has enough resources (CPU, memory) to handle the test load—Caliper can generate significant traffic.

内容的提问来源于stack exchange,提问作者ethertest

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:26:41