Skip to content

Commit

Permalink
[FAB-2762] Fix e2e_cli test when TLS is disabled
Browse files Browse the repository at this point in the history
* 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 <asara.ratnakar@gmail.com>
  • Loading branch information
asararatnakar committed Mar 13, 2017
1 parent 77760ef commit d7920a9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
4 changes: 0 additions & 4 deletions examples/e2e_cli/docker-compose-no-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ services:
- CORE_PEER_ID=peer0
#- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
- CORE_PEER_LOCALMSPID=Org0MSP
- CORE_PEER_GOSSIP_ORGLEADER=true
volumes:
- /var/run/:/host/var/run/
- ./crypto/peer/peer0/localMspConfig:/etc/hyperledger/fabric/msp/sampleconfig
Expand All @@ -48,7 +47,6 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0:7051
#- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
- CORE_PEER_LOCALMSPID=Org0MSP
- CORE_PEER_GOSSIP_ORGLEADER=false
volumes:
- /var/run/:/host/var/run/
- ./crypto/peer/peer1/localMspConfig:/etc/hyperledger/fabric/msp/sampleconfig
Expand All @@ -69,7 +67,6 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0:7051
#- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_GOSSIP_ORGLEADER=true
volumes:
- /var/run/:/host/var/run/
- ./crypto/peer/peer2/localMspConfig:/etc/hyperledger/fabric/msp/sampleconfig
Expand All @@ -91,7 +88,6 @@ services:
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0:7051
#- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_GOSSIP_ORGLEADER=false
volumes:
- /var/run/:/host/var/run/
- ./crypto/peer/peer3/localMspConfig:/etc/hyperledger/fabric/msp/sampleconfig
Expand Down
3 changes: 3 additions & 0 deletions examples/e2e_cli/peer-base/peer-base-no-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ services:
- CORE_LOGGING_LEVEL=ERROR
#- CORE_LOGGING_LEVEL=DEBUG
- CORE_NEXT=true
- CORE_PEER_TLS_ENABLED=false
- CORE_PEER_ENDORSER_ENABLED=true
- CORE_PEER_GOSSIP_ORGLEADER=false
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_PROFILE_ENABLED=true
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start --peer-defaultchain=false
36 changes: 16 additions & 20 deletions examples/e2e_cli/scripts/script.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
#!/bin/bash

# find address of orderer and peers in your network
ORDERER0_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("orderer0")); print "$a\n";'`
PEER0_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("peer0")); print "$a\n";'`
PEER1_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("peer1")); print "$a\n";'`
PEER2_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("peer2")); print "$a\n";'`
PEER3_IP=`perl -e 'use Socket; $a = inet_ntoa(inet_aton("peer2")); print "$a\n";'`

echo "-----------------------------------------"
echo "Orderer0 IP $ORDERER0_IP"
echo "PEER0 IP $PEER0_IP"
echo "PEER1 IP $PEER1_IP"
echo "PEER2 IP $PEER2_IP"
echo "PEER3 IP $PEER3_IP"
echo "-----------------------------------------"

CHANNEL_NAME="$1"
: ${CHANNEL_NAME:="mychannel"}
: ${TIMEOUT:="60"}
Expand All @@ -38,8 +23,6 @@ setGlobals () {
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer$1/localMspConfig
CORE_PEER_ADDRESS=peer$1:7051



if [ $1 -eq 0 -o $1 -eq 1 ] ; then
CORE_PEER_LOCALMSPID="Org0MSP"
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer$1/localMspConfig/cacerts/peerOrg0.pem
Expand All @@ -53,7 +36,12 @@ setGlobals () {
createChannel() {
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 $CHANNEL_NAME -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt

if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
peer channel create -o orderer0:7050 -c $CHANNEL_NAME -f crypto/orderer/channel.tx >&log.txt
else
peer channel create -o orderer0:7050 -c $CHANNEL_NAME -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
fi
res=$?
cat log.txt
verifyResult $res "Channel creation failed"
Expand Down Expand Up @@ -101,7 +89,11 @@ installChaincode () {
instantiateChaincode () {
PEER=$1
setGlobals $PEER
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
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
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
else
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
fi
res=$?
cat log.txt
verifyResult $res "Chaincode instantiation on PEER$PEER on channel '$CHANNEL_NAME' failed"
Expand Down Expand Up @@ -139,7 +131,11 @@ chaincodeQuery () {

chaincodeInvoke () {
PEER=$1
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
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
peer chaincode invoke -o orderer0:7050 -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
else
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
fi
res=$?
cat log.txt
verifyResult $res "Invoke execution on PEER$PEER failed "
Expand Down

0 comments on commit d7920a9

Please sign in to comment.