fabric-samples/scripts/Jenkins_Scripts/fabcar.sh
Simon Stone c18419644d [FAB-12878] Add fabcar app using new prog model (TS)
Add a new version of the FabCar applications using the new
programming model (fabric-network), written in TypeScript.

The new programming model requires a connection profile, so
I have added connection profiles (JSON and YAML) versions to
the basic-network sample. When we switch FabCar to use first-network,
we will have to add connection profiles into that as well.

Change-Id: I81bae907fc64a1cde0234325f37b53e5cd7964e5
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
2018-12-07 22:18:37 +00:00

63 lines
1.7 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"
# Start Fabric, and deploy the smart contract
./startFabric.sh ${LANGUAGE}
copy_logs $? fabcar-${LANGUAGE}
# If an application exists for this language, test it
if [ -d ${LANGUAGE} ]; then
pushd ${LANGUAGE}
if [ ${LANGUAGE} = "typescript" ]; then
COMMAND=node
PREFIX=dist/
SUFFIX=.js
npm install
npm run build
fi
${COMMAND} ${PREFIX}enrollAdmin${SUFFIX}
copy_logs $? fabcar-${LANGUAGE}-enrollAdmin
${COMMAND} ${PREFIX}registerUser${SUFFIX}
copy_logs $? fabcar-${LANGUAGE}-registerUser
${COMMAND} ${PREFIX}query${SUFFIX}
copy_logs $? fabcar-${LANGUAGE}-query
${COMMAND} ${PREFIX}invoke${SUFFIX}
copy_logs $? fabcar-${LANGUAGE}-invoke
popd
fi
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