mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-19 08:15:08 +00:00
[FAB-15649]Fix Fabcar to install Chaincode on all peers
CI Fabcar javascript test fails because a query proposal is sent to a peer which does not have Chaincode. The query handler in fabric-network does not consider if Chaincode is installed on target peers. As a workaround, this CR adds steps installing Chaincode on all peers during the setup. Change-Id: Iaff0c5bde8c54cef12a176b55e13d70173ee8108 Signed-off-by: Yuki Kondo <yuki.kondo@hal.hitachi.com>
This commit is contained in:
parent
7c5f5d39c9
commit
779f8f3418
1 changed files with 46 additions and 12 deletions
|
|
@ -50,7 +50,7 @@ ORG2_MSPCONFIGPATH=${CONFIG_ROOT}/crypto/peerOrganizations/org2.example.com/user
|
|||
ORG2_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
|
||||
ORDERER_TLS_ROOTCERT_FILE=${CONFIG_ROOT}/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
||||
|
||||
PEER_ORG1="docker exec
|
||||
PEER0_ORG1="docker exec
|
||||
-e CORE_PEER_LOCALMSPID=Org1MSP
|
||||
-e CORE_PEER_ADDRESS=peer0.org1.example.com:7051
|
||||
-e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH}
|
||||
|
|
@ -61,7 +61,18 @@ peer
|
|||
--cafile=${ORDERER_TLS_ROOTCERT_FILE}
|
||||
--orderer=orderer.example.com:7050"
|
||||
|
||||
PEER_ORG2="docker exec
|
||||
PEER1_ORG1="docker exec
|
||||
-e CORE_PEER_LOCALMSPID=Org1MSP
|
||||
-e CORE_PEER_ADDRESS=peer1.org1.example.com:8051
|
||||
-e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH}
|
||||
-e CORE_PEER_TLS_ROOTCERT_FILE=${ORG1_TLS_ROOTCERT_FILE}
|
||||
cli
|
||||
peer
|
||||
--tls=true
|
||||
--cafile=${ORDERER_TLS_ROOTCERT_FILE}
|
||||
--orderer=orderer.example.com:7050"
|
||||
|
||||
PEER0_ORG2="docker exec
|
||||
-e CORE_PEER_LOCALMSPID=Org2MSP
|
||||
-e CORE_PEER_ADDRESS=peer0.org2.example.com:9051
|
||||
-e CORE_PEER_MSPCONFIGPATH=${ORG2_MSPCONFIGPATH}
|
||||
|
|
@ -72,20 +83,35 @@ peer
|
|||
--cafile=${ORDERER_TLS_ROOTCERT_FILE}
|
||||
--orderer=orderer.example.com:7050"
|
||||
|
||||
PEER1_ORG2="docker exec
|
||||
-e CORE_PEER_LOCALMSPID=Org2MSP
|
||||
-e CORE_PEER_ADDRESS=peer1.org2.example.com:10051
|
||||
-e CORE_PEER_MSPCONFIGPATH=${ORG2_MSPCONFIGPATH}
|
||||
-e CORE_PEER_TLS_ROOTCERT_FILE=${ORG2_TLS_ROOTCERT_FILE}
|
||||
cli
|
||||
peer
|
||||
--tls=true
|
||||
--cafile=${ORDERER_TLS_ROOTCERT_FILE}
|
||||
--orderer=orderer.example.com:7050"
|
||||
|
||||
echo "Packaging smart contract on peer0.org1.example.com"
|
||||
${PEER_ORG1} lifecycle chaincode package \
|
||||
${PEER0_ORG1} lifecycle chaincode package \
|
||||
fabcar.tar.gz \
|
||||
--path "$CC_SRC_PATH" \
|
||||
--lang "$CC_RUNTIME_LANGUAGE" \
|
||||
--label fabcarv1
|
||||
|
||||
echo "Installing smart contract on peer0.org1.example.com"
|
||||
${PEER_ORG1} lifecycle chaincode install \
|
||||
${PEER0_ORG1} lifecycle chaincode install \
|
||||
fabcar.tar.gz
|
||||
|
||||
echo "Installing smart contract on peer1.org1.example.com"
|
||||
${PEER1_ORG1} lifecycle chaincode install \
|
||||
fabcar.tar.gz
|
||||
|
||||
echo "Determining package ID for smart contract on peer0.org1.example.com"
|
||||
REGEX='Package ID: (.*), Label: fabcarv1'
|
||||
if [[ `${PEER_ORG1} lifecycle chaincode queryinstalled` =~ $REGEX ]]; then
|
||||
if [[ `${PEER0_ORG1} lifecycle chaincode queryinstalled` =~ $REGEX ]]; then
|
||||
PACKAGE_ID_ORG1=${BASH_REMATCH[1]}
|
||||
else
|
||||
echo Could not find package ID for fabcarv1 chaincode on peer0.org1.example.com
|
||||
|
|
@ -93,7 +119,7 @@ else
|
|||
fi
|
||||
|
||||
echo "Approving smart contract for org1"
|
||||
${PEER_ORG1} lifecycle chaincode approveformyorg \
|
||||
${PEER0_ORG1} lifecycle chaincode approveformyorg \
|
||||
--package-id ${PACKAGE_ID_ORG1} \
|
||||
--channelID mychannel \
|
||||
--name fabcar \
|
||||
|
|
@ -103,18 +129,21 @@ ${PEER_ORG1} lifecycle chaincode approveformyorg \
|
|||
--waitForEvent
|
||||
|
||||
echo "Packaging smart contract on peer0.org2.example.com"
|
||||
${PEER_ORG2} lifecycle chaincode package \
|
||||
${PEER0_ORG2} lifecycle chaincode package \
|
||||
fabcar.tar.gz \
|
||||
--path "$CC_SRC_PATH" \
|
||||
--lang "$CC_RUNTIME_LANGUAGE" \
|
||||
--label fabcarv1
|
||||
|
||||
echo "Installing smart contract on peer0.org2.example.com"
|
||||
${PEER_ORG2} lifecycle chaincode install fabcar.tar.gz
|
||||
${PEER0_ORG2} lifecycle chaincode install fabcar.tar.gz
|
||||
|
||||
echo "Installing smart contract on peer1.org2.example.com"
|
||||
${PEER1_ORG2} lifecycle chaincode install fabcar.tar.gz
|
||||
|
||||
echo "Determining package ID for smart contract on peer0.org2.example.com"
|
||||
REGEX='Package ID: (.*), Label: fabcarv1'
|
||||
if [[ `${PEER_ORG2} lifecycle chaincode queryinstalled` =~ $REGEX ]]; then
|
||||
if [[ `${PEER0_ORG2} lifecycle chaincode queryinstalled` =~ $REGEX ]]; then
|
||||
PACKAGE_ID_ORG2=${BASH_REMATCH[1]}
|
||||
else
|
||||
echo Could not find package ID for fabcarv1 chaincode on peer0.org2.example.com
|
||||
|
|
@ -122,7 +151,7 @@ else
|
|||
fi
|
||||
|
||||
echo "Approving smart contract for org2"
|
||||
${PEER_ORG2} lifecycle chaincode approveformyorg \
|
||||
${PEER0_ORG2} lifecycle chaincode approveformyorg \
|
||||
--package-id ${PACKAGE_ID_ORG2} \
|
||||
--channelID mychannel \
|
||||
--name fabcar \
|
||||
|
|
@ -132,7 +161,7 @@ ${PEER_ORG2} lifecycle chaincode approveformyorg \
|
|||
--waitForEvent
|
||||
|
||||
echo "Committing smart contract"
|
||||
${PEER_ORG1} lifecycle chaincode commit \
|
||||
${PEER0_ORG1} lifecycle chaincode commit \
|
||||
--channelID mychannel \
|
||||
--name fabcar \
|
||||
--version 1.0 \
|
||||
|
|
@ -145,15 +174,20 @@ ${PEER_ORG1} lifecycle chaincode commit \
|
|||
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE}
|
||||
|
||||
echo "Submitting initLedger transaction to smart contract on mychannel"
|
||||
${PEER_ORG1} chaincode invoke \
|
||||
echo "The transaction is sent to all of the peers so that chaincode is built before receiving the following requests"
|
||||
${PEER0_ORG1} chaincode invoke \
|
||||
-C mychannel \
|
||||
-n fabcar \
|
||||
-c '{"function":"initLedger","Args":[]}' \
|
||||
--waitForEvent \
|
||||
--waitForEventTimeout 300s \
|
||||
--peerAddresses peer0.org1.example.com:7051 \
|
||||
--peerAddresses peer1.org1.example.com:8051 \
|
||||
--peerAddresses peer0.org2.example.com:9051 \
|
||||
--peerAddresses peer1.org2.example.com:10051 \
|
||||
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \
|
||||
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \
|
||||
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE} \
|
||||
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE}
|
||||
|
||||
cat <<EOF
|
||||
|
|
|
|||
Loading…
Reference in a new issue