Skip to content

Commit fbe4036

Browse files
author
Simon Stone
committed
[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>
1 parent 0c4141f commit fbe4036

File tree

3 files changed

+60
-43
lines changed

3 files changed

+60
-43
lines changed

first-network/byfn.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export VERBOSE=false
3535
# Print the usage message
3636
function printHelp() {
3737
echo "Usage: "
38-
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]"
38+
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]"
3939
echo " <mode> - one of 'up', 'down', 'restart', 'generate' or 'upgrade'"
4040
echo " - 'up' - bring up the network with docker-compose up"
4141
echo " - 'down' - clear the network with docker-compose down"
@@ -51,6 +51,7 @@ function printHelp() {
5151
echo " -o <consensus-type> - the consensus-type of the ordering service: solo (default), kafka, or etcdraft"
5252
echo " -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")"
5353
echo " -a - launch certificate authorities (no certificate authorities are launched by default)"
54+
echo " -n - do not deploy chaincode (abstore chaincode is deployed by default)"
5455
echo " -v - verbose mode"
5556
echo " byfn.sh -h (print this message)"
5657
echo
@@ -530,7 +531,7 @@ else
530531
exit 1
531532
fi
532533

533-
while getopts "h?c:t:d:f:s:l:i:o:av" opt; do
534+
while getopts "h?c:t:d:f:s:l:i:o:anv" opt; do
534535
case "$opt" in
535536
h | \?)
536537
printHelp
@@ -563,6 +564,9 @@ while getopts "h?c:t:d:f:s:l:i:o:av" opt; do
563564
a)
564565
CERTIFICATE_AUTHORITIES=true
565566
;;
567+
n)
568+
NO_CHAINCODE=true
569+
;;
566570
v)
567571
VERBOSE=true
568572
;;

first-network/scripts/script.sh

+47-41
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ DELAY="$2"
1414
LANGUAGE="$3"
1515
TIMEOUT="$4"
1616
VERBOSE="$5"
17+
NO_CHAINCODE="$6"
1718
: ${CHANNEL_NAME:="mychannel"}
1819
: ${DELAY:="3"}
1920
: ${LANGUAGE:="golang"}
2021
: ${TIMEOUT:="10"}
2122
: ${VERBOSE:="false"}
23+
: ${NO_CHAINCODE:="false"}
2224
LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]`
2325
COUNTER=1
2426
MAX_RETRY=10
@@ -82,61 +84,65 @@ updateAnchorPeers 0 1
8284
echo "Updating anchor peers for org2..."
8385
updateAnchorPeers 0 2
8486

85-
## at first we package the chaincode
86-
packageChaincode 1 0 1
87+
if [ "${NO_CHAINCODE}" != "true" ]; then
8788

88-
## Install chaincode on peer0.org1 and peer0.org2
89-
echo "Installing chaincode on peer0.org1..."
90-
installChaincode 0 1
91-
echo "Install chaincode on peer0.org2..."
92-
installChaincode 0 2
89+
## at first we package the chaincode
90+
packageChaincode 1 0 1
9391

94-
## query whether the chaincode is installed
95-
queryInstalled 0 1
92+
## Install chaincode on peer0.org1 and peer0.org2
93+
echo "Installing chaincode on peer0.org1..."
94+
installChaincode 0 1
95+
echo "Install chaincode on peer0.org2..."
96+
installChaincode 0 2
9697

97-
## approve the definition for org1
98-
approveForMyOrg 1 0 1
98+
## query whether the chaincode is installed
99+
queryInstalled 0 1
99100

100-
## query the approval status on both orgs, expect org1 to have approved and org2 not to
101-
queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false"
102-
queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false"
101+
## approve the definition for org1
102+
approveForMyOrg 1 0 1
103103

104-
## now approve also for org2
105-
approveForMyOrg 1 0 2
104+
## query the approval status on both orgs, expect org1 to have approved and org2 not to
105+
queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": false"
106+
queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": false"
106107

107-
## query the approval status on both orgs, expect them both to have approved
108-
queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true"
109-
queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true"
108+
## now approve also for org2
109+
approveForMyOrg 1 0 2
110110

111-
## now that we know for sure both orgs have approved, commit the definition
112-
commitChaincodeDefinition 1 0 1 0 2
111+
## query the approval status on both orgs, expect them both to have approved
112+
queryStatus 1 0 1 "\"Org1MSP\": true" "\"Org2MSP\": true"
113+
queryStatus 1 0 2 "\"Org1MSP\": true" "\"Org2MSP\": true"
113114

114-
## query on both orgs to see that the definition committed ok
115-
queryCommitted 1 0 1
116-
queryCommitted 1 0 2
115+
## now that we know for sure both orgs have approved, commit the definition
116+
commitChaincodeDefinition 1 0 1 0 2
117117

118-
# invoke init
119-
chaincodeInvoke 1 0 1 0 2
118+
## query on both orgs to see that the definition committed ok
119+
queryCommitted 1 0 1
120+
queryCommitted 1 0 2
120121

121-
# Query chaincode on peer0.org1
122-
echo "Querying chaincode on peer0.org1..."
123-
chaincodeQuery 0 1 100
122+
# invoke init
123+
chaincodeInvoke 1 0 1 0 2
124124

125-
# Invoke chaincode on peer0.org1 and peer0.org2
126-
echo "Sending invoke transaction on peer0.org1 peer0.org2..."
127-
chaincodeInvoke 0 0 1 0 2
125+
# Query chaincode on peer0.org1
126+
echo "Querying chaincode on peer0.org1..."
127+
chaincodeQuery 0 1 100
128128

129-
# Query chaincode on peer0.org1
130-
echo "Querying chaincode on peer0.org1..."
131-
chaincodeQuery 0 1 90
129+
# Invoke chaincode on peer0.org1 and peer0.org2
130+
echo "Sending invoke transaction on peer0.org1 peer0.org2..."
131+
chaincodeInvoke 0 0 1 0 2
132132

133-
## Install chaincode on peer1.org2
134-
echo "Installing chaincode on peer1.org2..."
135-
installChaincode 1 2
133+
# Query chaincode on peer0.org1
134+
echo "Querying chaincode on peer0.org1..."
135+
chaincodeQuery 0 1 90
136136

137-
# Query on chaincode on peer1.org2, check if the result is 90
138-
echo "Querying chaincode on peer1.org2..."
139-
chaincodeQuery 1 2 90
137+
## Install chaincode on peer1.org2
138+
echo "Installing chaincode on peer1.org2..."
139+
installChaincode 1 2
140+
141+
# Query on chaincode on peer1.org2, check if the result is 90
142+
echo "Querying chaincode on peer1.org2..."
143+
chaincodeQuery 1 2 90
144+
145+
fi
140146

141147
echo
142148
echo "========= All GOOD, BYFN execution completed =========== "

scripts/Jenkins_Scripts/byfn_eyfn.sh

+7
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,11 @@ echo "##################################################"
102102
echo y | ./byfn.sh -m up -a
103103
copy_logs $? default-channel-ca
104104
echo y | ./byfn.sh -m down -a
105+
echo
106+
107+
echo "############### BYFN WITH NO CHAINCODE TEST ################"
108+
echo "############################################################"
109+
echo y | ./byfn.sh -m up -n
110+
copy_logs $? default-channel-ca
111+
echo y | ./byfn.sh -m down -n
105112
echo

0 commit comments

Comments
 (0)