hyperledger-caliper / caliper

A blockchain benchmark framework to measure performance of multiple blockchain solutions https://wiki.hyperledger.org/display/caliper
https://hyperledger-caliper.github.io/caliper/
Apache License 2.0
653 stars 404 forks source link

What is the easiest way to use caliper with existing network and custom chaincodes? #544

Closed ghost closed 5 years ago

ghost commented 5 years ago

As the title suggests, we have implemented a custom network that uses custom chaincodes. However our chaincodes have been written in go-language so they are not compatible with composer and we would preferably like to run caliper tests on a network that is already running. I found this article from Medium but it seems to be really outdated.

So what would be the easiest way to use Caliper with our custom network and chaincodes? Is it easiest to edit out some code from the work-flow or is it possible to run docker-compose up and our chaincode installation scripts after that within the composer?

EDIT: Seems like there is a way to use fabric chaincodes in the src/contract/fabric folder. However another question still stands. Is there any way to run caliper on an existing network?

aklenik commented 5 years ago

@edysteri Technically speaking, Caliper always connects to an existing network. The example network configuration files have a start/end script, that spins up a local network, and Caliper connects to it. But you could do this separately, or not at all if your network is already running.

https://hyperledger.github.io/caliper/docs/Fabric_Configuration.html#channels

In this doc section, you can specify the channels, whether they already exist, and the same for chaincodes. You don't need to set the CC path if it's already installed, just set the ID and version (and maybe language), and Caliper will verify whether it exists on the target peers.

ghost commented 5 years ago

Oh, I should have known that it's not mandatory to provide that information. Thanks for your fast reply! I will try to advance with these tips.

nurhazbiy commented 4 years ago

@edysteri Technically speaking, Caliper always connects to an existing network. The example network configuration files have a start/end script, that spins up a local network, and Caliper connects to it. But you could do this separately, or not at all if your network is already running.

https://hyperledger.github.io/caliper/docs/Fabric_Configuration.html#channels

In this doc section, you can specify the channels, whether they already exist, and the same for chaincodes. You don't need to set the CC path if it's already installed, just set the ID and version (and maybe language), and Caliper will verify whether it exists on the target peers.

Hello, as my question is still related to your answer I will try to ask here. @aklenik you said that you don't need to set cc path, but when I remove cc path from network config, it shows error

2020-06-09T21:57:00.058Z - error: [Client.js]: installChaincode error Missing "chaincodePath" parameter in the proposal request

how can i skip installing chaincode?

aklenik commented 4 years ago

@nurhazbiy Caliper will query the target peers first to check whether the CC is installed. Make sure you set the correct id/version pair for the chaincode in your network configuration file. Then you should see in the logs that Caliper will skip the CC install step (the same method goes for instantiated CCs).