Skip to content

Commit abbda95

Browse files
author
Simon Stone
committed
[FAB-15897] Improve FabCar test logging
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
1 parent dd8150a commit abbda95

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

fabcar/startFabric.sh

+16-5
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,31 @@ ${PEER0_ORG1} lifecycle chaincode commit \
174174
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE}
175175

176176
echo "Submitting initLedger transaction to smart contract on mychannel"
177-
echo "The transaction is sent to all of the peers so that chaincode is built before receiving the following requests"
177+
# echo "The transaction is sent to all of the peers so that chaincode is built before receiving the following requests"
178178
${PEER0_ORG1} chaincode invoke \
179179
-C mychannel \
180180
-n fabcar \
181181
-c '{"function":"initLedger","Args":[]}' \
182182
--waitForEvent \
183183
--waitForEventTimeout 300s \
184184
--peerAddresses peer0.org1.example.com:7051 \
185-
--peerAddresses peer1.org1.example.com:8051 \
186185
--peerAddresses peer0.org2.example.com:9051 \
187-
--peerAddresses peer1.org2.example.com:10051 \
188-
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \
189186
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \
190-
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE} \
187+
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE}
188+
189+
# Temporary workaround (see FAB-15897) - cannot invoke across all four peers at the same time, so use a query to build
190+
# the chaincode across the remaining peers.
191+
${PEER1_ORG1} chaincode query \
192+
-C mychannel \
193+
-n fabcar \
194+
-c '{"function":"queryAllCars","Args":[]}' \
195+
--peerAddresses peer1.org1.example.com:8051 \
196+
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE}
197+
${PEER1_ORG2} chaincode query \
198+
-C mychannel \
199+
-n fabcar \
200+
-c '{"function":"queryAllCars","Args":[]}' \
201+
--peerAddresses peer1.org2.example.com:10051 \
191202
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE}
192203

193204
cat <<EOF

scripts/ci_scripts/fabcar.sh

+8-11
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

6-
# docker container list - Check these from basic-network/docker-compose.yaml
7-
CONTAINER_LIST=(peer0.org1 orderer ca)
8-
96
logs() {
10-
11-
for CONTAINER in ${CONTAINER_LIST[*]}; do
12-
docker logs $CONTAINER.example.com >& $WORKSPACE/$CONTAINER-$1.log
13-
echo
14-
done
15-
# Write couchdb container logs into couchdb.log file
16-
docker logs couchdb >& couchdb.log
17-
7+
LOG_DIRECTORY=$WORKSPACE/fabcar/$1
8+
mkdir -p ${LOG_DIRECTORY}
9+
CONTAINER_LIST=$(docker ps -a --format '{{.Names}}')
10+
for CONTAINER in ${CONTAINER_LIST}; do
11+
docker logs ${CONTAINER} > ${LOG_DIRECTORY}/${CONTAINER}.log 2>&1
12+
done
1813
}
1914

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

0 commit comments

Comments
 (0)