Skip to content

Commit

Permalink
[FAB-3733] Fix the CouchDB option for e2e_cli
Browse files Browse the repository at this point in the history
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 <adnan.choudhury@itpeoplecorp.com>
  • Loading branch information
adnan-c authored and denyeart committed May 16, 2017
1 parent 2470d35 commit 8f1fb01
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 57 deletions.
54 changes: 0 additions & 54 deletions examples/e2e_cli/base/docker-compose-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -50,25 +36,13 @@ 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
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -113,25 +75,13 @@ 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
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
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
Expand All @@ -144,14 +94,10 @@ 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
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 10051:7051
- 10053:7053
#depends_on:
# - couchdb3
2 changes: 1 addition & 1 deletion examples/e2e_cli/docker-compose-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
62 changes: 62 additions & 0 deletions examples/e2e_cli/docker-compose-couch.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 8 additions & 2 deletions examples/e2e_cli/network_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <up|down> <channel-name>"
echo "Usage: ./network_setup <up|down> <\$channel-name> <\$cli_timeout> <couchdb>.\nThe arguments must be in order."
}

function validateArgs () {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f1fb01

Please sign in to comment.