Skip to content

Commit

Permalink
[FAB-15897] Improve FabCar test logging
Browse files Browse the repository at this point in the history
Collect logs from all existing Docker containers instead
of just limiting it to a predefined (and incorrect) set.

Also clean up the directory structure for the logs, and
remove any networks/volumes after each test run.

Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
Change-Id: Ifcf88baeb9ba4d42f757f7cd23ab2a178ab39b41
  • Loading branch information
Simon Stone committed Jul 29, 2019
1 parent dd8150a commit abbda95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
21 changes: 16 additions & 5 deletions fabcar/startFabric.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,31 @@ ${PEER0_ORG1} lifecycle chaincode commit \
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE}

echo "Submitting initLedger transaction to smart contract on mychannel"
echo "The transaction is sent to all of the peers so that chaincode is built before receiving the following requests"
# 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}

# Temporary workaround (see FAB-15897) - cannot invoke across all four peers at the same time, so use a query to build
# the chaincode across the remaining peers.
${PEER1_ORG1} chaincode query \
-C mychannel \
-n fabcar \
-c '{"function":"queryAllCars","Args":[]}' \
--peerAddresses peer1.org1.example.com:8051 \
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE}
${PEER1_ORG2} chaincode query \
-C mychannel \
-n fabcar \
-c '{"function":"queryAllCars","Args":[]}' \
--peerAddresses peer1.org2.example.com:10051 \
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE}

cat <<EOF
Expand Down
19 changes: 8 additions & 11 deletions scripts/ci_scripts/fabcar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
# SPDX-License-Identifier: Apache-2.0
#

# docker container list - Check these from basic-network/docker-compose.yaml
CONTAINER_LIST=(peer0.org1 orderer ca)

logs() {

for CONTAINER in ${CONTAINER_LIST[*]}; do
docker logs $CONTAINER.example.com >& $WORKSPACE/$CONTAINER-$1.log
echo
done
# Write couchdb container logs into couchdb.log file
docker logs couchdb >& couchdb.log

LOG_DIRECTORY=$WORKSPACE/fabcar/$1
mkdir -p ${LOG_DIRECTORY}
CONTAINER_LIST=$(docker ps -a --format '{{.Names}}')
for CONTAINER in ${CONTAINER_LIST}; do
docker logs ${CONTAINER} > ${LOG_DIRECTORY}/${CONTAINER}.log 2>&1
done
}

copy_logs() {
Expand Down Expand Up @@ -65,5 +60,7 @@ for LANGUAGE in ${LANGUAGES}; do
fi
docker ps -aq | xargs docker rm -f
docker rmi -f $(docker images -aq dev-*)
docker volume prune -f
docker network prune -f
echo -e "\033[32m finished fabcar test (${LANGUAGE})" "\033[0m"
done

0 comments on commit abbda95

Please sign in to comment.