From 8f1fb0153386b27db3ed98c0960fbf861a5a252e Mon Sep 17 00:00:00 2001 From: Adnan Choudhury Date: Mon, 8 May 2017 15:19:41 -0400 Subject: [PATCH] [FAB-3733] Fix the CouchDB option for e2e_cli Include a docker-compose file that will work as an addition to existing docker-compose file and will 1) create the necessary CouchDB containers and 2) include the necessary environment variables in the peers. Deleting the previous directions in the existing docker-compose and updating the driver script so the CouchDB option can be run simply by calling the driver with and added parameter "couchdb". Also exposed all chaincode examples instead of just example02, because marbles02 (JSON based) is a better demonstration on CouchDB. Document update to follow. Change-Id: I9c4dbb1f08a6e07319077fb79942483a7782980f Signed-off-by: Adnan Choudhury --- .../e2e_cli/base/docker-compose-base.yaml | 54 ---------------- examples/e2e_cli/docker-compose-cli.yaml | 2 +- examples/e2e_cli/docker-compose-couch.yaml | 62 +++++++++++++++++++ examples/e2e_cli/network_setup.sh | 10 ++- 4 files changed, 71 insertions(+), 57 deletions(-) create mode 100644 examples/e2e_cli/docker-compose-couch.yaml diff --git a/examples/e2e_cli/base/docker-compose-base.yaml b/examples/e2e_cli/base/docker-compose-base.yaml index 09b592a87f6..f988ba3d745 100644 --- a/examples/e2e_cli/base/docker-compose-base.yaml +++ b/examples/e2e_cli/base/docker-compose-base.yaml @@ -26,20 +26,6 @@ services: ports: - 7050:7050 -## To enable CouchDB as state database, uncomment the following sections of this file: -## 1) couchdb containers -## 2) peer environment variables CORE_LEDGER_STATE_STATEDATABASE and -## CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS -## 3) couch container names in "depends_on" section - -# couchdb0: -# container_name: couchdb0 -# image: hyperledger/fabric-couchdb -## Uncomment the port mapping if you want to expose the CouchDB service, -## for example to utilize Fauxton User Interface in dev environments. -# ports: -# - "5984:5984" - peer0.org1.example.com: container_name: peer0.org1.example.com extends: @@ -50,8 +36,6 @@ services: - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 - CORE_PEER_LOCALMSPID=Org1MSP - # - CORE_LEDGER_STATE_STATEDATABASE=CouchDB - # - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984 volumes: - /var/run/:/host/var/run/ - ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp @@ -59,16 +43,6 @@ services: ports: - 7051:7051 - 7053:7053 - #depends_on: - # - couchdb0 - -# couchdb1: -# container_name: couchdb1 -# image: hyperledger/fabric-couchdb -## Uncomment the port mapping if you want to expose the CouchDB service, -## for example to utilize Fauxton User Interface in dev environments. -# ports: -# - "6984:5984" peer1.org1.example.com: container_name: peer1.org1.example.com @@ -81,8 +55,6 @@ services: - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051 - CORE_PEER_LOCALMSPID=Org1MSP - # - CORE_LEDGER_STATE_STATEDATABASE=CouchDB - # - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984 volumes: - /var/run/:/host/var/run/ - ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp @@ -91,16 +63,6 @@ services: ports: - 8051:7051 - 8053:7053 - #depends_on: - # - couchdb1 - -# couchdb2: -# container_name: couchdb2 -# image: hyperledger/fabric-couchdb -## Uncomment the port mapping if you want to expose the CouchDB service, -## for example to utilize Fauxton User Interface in dev environments. -# ports: -# - "7984:5984" peer0.org2.example.com: container_name: peer0.org2.example.com @@ -113,8 +75,6 @@ services: - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051 - CORE_PEER_LOCALMSPID=Org2MSP - # - CORE_LEDGER_STATE_STATEDATABASE=CouchDB - # - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984 volumes: - /var/run/:/host/var/run/ - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp @@ -122,16 +82,6 @@ services: ports: - 9051:7051 - 9053:7053 - #depends_on: - # - couchdb2 - -# couchdb3: -# container_name: couchdb3 -# image: hyperledger/fabric-couchdb -## Uncomment the port mapping if you want to expose the CouchDB service, -## for example to utilize Fauxton User Interface in dev environments. -# ports: -# - "8984:5984" peer1.org2.example.com: container_name: peer1.org2.example.com @@ -144,8 +94,6 @@ services: - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:7051 - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051 - CORE_PEER_LOCALMSPID=Org2MSP - # - CORE_LEDGER_STATE_STATEDATABASE=CouchDB - # - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984 volumes: - /var/run/:/host/var/run/ - ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp @@ -153,5 +101,3 @@ services: ports: - 10051:7051 - 10053:7053 - #depends_on: - # - couchdb3 diff --git a/examples/e2e_cli/docker-compose-cli.yaml b/examples/e2e_cli/docker-compose-cli.yaml index aca64f51323..fd800d4b7ca 100644 --- a/examples/e2e_cli/docker-compose-cli.yaml +++ b/examples/e2e_cli/docker-compose-cli.yaml @@ -52,7 +52,7 @@ services: command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT' volumes: - /var/run/:/host/var/run/ - - ./examples:/opt/gopath/src/github.com/hyperledger/fabric/examples + - ../chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/ - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts diff --git a/examples/e2e_cli/docker-compose-couch.yaml b/examples/e2e_cli/docker-compose-couch.yaml new file mode 100644 index 00000000000..e4d74d3db6b --- /dev/null +++ b/examples/e2e_cli/docker-compose-couch.yaml @@ -0,0 +1,62 @@ +version: '2' + +services: + couchdb0: + container_name: couchdb0 + image: hyperledger/fabric-couchdb + # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, + # for example map it to utilize Fauxton User Interface in dev environments. + ports: + - "5984:5984" + + peer0.org1.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984 + depends_on: + - couchdb0 + + couchdb1: + container_name: couchdb1 + image: hyperledger/fabric-couchdb + # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, + # for example map it to utilize Fauxton User Interface in dev environments. + ports: + - "6984:5984" + + peer1.org1.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984 + depends_on: + - couchdb1 + + couchdb2: + container_name: couchdb2 + image: hyperledger/fabric-couchdb + # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, + # for example map it to utilize Fauxton User Interface in dev environments. + ports: + - "7984:5984" + + peer0.org2.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984 + depends_on: + - couchdb2 + + couchdb3: + container_name: couchdb3 + image: hyperledger/fabric-couchdb + # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, + # for example map it to utilize Fauxton User Interface in dev environments. + ports: + - "8984:5984" + + peer1.org2.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984 + depends_on: + - couchdb3 diff --git a/examples/e2e_cli/network_setup.sh b/examples/e2e_cli/network_setup.sh index b044e47a662..584be923736 100755 --- a/examples/e2e_cli/network_setup.sh +++ b/examples/e2e_cli/network_setup.sh @@ -3,14 +3,16 @@ UP_DOWN="$1" CH_NAME="$2" CLI_TIMEOUT="$3" +IF_COUCHDB="$4" : ${CLI_TIMEOUT:="10000"} COMPOSE_FILE=docker-compose-cli.yaml +COMPOSE_FILE_COUCH=docker-compose-couch.yaml #COMPOSE_FILE=docker-compose-e2e.yaml function printHelp () { - echo "Usage: ./network_setup " + echo "Usage: ./network_setup <\$channel-name> <\$cli_timeout> .\nThe arguments must be in order." } function validateArgs () { @@ -48,7 +50,11 @@ function networkUp () { # channel configuration transaction source generateArtifacts.sh $CH_NAME - CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE up -d 2>&1 + if [ "${IF_COUCHDB}" == "couchdb" ]; then + CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1 + else + CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE up -d 2>&1 + fi if [ $? -ne 0 ]; then echo "ERROR !!!! Unable to pull the images " exit 1