From fbe403616fe0fa1a78c8ccdf4bd44c5b3aed8b03 Mon Sep 17 00:00:00 2001 From: Simon Stone Date: Tue, 5 Mar 2019 11:55:31 +0000 Subject: [PATCH] [FAB-14486] Extend BYFN to opt skip chaincode deploy Add a new "-n" option to byfn.sh that optionally skips the deployment of the abstore chaincode. When BYFN is used as a network for other samples, we don't really want the default chaincode deployed. Change-Id: I6b4043a5c0bcedbeec431cc4a860a3b12da8d8f6 Signed-off-by: Simon Stone --- first-network/byfn.sh | 8 ++- first-network/scripts/script.sh | 88 +++++++++++++++------------- scripts/Jenkins_Scripts/byfn_eyfn.sh | 7 +++ 3 files changed, 60 insertions(+), 43 deletions(-) diff --git a/first-network/byfn.sh b/first-network/byfn.sh index 4b914afcd1..8771ba540b 100755 --- a/first-network/byfn.sh +++ b/first-network/byfn.sh @@ -35,7 +35,7 @@ export VERBOSE=false # Print the usage message function printHelp() { echo "Usage: " - echo " byfn.sh [-c ] [-t ] [-d ] [-f ] [-s ] [-l ] [-o ] [-i ] [-a] [-v]" + echo " byfn.sh [-c ] [-t ] [-d ] [-f ] [-s ] [-l ] [-o ] [-i ] [-a] [-n] [-v]" echo " - one of 'up', 'down', 'restart', 'generate' or 'upgrade'" echo " - 'up' - bring up the network with docker-compose up" echo " - 'down' - clear the network with docker-compose down" @@ -51,6 +51,7 @@ function printHelp() { echo " -o - the consensus-type of the ordering service: solo (default), kafka, or etcdraft" echo " -i - the tag to be used to launch the network (defaults to \"latest\")" echo " -a - launch certificate authorities (no certificate authorities are launched by default)" + echo " -n - do not deploy chaincode (abstore chaincode is deployed by default)" echo " -v - verbose mode" echo " byfn.sh -h (print this message)" echo @@ -530,7 +531,7 @@ else exit 1 fi -while getopts "h?c:t:d:f:s:l:i:o:av" opt; do +while getopts "h?c:t:d:f:s:l:i:o:anv" opt; do case "$opt" in h | \?) printHelp @@ -563,6 +564,9 @@ while getopts "h?c:t:d:f:s:l:i:o:av" opt; do a) CERTIFICATE_AUTHORITIES=true ;; + n) + NO_CHAINCODE=true + ;; v) VERBOSE=true ;; diff --git a/first-network/scripts/script.sh b/first-network/scripts/script.sh index 320c2aff2c..e2a3b113ca 100755 --- a/first-network/scripts/script.sh +++ b/first-network/scripts/script.sh @@ -14,11 +14,13 @@ DELAY="$2" LANGUAGE="$3" TIMEOUT="$4" VERBOSE="$5" +NO_CHAINCODE="$6" : ${CHANNEL_NAME:="mychannel"} : ${DELAY:="3"} : ${LANGUAGE:="golang"} : ${TIMEOUT:="10"} : ${VERBOSE:="false"} +: ${NO_CHAINCODE:="false"} LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]` COUNTER=1 MAX_RETRY=10 @@ -82,61 +84,65 @@ updateAnchorPeers 0 1 echo "Updating anchor peers for org2..." updateAnchorPeers 0 2 -## at first we package the chaincode -packageChaincode 1 0 1 +if [ "${NO_CHAINCODE}" != "true" ]; then -## Install chaincode on peer0.org1 and peer0.org2 -echo "Installing chaincode on peer0.org1..." -installChaincode 0 1 -echo "Install chaincode on peer0.org2..." -installChaincode 0 2 + ## at first we package the chaincode + packageChaincode 1 0 1 -## query whether the chaincode is installed -queryInstalled 0 1 + ## Install chaincode on peer0.org1 and peer0.org2 + echo "Installing chaincode on peer0.org1..." + installChaincode 0 1 + echo "Install chaincode on peer0.org2..." + installChaincode 0 2 -## approve the definition for org1 -approveForMyOrg 1 0 1 + ## query whether the chaincode is installed + queryInstalled 0 1 -## query the approval status on both orgs, expect org1 to have approved and org2 not to -queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false" -queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false" + ## approve the definition for org1 + approveForMyOrg 1 0 1 -## now approve also for org2 -approveForMyOrg 1 0 2 + ## query the approval status on both orgs, expect org1 to have approved and org2 not to + queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false" + queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false" -## query the approval status on both orgs, expect them both to have approved -queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true" -queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true" + ## now approve also for org2 + approveForMyOrg 1 0 2 -## now that we know for sure both orgs have approved, commit the definition -commitChaincodeDefinition 1 0 1 0 2 + ## query the approval status on both orgs, expect them both to have approved + queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true" + queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true" -## query on both orgs to see that the definition committed ok -queryCommitted 1 0 1 -queryCommitted 1 0 2 + ## now that we know for sure both orgs have approved, commit the definition + commitChaincodeDefinition 1 0 1 0 2 -# invoke init -chaincodeInvoke 1 0 1 0 2 + ## query on both orgs to see that the definition committed ok + queryCommitted 1 0 1 + queryCommitted 1 0 2 -# Query chaincode on peer0.org1 -echo "Querying chaincode on peer0.org1..." -chaincodeQuery 0 1 100 + # invoke init + chaincodeInvoke 1 0 1 0 2 -# Invoke chaincode on peer0.org1 and peer0.org2 -echo "Sending invoke transaction on peer0.org1 peer0.org2..." -chaincodeInvoke 0 0 1 0 2 + # Query chaincode on peer0.org1 + echo "Querying chaincode on peer0.org1..." + chaincodeQuery 0 1 100 -# Query chaincode on peer0.org1 -echo "Querying chaincode on peer0.org1..." -chaincodeQuery 0 1 90 + # Invoke chaincode on peer0.org1 and peer0.org2 + echo "Sending invoke transaction on peer0.org1 peer0.org2..." + chaincodeInvoke 0 0 1 0 2 -## Install chaincode on peer1.org2 -echo "Installing chaincode on peer1.org2..." -installChaincode 1 2 + # Query chaincode on peer0.org1 + echo "Querying chaincode on peer0.org1..." + chaincodeQuery 0 1 90 -# Query on chaincode on peer1.org2, check if the result is 90 -echo "Querying chaincode on peer1.org2..." -chaincodeQuery 1 2 90 + ## Install chaincode on peer1.org2 + echo "Installing chaincode on peer1.org2..." + installChaincode 1 2 + + # Query on chaincode on peer1.org2, check if the result is 90 + echo "Querying chaincode on peer1.org2..." + chaincodeQuery 1 2 90 + +fi echo echo "========= All GOOD, BYFN execution completed =========== " diff --git a/scripts/Jenkins_Scripts/byfn_eyfn.sh b/scripts/Jenkins_Scripts/byfn_eyfn.sh index 4b5c4ed8a1..a0d32ddc21 100755 --- a/scripts/Jenkins_Scripts/byfn_eyfn.sh +++ b/scripts/Jenkins_Scripts/byfn_eyfn.sh @@ -102,4 +102,11 @@ echo "##################################################" echo y | ./byfn.sh -m up -a copy_logs $? default-channel-ca echo y | ./byfn.sh -m down -a +echo + +echo "############### BYFN WITH NO CHAINCODE TEST ################" +echo "############################################################" +echo y | ./byfn.sh -m up -n +copy_logs $? default-channel-ca +echo y | ./byfn.sh -m down -n echo \ No newline at end of file