mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
[FAB-5394] Introduce Delay as configurable variable
Introduce delay as configurable variable for byfn.sh Change-Id: I8ab05f44c68b36bd95f175c9b5f5091d11fa7083 Signed-off-by: Krishna Harsha Voora <krishvoor@in.ibm.com>
This commit is contained in:
parent
a7e83fc235
commit
7778837ebb
3 changed files with 14 additions and 7 deletions
|
|
@ -34,7 +34,7 @@ export FABRIC_CFG_PATH=${PWD}
|
|||
# Print the usage message
|
||||
function printHelp () {
|
||||
echo "Usage: "
|
||||
echo " byfn.sh -m up|down|restart|generate [-c <channel name>] [-t <timeout>]"
|
||||
echo " byfn.sh -m up|down|restart|generate [-c <channel name>] [-t <timeout>] [-d <delay>] "
|
||||
echo " byfn.sh -h|--help (print this message)"
|
||||
echo " -m <mode> - one of 'up', 'down', 'restart' or 'generate'"
|
||||
echo " - 'up' - bring up the network with docker-compose up"
|
||||
|
|
@ -43,6 +43,7 @@ function printHelp () {
|
|||
echo " - 'generate' - generate required certificates and genesis block"
|
||||
echo " -c <channel name> - channel name to use (defaults to \"mychannel\")"
|
||||
echo " -t <timeout> - CLI timeout duration in microseconds (defaults to 10000)"
|
||||
echo " -d <delay> - delay duration in seconds (defaults to 3)"
|
||||
echo
|
||||
echo "Typically, one would first generate the required certificates and "
|
||||
echo "genesis block, then bring up the network. e.g.:"
|
||||
|
|
@ -106,7 +107,7 @@ function networkUp () {
|
|||
replacePrivateKey
|
||||
generateChannelArtifacts
|
||||
fi
|
||||
CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE up -d 2>&1
|
||||
CHANNEL_NAME=$CHANNEL_NAME TIMEOUT=$CLI_TIMEOUT DELAY=$CLI_DELAY docker-compose -f $COMPOSE_FILE up -d 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR !!!! Unable to start network"
|
||||
docker logs -f cli
|
||||
|
|
@ -295,13 +296,15 @@ OS_ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/window
|
|||
# timeout duration - the duration the CLI should wait for a response from
|
||||
# another container before giving up
|
||||
CLI_TIMEOUT=10000
|
||||
#default for delay
|
||||
CLI_DELAY=3
|
||||
# channel name defaults to "mychannel"
|
||||
CHANNEL_NAME="mychannel"
|
||||
# use this as the default docker-compose yaml definition
|
||||
COMPOSE_FILE=docker-compose-cli.yaml
|
||||
|
||||
# Parse commandline args
|
||||
while getopts "h?m:c:t:" opt; do
|
||||
while getopts "h?m:c:t:d:" opt; do
|
||||
case "$opt" in
|
||||
h|\?)
|
||||
printHelp
|
||||
|
|
@ -313,6 +316,8 @@ while getopts "h?m:c:t:" opt; do
|
|||
;;
|
||||
t) CLI_TIMEOUT=$OPTARG
|
||||
;;
|
||||
d) CLI_DELAY=$OPTARG
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ services:
|
|||
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
|
||||
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
|
||||
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
|
||||
command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME}; sleep $TIMEOUT'
|
||||
command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME} ${DELAY}; sleep $TIMEOUT'
|
||||
volumes:
|
||||
- /var/run/:/host/var/run/
|
||||
- ./../chaincode/:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ echo
|
|||
echo "Build your first network (BYFN) end-to-end test"
|
||||
echo
|
||||
CHANNEL_NAME="$1"
|
||||
DELAY="$2"
|
||||
: ${CHANNEL_NAME:="mychannel"}
|
||||
: ${TIMEOUT:="60"}
|
||||
COUNTER=1
|
||||
|
|
@ -82,6 +83,7 @@ updateAnchorPeers() {
|
|||
cat log.txt
|
||||
verifyResult $res "Anchor peer update failed"
|
||||
echo "===================== Anchor peers for org \"$CORE_PEER_LOCALMSPID\" on \"$CHANNEL_NAME\" is updated successfully ===================== "
|
||||
sleep $DELAY
|
||||
echo
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +95,7 @@ joinWithRetry () {
|
|||
if [ $res -ne 0 -a $COUNTER -lt $MAX_RETRY ]; then
|
||||
COUNTER=` expr $COUNTER + 1`
|
||||
echo "PEER$1 failed to join the channel, Retry after 2 seconds"
|
||||
sleep 2
|
||||
sleep $DELAY
|
||||
joinWithRetry $1
|
||||
else
|
||||
COUNTER=1
|
||||
|
|
@ -106,7 +108,7 @@ joinChannel () {
|
|||
setGlobals $ch
|
||||
joinWithRetry $ch
|
||||
echo "===================== PEER$ch joined on the channel \"$CHANNEL_NAME\" ===================== "
|
||||
sleep 2
|
||||
sleep $DELAY
|
||||
echo
|
||||
done
|
||||
}
|
||||
|
|
@ -150,7 +152,7 @@ chaincodeQuery () {
|
|||
# we either get a successful response, or reach TIMEOUT
|
||||
while test "$(($(date +%s)-starttime))" -lt "$TIMEOUT" -a $rc -ne 0
|
||||
do
|
||||
sleep 3
|
||||
sleep $DELAY
|
||||
echo "Attempting to Query PEER$PEER ...$(($(date +%s)-starttime)) secs"
|
||||
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt
|
||||
test $? -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}')
|
||||
|
|
|
|||
Loading…
Reference in a new issue