Skip to content

Commit

Permalink
[FABN-1184] Add CI script for fabtoken sample app
Browse files Browse the repository at this point in the history
Change-Id: I611d9249c177a8bbc7e36d0406b81eb8e69dfa3e
Signed-off-by: Wenjian Qiao <wenjianq@gmail.com>
  • Loading branch information
wenjianqiao committed Apr 11, 2019
1 parent fdf88df commit 5056a23
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 148 deletions.
21 changes: 21 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,27 @@
}
}
}
// Run fabtoken tests
stage('Run FabToken Tests') {
steps {
script {
// making the output color coded
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("$ROOTDIR/$BASE_DIR/scripts/ci_scripts") {
// Run fabtoken tests
sh './ciScript.sh --fabtoken_Tests'
}
}
catch (err) {
failure_stage = "fabtoken_Tests"
currentBuild.result = 'FAILURE'
throw err
}
}
}
}
}
} // stages
post {
always {
Expand Down
148 changes: 0 additions & 148 deletions scripts/Jenkins_Scripts/CI_Script.sh

This file was deleted.

21 changes: 21 additions & 0 deletions scripts/ci_scripts/ciScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Parse_Arguments() {
--fabcar_Tests)
fabcar_Tests
;;
--fabtoken_Tests)
fabtoken_Tests
;;
esac
shift
done
Expand Down Expand Up @@ -51,4 +54,22 @@ fabcar_Tests() {
./fabcar.sh
}

# run fabtoken tests
fabtoken_Tests() {

echo " #############################"
echo "npm version ------> $(npm -v)"
echo "node version ------> $(node -v)"
echo " #############################"

echo
echo " _____ _ ____ _______ __ ___ __ _____ __ __ "
echo " | ___| / \ | __ ) |__ __| / _ \ | | / / | ____| | |\ | | "
echo " | |_ / _ \ | _ \ | | | | | | | |/ / | |___ | | \ | | "
echo " | _| / ___ \ | |_) | | | | |_ | | | |\ \ | ___| | | \ | | "
echo " |_| /_/ \_\ |____/ |_| \ __ / |_| \_\ |_|____ |_| \|_| "

./fabtoken.sh
}

Parse_Arguments $@
48 changes: 48 additions & 0 deletions scripts/ci_scripts/fabtoken.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/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 $WORKSPACE/$BASE_DIR/fabtoken || exit
export PATH=gopath/src/github.com/hyperledger/fabric-samples/bin:$PATH

LANGUAGE="javascript"

echo -e "\033[32m starting fabtoken test (${LANGUAGE})" "\033[0m"
./startFabric.sh
copy_logs $? fabtoken-start-script-${LANGUAGE}

pushd ${LANGUAGE}
npm install
node fabtoken.js
copy_logs $? fabtoken-${LANGUAGE}
popd

docker ps -aq | xargs docker rm -f
docker rmi -f $(docker images -aq dev-*)
echo -e "\033[32m finished fabtoken tests (${LANGUAGE})" "\033[0m"

0 comments on commit 5056a23

Please sign in to comment.