[FAB-17952] Fix test-network to use the latest version of fabric-ca (#195)

To get rid of hard-coded versioning and use the latest version of fabric-ca
in test-network, this patch modifies the existence check logic of
the fabric-ca-client binary in the same way as peer and orderer.

Also, this patch updates addOrg3.sh to use cai <ca_imagetag> option.

Signed-off-by: Tatsuya Sato <Tatsuya.Sato@hal.hitachi.com>
This commit is contained in:
Tatsuya Sato 2020-06-03 10:34:26 -07:00 committed by GitHub
parent 87a2bc7afd
commit 808f035088
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 28 deletions

View file

@ -30,6 +30,7 @@ function printHelp () {
echo " -d <delay> - delay duration in seconds (defaults to 3)"
echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb"
echo " -i <imagetag> - the tag to be used to launch the network (defaults to \"latest\")"
echo " -cai <ca_imagetag> - the image tag to be used for CA (defaults to \"${CA_IMAGETAG}\")"
echo " -verbose - verbose mode"
echo
echo "Typically, one would first generate the required certificates and "
@ -84,17 +85,12 @@ function generateOrg3() {
if [ "$CRYPTO" == "Certificate Authorities" ]; then
fabric-ca-client version > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Fabric CA client not found locally, downloading..."
cd ../..
curl -s -L "https://github.com/hyperledger/fabric-ca/releases/download/v1.4.4/hyperledger-fabric-ca-${OS_ARCH}-1.4.4.tar.gz" | tar xz || rc=$?
if [ -n "$rc" ]; then
echo "==> There was an error downloading the binary file."
echo "fabric-ca-client binary is not available to download"
else
echo "==> Done."
cd test-network/addOrg3/
fi
if [[ $? -ne 0 ]]; then
echo "ERROR! fabric-ca-client binary not found.."
echo
echo "Follow the instructions in the Fabric docs to install the Fabric Binaries:"
echo "https://hyperledger-fabric.readthedocs.io/en/latest/install.html"
exit 1
fi
echo
@ -102,14 +98,14 @@ function generateOrg3() {
echo "##### Generate certificates using Fabric CA's ############"
echo "##########################################################"
IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1
IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1
. fabric-ca/registerEnroll.sh
sleep 10
echo "##########################################################"
echo "############ Create Org1 Identities ######################"
echo "############ Create Org3 Identities ######################"
echo "##########################################################"
createOrg3
@ -233,6 +229,8 @@ COMPOSE_FILE_ORG3=docker/docker-compose-org3.yaml
COMPOSE_FILE_CA_ORG3=docker/docker-compose-ca-org3.yaml
# default image tag
IMAGETAG="latest"
# default ca image tag
CA_IMAGETAG="latest"
# database
DATABASE="leveldb"
@ -279,6 +277,10 @@ while [[ $# -ge 1 ]] ; do
IMAGETAG=$(go env GOARCH)"-""$2"
shift
;;
-cai )
CA_IMAGETAG="$2"
shift
;;
-verbose )
VERBOSE=true
shift

View file

@ -125,6 +125,30 @@ function checkPrereqs() {
exit 1
fi
done
## Check for fabric-ca
if [ "$CRYPTO" == "Certificate Authorities" ]; then
fabric-ca-client version > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "ERROR! fabric-ca-client binary not found.."
echo
echo "Follow the instructions in the Fabric docs to install the Fabric Binaries:"
echo "https://hyperledger-fabric.readthedocs.io/en/latest/install.html"
exit 1
fi
CA_LOCAL_VERSION=$(fabric-ca-client version | sed -ne 's/ Version: //p')
CA_DOCKER_IMAGE_VERSION=$(docker run --rm hyperledger/fabric-ca:$CA_IMAGETAG fabric-ca-client version | sed -ne 's/ Version: //p' | head -1)
echo "CA_LOCAL_VERSION=$CA_LOCAL_VERSION"
echo "CA_DOCKER_IMAGE_VERSION=$CA_DOCKER_IMAGE_VERSION"
if [ "$CA_LOCAL_VERSION" != "$CA_DOCKER_IMAGE_VERSION" ]; then
echo "=================== WARNING ======================"
echo " Local fabric-ca binaries and docker images are "
echo " out of sync. This may cause problems. "
echo "=================================================="
fi
fi
}
@ -216,20 +240,6 @@ function createOrgs() {
# Create crypto material using Fabric CAs
if [ "$CRYPTO" == "Certificate Authorities" ]; then
fabric-ca-client version > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Fabric CA client not found locally, downloading..."
cd ..
curl -s -L "https://github.com/hyperledger/fabric-ca/releases/download/v${CA_IMAGETAG}/hyperledger-fabric-ca-${OS_ARCH}-${CA_IMAGETAG}.tar.gz" | tar xz
if [ -n "$rc" ]; then
echo "==> There was an error downloading the binary file."
echo "fabric-ca-client binary is not available to download"
else
echo "==> Done."
cd test-network
fi
fi
echo
echo "##########################################################"
echo "##### Generate certificates using Fabric CA's ############"
@ -439,7 +449,7 @@ VERSION=1
# default image tag
IMAGETAG="latest"
# default ca image tag
CA_IMAGETAG="1.4.6"
CA_IMAGETAG="latest"
# default database
DATABASE="leveldb"