From d7920a9c3fa0b3fe96ed8e4dde86795de97ae1e2 Mon Sep 17 00:00:00 2001 From: ratnakar Date: Mon, 13 Mar 2017 11:24:33 -0400 Subject: [PATCH] [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 --- examples/e2e_cli/docker-compose-no-tls.yaml | 4 --- .../e2e_cli/peer-base/peer-base-no-tls.yaml | 3 ++ examples/e2e_cli/scripts/script.sh | 36 +++++++++---------- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/examples/e2e_cli/docker-compose-no-tls.yaml b/examples/e2e_cli/docker-compose-no-tls.yaml index fed2767ec14..4ec49186e45 100644 --- a/examples/e2e_cli/docker-compose-no-tls.yaml +++ b/examples/e2e_cli/docker-compose-no-tls.yaml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/examples/e2e_cli/peer-base/peer-base-no-tls.yaml b/examples/e2e_cli/peer-base/peer-base-no-tls.yaml index b799682725d..19f3a7fea09 100644 --- a/examples/e2e_cli/peer-base/peer-base-no-tls.yaml +++ b/examples/e2e_cli/peer-base/peer-base-no-tls.yaml @@ -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 diff --git a/examples/e2e_cli/scripts/script.sh b/examples/e2e_cli/scripts/script.sh index 93330dfb47d..6591709e8c4 100755 --- a/examples/e2e_cli/scripts/script.sh +++ b/examples/e2e_cli/scripts/script.sh @@ -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"} @@ -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 @@ -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" @@ -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" @@ -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 "