From aa9b577f655226ed7f6d88e35204406811471e35 Mon Sep 17 00:00:00 2001 From: nikhil550 Date: Wed, 15 Apr 2020 02:08:43 -0400 Subject: [PATCH] Remove TLS enabled switch (#155) Signed-off-by: NIKHIL E GUPTA Co-authored-by: NIKHIL E GUPTA --- test-network/scripts/createChannel.sh | 36 ++++++--------- test-network/scripts/deployCC.sh | 44 +++++-------------- test-network/scripts/envVar.sh | 18 ++++---- .../scripts/org3-scripts/envVarCLI.sh | 25 ----------- .../scripts/org3-scripts/step1org3.sh | 12 ++--- 5 files changed, 36 insertions(+), 99 deletions(-) diff --git a/test-network/scripts/createChannel.sh b/test-network/scripts/createChannel.sh index a87c55ed05..0a986548bc 100755 --- a/test-network/scripts/createChannel.sh +++ b/test-network/scripts/createChannel.sh @@ -50,23 +50,15 @@ createAncorPeerTx() { createChannel() { setGlobals 1 - # Poll in case the raft leader is not set yet local rc=1 local COUNTER=1 while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do sleep $DELAY - if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then - set -x - peer channel create -o localhost:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block >&log.txt - res=$? - set +x - else - set -x - peer channel create -o localhost:7050 -c $CHANNEL_NAME --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt - res=$? - set +x - fi + set -x + peer channel create -o localhost:7050 -c $CHANNEL_NAME --ordererTLSHostnameOverride orderer.example.com -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt + res=$? + set +x let rc=$res COUNTER=$(expr $COUNTER + 1) done @@ -101,19 +93,19 @@ joinChannel() { updateAnchorPeers() { ORG=$1 setGlobals $ORG - - if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then - set -x - peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt - res=$? - set +x - else + local rc=1 + local COUNTER=1 + ## Sometimes Join takes time, hence retry + while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do + sleep $DELAY set -x - peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt + peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt res=$? set +x - fi - cat log.txt + let rc=$res + COUNTER=$(expr $COUNTER + 1) + done + cat log.txt verifyResult $res "Anchor peer update failed" echo "===================== Anchor peers updated for org '$CORE_PEER_LOCALMSPID' on channel '$CHANNEL_NAME' ===================== " sleep $DELAY diff --git a/test-network/scripts/deployCC.sh b/test-network/scripts/deployCC.sh index e8fdb0850c..e12b8887af 100755 --- a/test-network/scripts/deployCC.sh +++ b/test-network/scripts/deployCC.sh @@ -107,16 +107,9 @@ queryInstalled() { approveForMyOrg() { ORG=$1 setGlobals $ORG - - if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ] ; then - set -x - peer lifecycle chaincode approveformyorg -o localhost:7050 --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt - set +x - else - set -x - peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} >&log.txt - set +x - fi + set -x + peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} >&log.txt + set +x cat log.txt verifyResult $res "Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' failed" echo "===================== Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' ===================== " @@ -140,7 +133,6 @@ checkCommitReadiness() { peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name fabcar --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt res=$? set +x - #test $res -eq 0 || continue let rc=0 for var in "$@" do @@ -167,17 +159,10 @@ commitChaincodeDefinition() { # while 'peer chaincode' command can get the orderer endpoint from the # peer (if join was successful), let's supply it directly as we know # it using the "-o" option - if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ] ; then - set -x - peer lifecycle chaincode commit -o localhost:7050 --channelID $CHANNEL_NAME --name fabcar $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt - res=$? - set +x - else - set -x - peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name fabcar $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt - res=$? - set +x - fi + set -x + peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name fabcar $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt + res=$? + set +x cat log.txt verifyResult $res "Chaincode definition commit failed on peer0.org${ORG} on channel '$CHANNEL_NAME' failed" echo "===================== Chaincode definition committed on channel '$CHANNEL_NAME' ===================== " @@ -225,17 +210,10 @@ chaincodeInvokeInit() { # while 'peer chaincode' command can get the orderer endpoint from the # peer (if join was successful), let's supply it directly as we know # it using the "-o" option - if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then - set -x - peer chaincode invoke -o localhost:7050 -C $CHANNEL_NAME -n fabcar $PEER_CONN_PARMS --isInit -c '{"function":"initLedger","Args":[]}' >&log.txt - res=$? - set +x - else - set -x - peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n fabcar $PEER_CONN_PARMS --isInit -c '{"function":"initLedger","Args":[]}' >&log.txt - res=$? - set +x - fi + set -x + peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n fabcar $PEER_CONN_PARMS --isInit -c '{"function":"initLedger","Args":[]}' >&log.txt + res=$? + set +x cat log.txt verifyResult $res "Invoke execution on $PEERS failed " echo "===================== Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME' ===================== " diff --git a/test-network/scripts/envVar.sh b/test-network/scripts/envVar.sh index 104e723ce8..0506914d91 100755 --- a/test-network/scripts/envVar.sh +++ b/test-network/scripts/envVar.sh @@ -25,7 +25,7 @@ setGlobals() { if [ -z "$OVERRIDE_ORG" ]; then USING_ORG=$1 else - USING_ORG="${OVERRIDE_ORG}" + USING_ORG="${OVERRIDE_ORG}" fi echo "Using organization ${USING_ORG}" if [ $USING_ORG -eq 1 ]; then @@ -54,24 +54,22 @@ setGlobals() { } # parsePeerConnectionParameters $@ -# Helper function that takes the parameters from a chaincode operation -# (e.g. invoke, query, instantiate) and checks for an even number of -# peers and associated org, then sets $PEER_CONN_PARMS and $PEERS +# Helper function that sets the peer connection parameters for a chaincode +# operation parsePeerConnectionParameters() { - # check for uneven number of peer and org parameters PEER_CONN_PARMS="" PEERS="" while [ "$#" -gt 0 ]; do setGlobals $1 PEER="peer0.org$1" + ## Set peer adresses PEERS="$PEERS $PEER" PEER_CONN_PARMS="$PEER_CONN_PARMS --peerAddresses $CORE_PEER_ADDRESS" - if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "true" ]; then - TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER0_ORG$1_CA") - PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO" - fi - # shift by two to get the next pair of peer/org parameters + ## Set path to TLS certificate + TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER0_ORG$1_CA") + PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO" + # shift by one to get to the next organization shift done # remove leading space for output diff --git a/test-network/scripts/org3-scripts/envVarCLI.sh b/test-network/scripts/org3-scripts/envVarCLI.sh index a4e5b0923d..01578bc502 100644 --- a/test-network/scripts/org3-scripts/envVarCLI.sh +++ b/test-network/scripts/org3-scripts/envVarCLI.sh @@ -45,31 +45,6 @@ setGlobals() { fi } -# parsePeerConnectionParameters $@ -# Helper function that takes the parameters from a chaincode operation -# (e.g. invoke, query, instantiate) and checks for an even number of -# peers and associated org, then sets $PEER_CONN_PARMS and $PEERS -parsePeerConnectionParameters() { - # check for uneven number of peer and org parameters - - PEER_CONN_PARMS="" - PEERS="" - while [ "$#" -gt 0 ]; do - setGlobals $1 - PEER="peer0.org$1" - PEERS="$PEERS $PEER" - PEER_CONN_PARMS="$PEER_CONN_PARMS --peerAddresses $CORE_PEER_ADDRESS" - if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "true" ]; then - TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER0_ORG$1_CA") - PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO" - fi - # shift by two to get the next pair of peer/org parameters - shift - done - # remove leading space for output - PEERS="$(echo -e "$PEERS" | sed -e 's/^[[:space:]]*//')" -} - verifyResult() { if [ $1 -ne 0 ]; then echo "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!" diff --git a/test-network/scripts/org3-scripts/step1org3.sh b/test-network/scripts/org3-scripts/step1org3.sh index 87a3d29a61..2e0dc0eaa2 100755 --- a/test-network/scripts/org3-scripts/step1org3.sh +++ b/test-network/scripts/org3-scripts/step1org3.sh @@ -38,15 +38,9 @@ fetchChannelConfig() { setGlobals $ORG echo "Fetching the most recent configuration block for the channel" - if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then - set -x - peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL --cafile $ORDERER_CA - set +x - else - set -x - peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile $ORDERER_CA - set +x - fi + set -x + peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile $ORDERER_CA + set +x echo "Decoding config block to JSON and isolating config to ${OUTPUT}" set -x