How to measure Hyperledger Fabric performance using Hyperledger Caliper in Kubernetes setting

1/4/2021

My fabric network is deployed in a local Kubernetes cluster(vagrant) using the following https://medium.com/swlh/how-to-implement-hyperledger-fabric-external-chaincodes-within-a-kubernetes-cluster-fd01d7544523 tutorial. The pods are up and running, and I was able to insert/read marbles from fabric-cli.

I was not able to configure caliper to measure the performance of my deployment. I ran the caliper 0.4.2 docker image in the same 'hyperledger' namespace.

the caliper deployment yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: caliper
  name: caliper
  namespace: hyperledger
spec:
  selector:
    matchLabels:
      app: caliper
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: caliper
    spec:
      containers:
        - env:
            - name: CALIPER_BIND_SUT
              value: fabric:2.2
            - name: CALIPER_BENCHCONFIG
              value: benchmarks/myAssetBenchmark.yaml
            - name: CALIPER_NETWORKCONFIG
              value: networks/networkConfig3.yaml
            - name: CALIPER_FABRIC_GATEWAY_ENABLED
              value: "true"
            - name: CALIPER_FLOW_ONLY_TEST
              value: "true"
          image: hyperledger/caliper:0.4.2
          name: caliper
          command:
            - caliper
          args:
            - launch
            - manager
          tty: true
          volumeMounts:
            - mountPath: /hyperledger/caliper/workspace
              name: caliper-workspace
            - mountPath: /hyperledger/caliper/fabric-samples
              name: fabric-workspace
          workingDir: /hyperledger/caliper/workspace
      restartPolicy: Always
      volumes:
        - name: caliper-workspace
          hostPath:
            path: /home/vagrant/caliper-workspace
            type: Directory
        - name: fabric-workspace
          hostPath:
            path: /home/vagrant/fabr          volumeMounts:
            - mountPath: /hyperledger/caliper/workspace
              name: caliper-workspace
            - mountPath: /hyperledger/caliper/fabric-samples
              name: fabric-workspace
          workingDir: /hyperledger/caliper/workspace
      restartPolicy: Always
      volumes:
        - name: caliper-workspace
          hostPath:
            path: /home/vagrant/caliper-workspace
            type: Directory
        - name: fabric-workspace
          hostPath:
            path: /home/vagrant/fabric-external-chaincodes/
            type: Directoryic-external-chaincodes/
            type: Directory

I followed https://hyperledger.github.io/caliper/v0.4.2/fabric-tutorial/tutorials-fabric-existing/ documentation on running caliper alongside existing fabric network. the networkconfig3.yaml file

name: Fabric
version: '2.0.0'
mutual-tls: true

caliper:
  blockchain: fabric
  sutOptions:
    mutualTls: true 

channels:
  - channelName: mychannel
    contracts:
    - id: marbles

organizations:
  - mspid: org1MSP
    identities:
      certificates:
      - name: 'Admin'
        admin: true
        clientPrivateKey:
          path: '../fabric-samples/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/keystore/priv_sk'
        clientSignedCert:
          path: '../fabric-samples/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/signcerts/Admin@org1-cert.pem'
      - name: 'User1'
        clientPrivateKey:
          path: '../fabric-samples/crypto-config/peerOrganizations/org1/users/User1@org1/msp/keystore/priv_sk'
        clientSignedCert:
          path: '../fabric-samples/crypto-config/peerOrganizations/org1/users/User1@org1/msp/signcerts/User1@org1-cert.pem'
    connectionProfile:
      path: 'networks/profile-org1.yaml'
      discover: true

the org1 connection profile will look like

name: Fabric
version: '1.0.0'

client:
  organization: org1
  connection:
    timeout:
      peer:
        endorser: '300'

organizations:
  org1:
    mspid: org1MSP
    peers:
    - peer0-org1

peers:
  peer0-org1:
    url: grpcs://peer0-org1:7051
    grpcOptions:
      ssl-target-name-override: peer0-org1
      grpc.keepalive_time_ms: 600000
    tlsCACerts:
      path: ../fabric-samples/crypto-config/peerOrganizations/org1/peers/peer0-org1/msp/tlscacerts/tlsca.org1-cert.pem

the myAssetBenchmark.yaml file

test:
    name: marble-benchmark
    description: test benchmark
    workers:
      type: local
      number: 2
    rounds:
    - label: initMarble
      description: init marbles benchmark
      txNumber: 100
      rateControl:
        type: fixed-load
        opts:
          tps: 25
      workload:
        module: workload/init.js
monitor:
  type:
  - none

observer:
  type: local
  interval: 1

The caliper is failing because the connection to the peers is not going through. 2021-01-05T04:37:55.592Z - ^[[32minfo^[[39m: [NetworkConfig]: buildPeer - Unable to connect to the endorser peer0-org1 due to Error: Failed to connect before the deadline on Endorser- name: peer0-org1, url:grpcs://peer0-org1:7051, connected:false, connectAttempted:true

some more error logs

2021-01-04T01:08:35.466Z - error: [DiscoveryService]: send[mychannel] - no discovery results
2021-01-04T01:08:38.473Z - error: [ServiceEndpoint]: Error: Failed to connect before the deadline on Discoverer- name: peer0-org1, url:grpcs://peer0-org1:7051, connected:false, connectAttempted:true
2021-01-04T01:08:38.473Z - error: [ServiceEndpoint]: waitForReady - Failed to connect to remote gRPC server peer0-org1 url:grpcs://peer0-org1:7051 timeout:3000
2021-01-04T01:08:38.473Z - error: [ServiceEndpoint]: ServiceEndpoint grpcs://peer0-org1:7051 reset connection failed :: Error: Failed to connect before the deadline on Discoverer- name: peer0-org1, url:grpcs://peer0-org1:7051, connected:false, connectAttempted:true

What are the issues with my current configuration? Is there any blog or documentation to look more?

-- Arun Joseph
hyperledger
hyperledger-caliper
hyperledger-fabric
kubernetes

1 Answer

1/5/2021

Your connection profile doesn't look correct as you haven't specified the tlsCACert information correctly. As you need to use a connection profile that works with node 2.2 the following might work

name: Fabric

organizations:
  org1:
    mspid: org1MSP
    peers:
    - peer0-org1

peers:
  peer0-org1:
    url: grpcs://peer0-org1:7051
    tlsCACerts:
      path: ../fabric-samples/crypto-config/peerOrganizations/org1/peers/peer0-org1/msp/tlscacerts/tlsca.org1-cert.pem

there are some details here about the node sdk 2.2 expected format for the connection profile but I'm not sure how correct they are https://hyperledger.github.io/fabric-sdk-node/release-2.2/tutorial-commonconnectionprofile.html

-- david_k
Source: StackOverflow