[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 <sstone1@uk.ibm.com>
This commit is contained in:
Simon Stone 2019-03-05 11:55:31 +00:00
parent 0c4141f2a1
commit fbe403616f
3 changed files with 60 additions and 43 deletions

View file

@ -35,7 +35,7 @@ export VERBOSE=false
# Print the usage message # Print the usage message
function printHelp() { function printHelp() {
echo "Usage: " echo "Usage: "
echo " byfn.sh <mode> [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>] [-l <language>] [-o <consensus-type>] [-i <imagetag>] [-a] [-v]" echo " byfn.sh <mode> [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>] [-l <language>] [-o <consensus-type>] [-i <imagetag>] [-a] [-n] [-v]"
echo " <mode> - one of 'up', 'down', 'restart', 'generate' or 'upgrade'" echo " <mode> - one of 'up', 'down', 'restart', 'generate' or 'upgrade'"
echo " - 'up' - bring up the network with docker-compose up" echo " - 'up' - bring up the network with docker-compose up"
echo " - 'down' - clear the network with docker-compose down" echo " - 'down' - clear the network with docker-compose down"
@ -51,6 +51,7 @@ function printHelp() {
echo " -o <consensus-type> - the consensus-type of the ordering service: solo (default), kafka, or etcdraft" echo " -o <consensus-type> - the consensus-type of the ordering service: solo (default), kafka, or etcdraft"
echo " -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")" echo " -i <imagetag> - 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 " -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 " -v - verbose mode"
echo " byfn.sh -h (print this message)" echo " byfn.sh -h (print this message)"
echo echo
@ -530,7 +531,7 @@ else
exit 1 exit 1
fi 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 case "$opt" in
h | \?) h | \?)
printHelp printHelp
@ -563,6 +564,9 @@ while getopts "h?c:t:d:f:s:l:i:o:av" opt; do
a) a)
CERTIFICATE_AUTHORITIES=true CERTIFICATE_AUTHORITIES=true
;; ;;
n)
NO_CHAINCODE=true
;;
v) v)
VERBOSE=true VERBOSE=true
;; ;;

View file

@ -14,11 +14,13 @@ DELAY="$2"
LANGUAGE="$3" LANGUAGE="$3"
TIMEOUT="$4" TIMEOUT="$4"
VERBOSE="$5" VERBOSE="$5"
NO_CHAINCODE="$6"
: ${CHANNEL_NAME:="mychannel"} : ${CHANNEL_NAME:="mychannel"}
: ${DELAY:="3"} : ${DELAY:="3"}
: ${LANGUAGE:="golang"} : ${LANGUAGE:="golang"}
: ${TIMEOUT:="10"} : ${TIMEOUT:="10"}
: ${VERBOSE:="false"} : ${VERBOSE:="false"}
: ${NO_CHAINCODE:="false"}
LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]` LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]`
COUNTER=1 COUNTER=1
MAX_RETRY=10 MAX_RETRY=10
@ -82,61 +84,65 @@ updateAnchorPeers 0 1
echo "Updating anchor peers for org2..." echo "Updating anchor peers for org2..."
updateAnchorPeers 0 2 updateAnchorPeers 0 2
## at first we package the chaincode if [ "${NO_CHAINCODE}" != "true" ]; then
packageChaincode 1 0 1
## Install chaincode on peer0.org1 and peer0.org2 ## at first we package the chaincode
echo "Installing chaincode on peer0.org1..." packageChaincode 1 0 1
installChaincode 0 1
echo "Install chaincode on peer0.org2..."
installChaincode 0 2
## query whether the chaincode is installed ## Install chaincode on peer0.org1 and peer0.org2
queryInstalled 0 1 echo "Installing chaincode on peer0.org1..."
installChaincode 0 1
echo "Install chaincode on peer0.org2..."
installChaincode 0 2
## approve the definition for org1 ## query whether the chaincode is installed
approveForMyOrg 1 0 1 queryInstalled 0 1
## query the approval status on both orgs, expect org1 to have approved and org2 not to ## approve the definition for org1
queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false" approveForMyOrg 1 0 1
queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false"
## now approve also for org2 ## query the approval status on both orgs, expect org1 to have approved and org2 not to
approveForMyOrg 1 0 2 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 ## now approve also for org2
queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true" approveForMyOrg 1 0 2
queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true"
## now that we know for sure both orgs have approved, commit the definition ## query the approval status on both orgs, expect them both to have approved
commitChaincodeDefinition 1 0 1 0 2 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 ## now that we know for sure both orgs have approved, commit the definition
queryCommitted 1 0 1 commitChaincodeDefinition 1 0 1 0 2
queryCommitted 1 0 2
# invoke init ## query on both orgs to see that the definition committed ok
chaincodeInvoke 1 0 1 0 2 queryCommitted 1 0 1
queryCommitted 1 0 2
# Query chaincode on peer0.org1 # invoke init
echo "Querying chaincode on peer0.org1..." chaincodeInvoke 1 0 1 0 2
chaincodeQuery 0 1 100
# Invoke chaincode on peer0.org1 and peer0.org2 # Query chaincode on peer0.org1
echo "Sending invoke transaction on peer0.org1 peer0.org2..." echo "Querying chaincode on peer0.org1..."
chaincodeInvoke 0 0 1 0 2 chaincodeQuery 0 1 100
# Query chaincode on peer0.org1 # Invoke chaincode on peer0.org1 and peer0.org2
echo "Querying chaincode on peer0.org1..." echo "Sending invoke transaction on peer0.org1 peer0.org2..."
chaincodeQuery 0 1 90 chaincodeInvoke 0 0 1 0 2
## Install chaincode on peer1.org2 # Query chaincode on peer0.org1
echo "Installing chaincode on peer1.org2..." echo "Querying chaincode on peer0.org1..."
installChaincode 1 2 chaincodeQuery 0 1 90
# Query on chaincode on peer1.org2, check if the result is 90 ## Install chaincode on peer1.org2
echo "Querying chaincode on peer1.org2..." echo "Installing chaincode on peer1.org2..."
chaincodeQuery 1 2 90 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
echo "========= All GOOD, BYFN execution completed =========== " echo "========= All GOOD, BYFN execution completed =========== "

View file

@ -103,3 +103,10 @@ echo y | ./byfn.sh -m up -a
copy_logs $? default-channel-ca copy_logs $? default-channel-ca
echo y | ./byfn.sh -m down -a echo y | ./byfn.sh -m down -a
echo 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