[FAB-8630] byfn failing intermittently in CI

byfn test failing intermittently in CI due to peer not
being available when the join channel command is
executed. Need to wait for peer to finsih establishing
connection with couchdb before joining channel.

The exit code was not being correctly captured from the
peer join command and thus the retry logic was not being
executed.

Change-Id: I2c27d17cd769c6b8de1bdcfed263d9b0f758b432
Signed-off-by: Saad Karim <skarim@us.ibm.com>
This commit is contained in:
Saad Karim 2018-03-08 11:31:37 -05:00
parent 5d7ac01c81
commit 2bbb0a85b3
6 changed files with 32 additions and 17 deletions

View file

@ -317,8 +317,9 @@ function generateCerts (){
fi fi
set -x set -x
cryptogen generate --config=./crypto-config.yaml cryptogen generate --config=./crypto-config.yaml
res=$?
set +x set +x
if [ "$?" -ne 0 ]; then if [ $res -ne 0 ]; then
echo "Failed to generate certificates..." echo "Failed to generate certificates..."
exit 1 exit 1
fi fi
@ -377,8 +378,9 @@ function generateChannelArtifacts() {
# named orderer.genesis.block or the orderer will fail to launch! # named orderer.genesis.block or the orderer will fail to launch!
set -x set -x
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
res=$?
set +x set +x
if [ "$?" -ne 0 ]; then if [ $res -ne 0 ]; then
echo "Failed to generate orderer genesis block..." echo "Failed to generate orderer genesis block..."
exit 1 exit 1
fi fi
@ -388,8 +390,9 @@ function generateChannelArtifacts() {
echo "#################################################################" echo "#################################################################"
set -x set -x
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
res=$?
set +x set +x
if [ "$?" -ne 0 ]; then if [ $res -ne 0 ]; then
echo "Failed to generate channel configuration transaction..." echo "Failed to generate channel configuration transaction..."
exit 1 exit 1
fi fi
@ -400,8 +403,9 @@ function generateChannelArtifacts() {
echo "#################################################################" echo "#################################################################"
set -x set -x
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
res=$?
set +x set +x
if [ "$?" -ne 0 ]; then if [ $res -ne 0 ]; then
echo "Failed to generate anchor peer update for Org1MSP..." echo "Failed to generate anchor peer update for Org1MSP..."
exit 1 exit 1
fi fi
@ -413,8 +417,9 @@ function generateChannelArtifacts() {
set -x set -x
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate \ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate \
./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
res=$?
set +x set +x
if [ "$?" -ne 0 ]; then if [ $res -ne 0 ]; then
echo "Failed to generate anchor peer update for Org2MSP..." echo "Failed to generate anchor peer update for Org2MSP..."
exit 1 exit 1
fi fi

View file

@ -186,8 +186,9 @@ function generateCerts (){
(cd org3-artifacts (cd org3-artifacts
set -x set -x
cryptogen generate --config=./org3-crypto.yaml cryptogen generate --config=./org3-crypto.yaml
res=$?
set +x set +x
if [ "$?" -ne 0 ]; then if [ $res -ne 0 ]; then
echo "Failed to generate certificates..." echo "Failed to generate certificates..."
exit 1 exit 1
fi fi
@ -209,8 +210,9 @@ function generateChannelArtifacts() {
export FABRIC_CFG_PATH=$PWD export FABRIC_CFG_PATH=$PWD
set -x set -x
configtxgen -printOrg Org3MSP > ../channel-artifacts/org3.json configtxgen -printOrg Org3MSP > ../channel-artifacts/org3.json
res=$?
set +x set +x
if [ "$?" -ne 0 ]; then if [ $res -ne 0 ]; then
echo "Failed to generate Org3 config material..." echo "Failed to generate Org3 config material..."
exit 1 exit 1
fi fi

View file

@ -38,11 +38,14 @@ createChannel() {
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
set -x set -x
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx >&log.txt peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx >&log.txt
res=$?
set +x set +x
else else
set -x
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
res=$?
set +x
fi fi
res=$?
cat log.txt cat log.txt
verifyResult $res "Channel creation failed" verifyResult $res "Channel creation failed"
echo "===================== Channel \"$CHANNEL_NAME\" is created successfully ===================== " echo "===================== Channel \"$CHANNEL_NAME\" is created successfully ===================== "

View file

@ -38,8 +38,8 @@ fi
echo "Fetching channel config block from orderer..." echo "Fetching channel config block from orderer..."
set -x set -x
peer channel fetch 0 $CHANNEL_NAME.block -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA >&log.txt peer channel fetch 0 $CHANNEL_NAME.block -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA >&log.txt
set +x
res=$? res=$?
set +x
cat log.txt cat log.txt
verifyResult $res "Fetching config block from orderer has Failed" verifyResult $res "Fetching config block from orderer has Failed"

View file

@ -87,13 +87,14 @@ addCapabilityToChannel() {
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
set -x set -x
peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --cafile $ORDERER_CA peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --cafile $ORDERER_CA
res=$?
set +x set +x
else else
set -x set -x
peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --tls true --cafile $ORDERER_CA peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --tls true --cafile $ORDERER_CA
res=$?
set +x set +x
fi fi
res=$?
verifyResult $res "Config update for \"$GROUP\" on \"$CH_NAME\" failed" verifyResult $res "Config update for \"$GROUP\" on \"$CH_NAME\" failed"
echo "===================== Config update for \"$GROUP\" on \"$CH_NAME\" is completed ===================== " echo "===================== Config update for \"$GROUP\" on \"$CH_NAME\" is completed ===================== "

View file

@ -71,13 +71,14 @@ updateAnchorPeers() {
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
set -x set -x
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt
res=$?
set +x set +x
else else
set -x set -x
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
res=$?
set +x set +x
fi fi
res=$?
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 ===================== "
@ -93,8 +94,8 @@ joinChannelWithRetry () {
set -x set -x
peer channel join -b $CHANNEL_NAME.block >&log.txt peer channel join -b $CHANNEL_NAME.block >&log.txt
set +x
res=$? res=$?
set +x
cat log.txt cat log.txt
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`
@ -114,8 +115,8 @@ installChaincode () {
VERSION=${3:-1.0} VERSION=${3:-1.0}
set -x set -x
peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt
set +x
res=$? res=$?
set +x
cat log.txt cat log.txt
verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has Failed" verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has Failed"
echo "===================== Chaincode is installed on peer${PEER}.org${ORG} ===================== " echo "===================== Chaincode is installed on peer${PEER}.org${ORG} ===================== "
@ -133,13 +134,14 @@ instantiateChaincode () {
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
set -x set -x
peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
res=$?
set +x set +x
else else
set -x set -x
peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
res=$?
set +x set +x
fi fi
res=$?
cat log.txt cat log.txt
verifyResult $res "Chaincode instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' failed" verifyResult $res "Chaincode instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' failed"
echo "===================== Chaincode Instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' is successful ===================== " echo "===================== Chaincode Instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' is successful ===================== "
@ -153,8 +155,8 @@ upgradeChaincode () {
set -x set -x
peer chaincode upgrade -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')" peer chaincode upgrade -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')"
set +x
res=$? res=$?
set +x
cat log.txt cat log.txt
verifyResult $res "Chaincode upgrade on org${ORG} peer${PEER} has Failed" verifyResult $res "Chaincode upgrade on org${ORG} peer${PEER} has Failed"
echo "===================== Chaincode is upgraded on org${ORG} peer${PEER} ===================== " echo "===================== Chaincode is upgraded on org${ORG} peer${PEER} ===================== "
@ -178,8 +180,9 @@ chaincodeQuery () {
echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s)-starttime)) secs" echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s)-starttime)) secs"
set -x set -x
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
res=$?
set +x set +x
test $? -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}') test $res -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}')
test "$VALUE" = "$EXPECTED_RESULT" && let rc=0 test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
done done
echo echo
@ -257,13 +260,14 @@ chaincodeInvoke () {
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
set -x set -x
peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
res=$?
set +x set +x
else else
set -x set -x
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt
res=$?
set +x set +x
fi fi
res=$?
cat log.txt cat log.txt
verifyResult $res "Invoke execution on peer${PEER}.org${ORG} failed " verifyResult $res "Invoke execution on peer${PEER}.org${ORG} failed "
echo "===================== Invoke transaction on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' is successful ===================== " echo "===================== Invoke transaction on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' is successful ===================== "