fabric-samples/scripts/Jenkins_Scripts/fabcar.sh
Simon Stone 928b72b60a [FAB-12875] Add automated tests for fabcar sample
Introduce automated tests for the fabcar sample, that deploy
the new sample contracts and submit the initLedger transaction
using the "peer" CLI.

Additional changes will follow to drive the new sample apps
to ensure that they work as well (but the apps aren't there
yet!).

Change-Id: Ie42d139eb1dc1cf0f7c16f41f54bb5f40309921c
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
2018-11-30 09:52:25 +00:00

42 lines
1 KiB
Bash
Executable file

#!/bin/bash
#
# 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
}
copy_logs() {
# Call logs function
logs $2 $3
if [ $1 != 0 ]; then
echo -e "\033[31m $2 test case is FAILED" "\033[0m"
exit 1
fi
}
cd $BASE_FOLDER/fabric-samples/fabcar || exit
export PATH=gopath/src/github.com/hyperledger/fabric-samples/bin:$PATH
LANGUAGES="go javascript typescript"
for LANGUAGE in ${LANGUAGES}; do
echo -e "\033[32m starting fabcar test (${LANGUAGE})" "\033[0m"
./startFabric.sh ${LANGUAGE}
copy_logs $? fabcar-${LANGUAGE}
docker ps -aq | xargs docker rm -f
docker rmi -f $(docker images -aq dev-*)
echo -e "\033[32m finished fabcar test (${LANGUAGE})" "\033[0m"
done