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