From 9c39b178b6467d34606b9a3a0c7b5f306dace35a Mon Sep 17 00:00:00 2001 From: Adnan Choudhury Date: Wed, 15 Mar 2017 21:06:06 -0400 Subject: [PATCH] [FAB-2803] Update e2e readme to reflect TLS change https://jira.hyperledger.org/browse/FAB-2803 Updating the documentation for the end-to-end example to reflect the TLS changes, which the automated script exercises. Also, updating other commands in the readme to follow the script. Change-Id: If73345554b6c23efa0af3f4854592a955bc95ebe Signed-off-by: Adnan Choudhury --- examples/e2e_cli/end-to-end.rst | 94 ++++++++++++++++----------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/examples/e2e_cli/end-to-end.rst b/examples/e2e_cli/end-to-end.rst index 296ff08e80e..b3bb0c83654 100644 --- a/examples/e2e_cli/end-to-end.rst +++ b/examples/e2e_cli/end-to-end.rst @@ -141,8 +141,8 @@ directory. configtxgen -profile TwoOrgs -outputCreateChannelTx -channelID # example: configtxgen -profile TwoOrgs -outputCreateChannelTx channel.tx -channelID mychannel -Run the end-to-end test ------------------------ +Run the end-to-end test with Docker +----------------------------------- Make sure you are in the ``/e2e_cli`` directory. Then use docker-compose to spawn the network entities and drive the tests. @@ -305,8 +305,8 @@ output from each container: ex02 Invoke Query Response:{"Name":"a","Amount":"90"} -Manually create the channel and join peers through CLI ------------------------------------------------------- +Run the end-to-end test manually with Docker +-------------------------------------------- From your vagrant environment exit the currently running containers: @@ -369,8 +369,10 @@ Command syntax Refer to the create and join commands in the ``script.sh``. -For any of the following commands to work, you need to preface the -commands with the following environment variables. +For the following CLI commands against `peer0` to work, you need to set the +values for four environment variables, given below. Please make sure to override +the values accordingly when calling commands against other peers and the +orderer. .. code:: bash @@ -378,6 +380,7 @@ commands with the following environment variables. CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer0/localMspConfig CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_LOCALMSPID="Org0MSP" + CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer0/localMspConfig/cacerts/peerOrg0.pem These environment variables for each peer are defined in the supplied docker-compose file. @@ -406,18 +409,20 @@ with a different name. # the channel.tx and orderer.block are mounted in the crypto/orderer folder within your cli container # as a result, we pass the full path for the file - peer channel create -o orderer:7050 -c mychannel -f crypto/orderer/channel.tx + peer channel create -o orderer0:7050 -c mychannel -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -Recall that the environment variables are required for this manual -operation. So the command in its entirety would be: +Since the `channel create` runs against the orderer, we need to override the +four environment variables set before. So the above command in its entirety would be: .. code:: bash - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer0/localMspConfig CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_LOCALMSPID="Org0MSP" peer channel create -o orderer:7050 -c mychannel -f crypto/orderer/channel.tx + CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig CORE_PEER_LOCALMSPID="OrdererMSP" peer channel create -o orderer0:7050 -c mychannel -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem + **Note**: You will remain in the CLI container for the remainder of these manual commands. You must also remember to preface all commands -with the corresponding env variables for the targeted peer. +with the corresponding environment variables for targetting a peer other than +`peer0`. Join channel ^^^^^^^^^^^^ @@ -426,14 +431,12 @@ Join specific peers to the channel .. code:: bash + # By default, this joins PEER0 only # the mychannel.block is also mounted in the crypto/orderer directory peer channel join -b mychannel.block -This command in its entirety would be: - -.. code:: bash - - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer0/localMspConfig CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_LOCALMSPID="Org0MSP" peer channel join -b crypto/orderer/mychannel.block +You can make other peers join the channel as necessary by making appropriate +changes in the four environment variables. Install chaincode onto a remote peer ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -450,13 +453,12 @@ Instantiate chaincode and define the endorsement policy Instantiate the chaincode on a peer. This will launch a chaincode container for the targeted peer and set the endorsement policy for the chaincode. In this snippet, we define the policy as requiring an -endorsement from one peer node that is a part of Org1. In our scenario, -this is ``PEER2`` or ``PEER3`` +endorsement from one peer node that is a part of either `Org0` or `Org1`. +The command is: .. code:: bash - # - peer chaincode instantiate -o orderer:7050 -C mychannel -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}' -P "AND('Org1MSP.member')" + peer chaincode instantiate -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org0MSP.member','Org1MSP.member')" See the `endorsement policies `__ @@ -467,7 +469,7 @@ Invoke chaincode .. code:: bash - peer chaincode invoke -o orderer:7050 -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}' + peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}' **NOTE**: Make sure to wait a few seconds for the operation to complete. @@ -484,8 +486,8 @@ The result of the above command should be as below: Query Result: 90 -Using the native binaries -------------------------- +Run the end-to-end test using the native binaries +------------------------------------------------- Open your vagrant environment: @@ -568,7 +570,7 @@ Ask peer to create a channel with the configuration parameters in .. code:: bash - peer channel create -o orderer:7050 -c mychannel -f channel.tx + peer channel create -o 127.0.0.1:7050 -c mychannel -f channel.tx This will return a channel genesis block - ``mychannel.block`` - in your current directory. @@ -589,7 +591,7 @@ Install chaincode on the peer: .. code:: bash - peer chaincode install -o orderer:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 + peer chaincode install -o 127.0.0.1:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 Make sure the chaincode is in the filesystem: @@ -606,7 +608,7 @@ Instantiate the chaincode: .. code:: bash - peer chaincode instantiate -o orderer:7050 -C mychannel -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}' + peer chaincode instantiate -o 127.0.0.1:7050 -C mychannel -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}' Check your active containers: @@ -628,7 +630,7 @@ Issue an invoke to move "10" from "a" to "b": .. code:: bash - peer chaincode invoke -o orderer:7050 -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}' + peer chaincode invoke -o 127.0.0.1:7050 -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}' Wait a few seconds for the operation to complete @@ -640,7 +642,7 @@ Query for the value of "a": .. code:: bash # this should return 90 - peer chaincode query -o orderer:7050 -C mychannel -n mycc -c '{"Args":["query","a"]}' + peer chaincode query -o 127.0.0.1:7050 -C mychannel -n mycc -c '{"Args":["query","a"]}' Don't forget to clear ledger folder ``/var/hyperledger/`` after each run! @@ -691,29 +693,27 @@ capabilities you will need to use a chaincode that has data modeled as JSON, Install, instantiate, invoke, and query *marbles02* chaincode by following the same general steps outlined above for *chaincode_example02* in the **Manually -create the channel and join peers through CLI** section . After the **Join +create the channel and join peers through CLI** section. After the **Join channel** step, use the following steps to interact with the *marbles02* -chaincode: +chaincode: -- Install and instantiate the chaincode in ``peer0`` (replace ``$ORDERER_IP`` - with the IP address of the orderer. One way to find the address is with the - command ``docker inspect orderer | grep \"IPAddress\"``): +- Install and instantiate the chaincode in ``peer0``: .. code:: bash - peer chaincode install -o $ORDERER_IP:7050 -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02 - peer chaincode instantiate -o $ORDERER_IP:7050 -C $mychannel -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02 -c '{"Args":["init"]}' -P "OR ('Org0MSP.member','Org1MSP.member')" + peer chaincode install -o orderer0:7050 -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02 + peer chaincode instantiate -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02 -c '{"Args":["init"]}' -P "OR ('Org0MSP.member','Org1MSP.member')" - Create some marbles and move them around: .. code:: bash - peer chaincode invoke -o $ORDERER_IP:7050 -C mychannel -n marbles -c '{"Args":["initMarble","marble1","blue","35","tom"]}' - peer chaincode invoke -o $ORDERER_IP:7050 -C mychannel -n marbles -c '{"Args":["initMarble","marble2","red","50","tom"]}' - peer chaincode invoke -o $ORDERER_IP:7050 -C mychannel -n marbles -c '{"Args":["initMarble","marble3","blue","70","tom"]}' - peer chaincode invoke -o $ORDERER_IP:7050 -C mychannel -n marbles -c '{"Args":["transferMarble","marble2","jerry"]}' - peer chaincode invoke -o $ORDERER_IP:7050 -C mychannel -n marbles -c '{"Args":["transferMarblesBasedOnColor","blue","jerry"]}' - peer chaincode invoke -o $ORDERER_IP:7050 -C mychannel -n marbles -c '{"Args":["delete","marble1"]}' + peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c '{"Args":["initMarble","marble1","blue","35","tom"]}' + peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c '{"Args":["initMarble","marble2","red","50","tom"]}' + peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c '{"Args":["initMarble","marble3","blue","70","tom"]}' + peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c '{"Args":["transferMarble","marble2","jerry"]}' + peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c '{"Args":["transferMarblesBasedOnColor","blue","jerry"]}' + peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c '{"Args":["delete","marble1"]}' @@ -723,12 +723,12 @@ chaincode: For containers running in a vagrant environment: - ```http://localhost:15984/_utils``` + ``http://localhost:15984/_utils`` For non-vagrant environment, use the port address that was mapped in CouchDB container specification: - ```http://localhost:5984/_utils``` + ``http://localhost:5984/_utils`` You should see a database named ``mychannel`` and the documents inside it. @@ -737,7 +737,7 @@ chaincode: .. code:: bash - peer chaincode query -o $ORDERER_IP:7050 -C mychannel -n marbles -c '{"Args":["readMarble","marble2"]}' + peer chaincode query -C mychannel -n marbles -c '{"Args":["readMarble","marble2"]}' You should see the details of ``marble2``: @@ -751,7 +751,7 @@ chaincode: .. code:: bash - peer chaincode query -o $ORDERER_IP:7050 -C mychannel -n marbles -c '{"Args":["getHistoryForMarble","marble1"]}' + peer chaincode query -C mychannel -n marbles -c '{"Args":["getHistoryForMarble","marble1"]}' You should see the transactions on ``marble1``: @@ -765,7 +765,7 @@ chaincode: .. code:: bash - peer chaincode query -o $ORDERER_IP:7050 -C myc1 -n marbles -c '{"Args":["queryMarblesByOwner","jerry"]}' + peer chaincode query -C mychannel -n marbles -c '{"Args":["queryMarblesByOwner","jerry"]}' The output should display the two marbles owned by ``jerry``: @@ -777,7 +777,7 @@ chaincode: .. code:: bash - peer chaincode query -o $ORDERER_IP:7050 -C myc1 -n marbles -c '{"Args":["queryMarbles","{\"selector\":{\"owner\":\"jerry\"}}"]}' + peer chaincode query -C mychannel -n marbles -c '{"Args":["queryMarbles","{\"selector\":{\"owner\":\"jerry\"}}"]}' The output should display: