Skip to content

Commit d7920a9

Browse files
committed
[FAB-2762] Fix e2e_cli test when TLS is disabled
* When tls is disabled, end-to-end test fails as --tls flag is passed even when tls is disabled, added a check to remove the flag * enabled CORE_PEER_GOSSIP_USELEADERELECTION configuration and disabled CORE_PEER_GOSSIP_ORGLEADER * Removed all unwanted addresses printed in the script.sh Change-Id: I87aea47a4becf82cde4f2e9e4dfddd2483b559c2 Signed-off-by: ratnakar <[email protected]>
1 parent 77760ef commit d7920a9

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

examples/e2e_cli/docker-compose-no-tls.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ services:
2828
- CORE_PEER_ID=peer0
2929
#- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
3030
- CORE_PEER_LOCALMSPID=Org0MSP
31-
- CORE_PEER_GOSSIP_ORGLEADER=true
3231
volumes:
3332
- /var/run/:/host/var/run/
3433
- ./crypto/peer/peer0/localMspConfig:/etc/hyperledger/fabric/msp/sampleconfig
@@ -48,7 +47,6 @@ services:
4847
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0:7051
4948
#- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
5049
- CORE_PEER_LOCALMSPID=Org0MSP
51-
- CORE_PEER_GOSSIP_ORGLEADER=false
5250
volumes:
5351
- /var/run/:/host/var/run/
5452
- ./crypto/peer/peer1/localMspConfig:/etc/hyperledger/fabric/msp/sampleconfig
@@ -69,7 +67,6 @@ services:
6967
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0:7051
7068
#- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
7169
- CORE_PEER_LOCALMSPID=Org1MSP
72-
- CORE_PEER_GOSSIP_ORGLEADER=true
7370
volumes:
7471
- /var/run/:/host/var/run/
7572
- ./crypto/peer/peer2/localMspConfig:/etc/hyperledger/fabric/msp/sampleconfig
@@ -91,7 +88,6 @@ services:
9188
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0:7051
9289
#- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
9390
- CORE_PEER_LOCALMSPID=Org1MSP
94-
- CORE_PEER_GOSSIP_ORGLEADER=false
9591
volumes:
9692
- /var/run/:/host/var/run/
9793
- ./crypto/peer/peer3/localMspConfig:/etc/hyperledger/fabric/msp/sampleconfig

examples/e2e_cli/peer-base/peer-base-no-tls.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ services:
99
- CORE_LOGGING_LEVEL=ERROR
1010
#- CORE_LOGGING_LEVEL=DEBUG
1111
- CORE_NEXT=true
12+
- CORE_PEER_TLS_ENABLED=false
1213
- CORE_PEER_ENDORSER_ENABLED=true
14+
- CORE_PEER_GOSSIP_ORGLEADER=false
15+
- CORE_PEER_GOSSIP_USELEADERELECTION=true
1316
- CORE_PEER_PROFILE_ENABLED=true
1417
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
1518
command: peer node start --peer-defaultchain=false

examples/e2e_cli/scripts/script.sh

+16-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
#!/bin/bash
22

3-
# find address of orderer and peers in your network
4-
ORDERER0_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("orderer0")); print "$a\n";'`
5-
PEER0_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("peer0")); print "$a\n";'`
6-
PEER1_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("peer1")); print "$a\n";'`
7-
PEER2_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("peer2")); print "$a\n";'`
8-
PEER3_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("peer2")); print "$a\n";'`
9-
10-
echo "-----------------------------------------"
11-
echo "Orderer0 IP $ORDERER0_IP"
12-
echo "PEER0 IP $PEER0_IP"
13-
echo "PEER1 IP $PEER1_IP"
14-
echo "PEER2 IP $PEER2_IP"
15-
echo "PEER3 IP $PEER3_IP"
16-
echo "-----------------------------------------"
17-
183
CHANNEL_NAME="$1"
194
: ${CHANNEL_NAME:="mychannel"}
205
: ${TIMEOUT:="60"}
@@ -38,8 +23,6 @@ setGlobals () {
3823
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer$1/localMspConfig
3924
CORE_PEER_ADDRESS=peer$1:7051
4025

41-
42-
4326
if [ $1 -eq 0 -o $1 -eq 1 ] ; then
4427
CORE_PEER_LOCALMSPID="Org0MSP"
4528
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer$1/localMspConfig/cacerts/peerOrg0.pem
@@ -53,7 +36,12 @@ setGlobals () {
5336
createChannel() {
5437
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig
5538
CORE_PEER_LOCALMSPID="OrdererMSP"
56-
peer channel create -o orderer0:7050 -c $CHANNEL_NAME -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
39+
40+
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
41+
peer channel create -o orderer0:7050 -c $CHANNEL_NAME -f crypto/orderer/channel.tx >&log.txt
42+
else
43+
peer channel create -o orderer0:7050 -c $CHANNEL_NAME -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
44+
fi
5745
res=$?
5846
cat log.txt
5947
verifyResult $res "Channel creation failed"
@@ -101,7 +89,11 @@ installChaincode () {
10189
instantiateChaincode () {
10290
PEER=$1
10391
setGlobals $PEER
104-
peer chaincode instantiate -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -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')" >&log.txt
92+
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
93+
peer chaincode instantiate -o orderer0:7050 -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org0MSP.member','Org1MSP.member')" >&log.txt
94+
else
95+
peer chaincode instantiate -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org0MSP.member','Org1MSP.member')" >&log.txt
96+
fi
10597
res=$?
10698
cat log.txt
10799
verifyResult $res "Chaincode instantiation on PEER$PEER on channel '$CHANNEL_NAME' failed"
@@ -139,7 +131,11 @@ chaincodeQuery () {
139131

140132
chaincodeInvoke () {
141133
PEER=$1
142-
peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
134+
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
135+
peer chaincode invoke -o orderer0:7050 -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
136+
else
137+
peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
138+
fi
143139
res=$?
144140
cat log.txt
145141
verifyResult $res "Invoke execution on PEER$PEER failed "

0 commit comments

Comments
 (0)