Skip to content

Commit 8f1fb01

Browse files
adnan-cdenyeart
authored andcommitted
[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 <[email protected]>
1 parent 2470d35 commit 8f1fb01

File tree

4 files changed

+71
-57
lines changed

4 files changed

+71
-57
lines changed

examples/e2e_cli/base/docker-compose-base.yaml

-54
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ services:
2626
ports:
2727
- 7050:7050
2828

29-
## To enable CouchDB as state database, uncomment the following sections of this file:
30-
## 1) couchdb containers
31-
## 2) peer environment variables CORE_LEDGER_STATE_STATEDATABASE and
32-
## CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS
33-
## 3) couch container names in "depends_on" section
34-
35-
# couchdb0:
36-
# container_name: couchdb0
37-
# image: hyperledger/fabric-couchdb
38-
## Uncomment the port mapping if you want to expose the CouchDB service,
39-
## for example to utilize Fauxton User Interface in dev environments.
40-
# ports:
41-
# - "5984:5984"
42-
4329
peer0.org1.example.com:
4430
container_name: peer0.org1.example.com
4531
extends:
@@ -50,25 +36,13 @@ services:
5036
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
5137
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
5238
- CORE_PEER_LOCALMSPID=Org1MSP
53-
# - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
54-
# - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
5539
volumes:
5640
- /var/run/:/host/var/run/
5741
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
5842
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
5943
ports:
6044
- 7051:7051
6145
- 7053:7053
62-
#depends_on:
63-
# - couchdb0
64-
65-
# couchdb1:
66-
# container_name: couchdb1
67-
# image: hyperledger/fabric-couchdb
68-
## Uncomment the port mapping if you want to expose the CouchDB service,
69-
## for example to utilize Fauxton User Interface in dev environments.
70-
# ports:
71-
# - "6984:5984"
7246

7347
peer1.org1.example.com:
7448
container_name: peer1.org1.example.com
@@ -81,8 +55,6 @@ services:
8155
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051
8256
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
8357
- CORE_PEER_LOCALMSPID=Org1MSP
84-
# - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
85-
# - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
8658
volumes:
8759
- /var/run/:/host/var/run/
8860
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
@@ -91,16 +63,6 @@ services:
9163
ports:
9264
- 8051:7051
9365
- 8053:7053
94-
#depends_on:
95-
# - couchdb1
96-
97-
# couchdb2:
98-
# container_name: couchdb2
99-
# image: hyperledger/fabric-couchdb
100-
## Uncomment the port mapping if you want to expose the CouchDB service,
101-
## for example to utilize Fauxton User Interface in dev environments.
102-
# ports:
103-
# - "7984:5984"
10466

10567
peer0.org2.example.com:
10668
container_name: peer0.org2.example.com
@@ -113,25 +75,13 @@ services:
11375
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
11476
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
11577
- CORE_PEER_LOCALMSPID=Org2MSP
116-
# - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
117-
# - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984
11878
volumes:
11979
- /var/run/:/host/var/run/
12080
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
12181
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
12282
ports:
12383
- 9051:7051
12484
- 9053:7053
125-
#depends_on:
126-
# - couchdb2
127-
128-
# couchdb3:
129-
# container_name: couchdb3
130-
# image: hyperledger/fabric-couchdb
131-
## Uncomment the port mapping if you want to expose the CouchDB service,
132-
## for example to utilize Fauxton User Interface in dev environments.
133-
# ports:
134-
# - "8984:5984"
13585

13686
peer1.org2.example.com:
13787
container_name: peer1.org2.example.com
@@ -144,14 +94,10 @@ services:
14494
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:7051
14595
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051
14696
- CORE_PEER_LOCALMSPID=Org2MSP
147-
# - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
148-
# - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984
14997
volumes:
15098
- /var/run/:/host/var/run/
15199
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
152100
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
153101
ports:
154102
- 10051:7051
155103
- 10053:7053
156-
#depends_on:
157-
# - couchdb3

examples/e2e_cli/docker-compose-cli.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ services:
5252
command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT'
5353
volumes:
5454
- /var/run/:/host/var/run/
55-
- ./examples:/opt/gopath/src/github.com/hyperledger/fabric/examples
55+
- ../chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go
5656
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
5757
- ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
5858
- ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
version: '2'
2+
3+
services:
4+
couchdb0:
5+
container_name: couchdb0
6+
image: hyperledger/fabric-couchdb
7+
# Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
8+
# for example map it to utilize Fauxton User Interface in dev environments.
9+
ports:
10+
- "5984:5984"
11+
12+
peer0.org1.example.com:
13+
environment:
14+
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
15+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
16+
depends_on:
17+
- couchdb0
18+
19+
couchdb1:
20+
container_name: couchdb1
21+
image: hyperledger/fabric-couchdb
22+
# Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
23+
# for example map it to utilize Fauxton User Interface in dev environments.
24+
ports:
25+
- "6984:5984"
26+
27+
peer1.org1.example.com:
28+
environment:
29+
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
30+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
31+
depends_on:
32+
- couchdb1
33+
34+
couchdb2:
35+
container_name: couchdb2
36+
image: hyperledger/fabric-couchdb
37+
# Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
38+
# for example map it to utilize Fauxton User Interface in dev environments.
39+
ports:
40+
- "7984:5984"
41+
42+
peer0.org2.example.com:
43+
environment:
44+
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
45+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984
46+
depends_on:
47+
- couchdb2
48+
49+
couchdb3:
50+
container_name: couchdb3
51+
image: hyperledger/fabric-couchdb
52+
# Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
53+
# for example map it to utilize Fauxton User Interface in dev environments.
54+
ports:
55+
- "8984:5984"
56+
57+
peer1.org2.example.com:
58+
environment:
59+
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
60+
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984
61+
depends_on:
62+
- couchdb3

examples/e2e_cli/network_setup.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
UP_DOWN="$1"
44
CH_NAME="$2"
55
CLI_TIMEOUT="$3"
6+
IF_COUCHDB="$4"
67

78
: ${CLI_TIMEOUT:="10000"}
89

910
COMPOSE_FILE=docker-compose-cli.yaml
11+
COMPOSE_FILE_COUCH=docker-compose-couch.yaml
1012
#COMPOSE_FILE=docker-compose-e2e.yaml
1113

1214
function printHelp () {
13-
echo "Usage: ./network_setup <up|down> <channel-name>"
15+
echo "Usage: ./network_setup <up|down> <\$channel-name> <\$cli_timeout> <couchdb>.\nThe arguments must be in order."
1416
}
1517

1618
function validateArgs () {
@@ -48,7 +50,11 @@ function networkUp () {
4850
# channel configuration transaction
4951
source generateArtifacts.sh $CH_NAME
5052

51-
CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE up -d 2>&1
53+
if [ "${IF_COUCHDB}" == "couchdb" ]; then
54+
CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
55+
else
56+
CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE up -d 2>&1
57+
fi
5258
if [ $? -ne 0 ]; then
5359
echo "ERROR !!!! Unable to pull the images "
5460
exit 1

0 commit comments

Comments
 (0)