Skip to content

Commit

Permalink
[FAB-14486] Extend BYFN to opt skip chaincode deploy
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Simon Stone committed Apr 24, 2019
1 parent 0c4141f commit fbe4036
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 43 deletions.
8 changes: 6 additions & 2 deletions first-network/byfn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export VERBOSE=false
# Print the usage message
function printHelp() {
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 " - 'up' - bring up the network with docker-compose up"
echo " - 'down' - clear the network with docker-compose down"
Expand All @@ -51,6 +51,7 @@ function printHelp() {
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 " -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
;;
Expand Down
88 changes: 47 additions & 41 deletions first-network/scripts/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =========== "
Expand Down
7 changes: 7 additions & 0 deletions scripts/Jenkins_Scripts/byfn_eyfn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fbe4036

Please sign in to comment.