diff --git a/weaver/tests/network-setups/fabric/dev/Makefile b/weaver/tests/network-setups/fabric/dev/Makefile index 23cf10f960..c7142789eb 100644 --- a/weaver/tests/network-setups/fabric/dev/Makefile +++ b/weaver/tests/network-setups/fabric/dev/Makefile @@ -27,22 +27,22 @@ start-interop-local: start-interop-network1-local start-interop-network2-local .PHONY: start-network1 start-network1: .fabric-setup artifacts-network1 setup-cc - ./network.sh up createChannel -ca -nw network1 -p $(PROFILE) + ./network.sh up createChannel -ca -nw network1 -p $(PROFILE) -i $(FABRIC_VERSION) -cai $(FABRIC_CA_VERSION) ./network.sh deployCC -ch $(CHAINCODE_NAME) -nw network1 -p $(PROFILE) .PHONY: start-network1-local start-network1-local: .fabric-setup artifacts-network1 setup-cc-local - ./network.sh up createChannel -ca -nw network1 -p $(PROFILE) + ./network.sh up createChannel -ca -nw network1 -p $(PROFILE) -i $(FABRIC_VERSION) -cai $(FABRIC_CA_VERSION) ./network.sh deployCC -ch $(CHAINCODE_NAME) -nw network1 -p $(PROFILE) .PHONY: start-network2 start-network2: .fabric-setup artifacts-network2 setup-cc - ./network.sh up createChannel -ca -nw network2 -p $(PROFILE) + ./network.sh up createChannel -ca -nw network2 -p $(PROFILE) -i $(FABRIC_VERSION) -cai $(FABRIC_CA_VERSION) ./network.sh deployCC -ch $(CHAINCODE_NAME) -nw network2 -p $(PROFILE) .PHONY: start-network2-local start-network2-local: .fabric-setup artifacts-network2 setup-cc-local - ./network.sh up createChannel -ca -nw network2 -p $(PROFILE) + ./network.sh up createChannel -ca -nw network2 -p $(PROFILE) -i $(FABRIC_VERSION) -cai $(FABRIC_CA_VERSION) ./network.sh deployCC -ch $(CHAINCODE_NAME) -nw network2 -p $(PROFILE) .PHONY: start-interop-network1 diff --git a/weaver/tests/network-setups/fabric/dev/base.env b/weaver/tests/network-setups/fabric/dev/base.env index 3c5801981c..2791971424 100644 --- a/weaver/tests/network-setups/fabric/dev/base.env +++ b/weaver/tests/network-setups/fabric/dev/base.env @@ -1,2 +1 @@ -IMAGE_TAG=latest SYS_CHANNEL=system-channel diff --git a/weaver/tests/network-setups/fabric/dev/docker/docker-compose-ca.yaml b/weaver/tests/network-setups/fabric/dev/docker/docker-compose-ca.yaml index 3135d0323b..2844c1964b 100644 --- a/weaver/tests/network-setups/fabric/dev/docker/docker-compose-ca.yaml +++ b/weaver/tests/network-setups/fabric/dev/docker/docker-compose-ca.yaml @@ -10,7 +10,7 @@ networks: services: ca_org1: - image: hyperledger/fabric-ca:$IMAGE_TAG + image: hyperledger/fabric-ca:${CA_IMAGE_TAG} environment: - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - FABRIC_CA_SERVER_CA_NAME=ca.org1.${COMPOSE_PROJECT_NAME}.com @@ -27,7 +27,7 @@ services: ca_org2: profiles: ["2-nodes"] - image: hyperledger/fabric-ca:$IMAGE_TAG + image: hyperledger/fabric-ca:${CA_IMAGE_TAG} environment: - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - FABRIC_CA_SERVER_CA_NAME=ca.org2.${COMPOSE_PROJECT_NAME}.com @@ -43,7 +43,7 @@ services: - net ca_orderer: - image: hyperledger/fabric-ca:$IMAGE_TAG + image: hyperledger/fabric-ca:${CA_IMAGE_TAG} environment: - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - FABRIC_CA_SERVER_CA_NAME=ca.orderer.${COMPOSE_PROJECT_NAME}.com diff --git a/weaver/tests/network-setups/fabric/dev/network.sh b/weaver/tests/network-setups/fabric/dev/network.sh index 8ffd7b1482..6ade978f69 100755 --- a/weaver/tests/network-setups/fabric/dev/network.sh +++ b/weaver/tests/network-setups/fabric/dev/network.sh @@ -12,6 +12,8 @@ # # prepending $PWD/../bin to PATH to ensure we are picking up the correct binaries # this may be commented out to resolve installed version of tools if desired +set -e + export PATH=${PWD}/bin:${PWD}:$PATH export FABRIC_CFG_PATH=$NW_CFG_PATH/configtx export VERBOSE=false @@ -39,6 +41,7 @@ function printHelp() { echo " -l - the programming language of the chaincode to deploy: go (default), java, javascript, typescript" echo " -v - chaincode version. Must be a round number, 1, 2, 3, etc" echo " -i - the tag to be used to launch the network (defaults to \"latest\")" + echo " -cai - the tag to be used to launch the certificat authority network (defaults to \"latest\")" echo " -verbose - verbose mode" echo " network.sh -h (print this message)" echo @@ -123,14 +126,12 @@ function checkPrereqs() { fi for UNSUPPORTED_VERSION in $BLACKLISTED_VERSIONS; do - echo "$LOCAL_VERSION" | grep -q $UNSUPPORTED_VERSION - if [ $? -eq 0 ]; then + if [[ $LOCAL_VERSION =~ $UNSUPPORTED_VERSION ]]; then echo "ERROR! Local Fabric binary version of $LOCAL_VERSION does not match the versions supported by the test network." exit 1 fi - echo "$DOCKER_IMAGE_VERSION" | grep -q $UNSUPPORTED_VERSION - if [ $? -eq 0 ]; then + if [[ $DOCKER_IMAGE_VERSION =~ $UNSUPPORTED_VERSION ]]; then echo "ERROR! Fabric Docker image version of $DOCKER_IMAGE_VERSION does not match the versions supported by the test network." exit 1 fi @@ -253,7 +254,7 @@ function createOrgs() { envsubst < docker/docker-compose-ca.yaml > docker/docker-compose-ca.real.yaml COMPOSE_FILE_CA=docker/docker-compose-ca.real.yaml - IMAGE_TAG=$IMAGETAG docker compose -f $COMPOSE_FILE_CA --env-file=docker.real.env --profile $DOCKER_PROFILES up -d 2>&1 + docker compose -f $COMPOSE_FILE_CA --env-file=docker.real.env --profile $DOCKER_PROFILES up -d 2>&1 . $NW_CFG_PATH/fabric-ca/registerEnroll.sh @@ -359,7 +360,7 @@ function networkUp() { envsubst < docker.env > docker.real.env envsubst < docker/docker-compose-ca.yaml > docker/docker-compose-ca.real.yaml COMPOSE_FILE_CA=docker/docker-compose-ca.real.yaml - IMAGE_TAG=$IMAGETAG docker compose -f $COMPOSE_FILE_CA --env-file=docker.real.env --profile $DOCKER_PROFILES up -d 2>&1 + docker compose -f $COMPOSE_FILE_CA --env-file=docker.real.env --profile $DOCKER_PROFILES up -d 2>&1 fi envsubst < docker/docker-compose-test-net.yaml > docker/docker-compose-test-net.real.yaml @@ -375,7 +376,7 @@ function networkUp() { echo "NW config path.. : "$NW_CFG_PATH cat docker.env envsubst < docker.env > docker.real.env - IMAGE_TAG=$IMAGETAG NW_CFG_PATH=$NW_CFG_PATH docker compose ${COMPOSE_FILES} --env-file=docker.real.env --profile $DOCKER_PROFILES up -d 2>&1 + NW_CFG_PATH=$NW_CFG_PATH docker compose ${COMPOSE_FILES} --env-file=docker.real.env --profile $DOCKER_PROFILES up -d 2>&1 docker ps -a if [ $? -ne 0 ]; then @@ -488,6 +489,8 @@ CC_SRC_LANGUAGE=golang VERSION=1 # default image tag IMAGETAG="latest" +# default ca image tag +CAIMAGETAG="latest" # default database DATABASE="leveldb" # default chaincode @@ -519,9 +522,6 @@ export N2_PEER_ORG1_PORT=${N2_PEER_ORG1_PORT:-9051} export N2_PEER_ORG2_PORT=${N2_PEER_ORG2_PORT:-9061} export COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} -export IMAGE_TAG=$IMAGE_TAG - - # Parse commandline args @@ -599,6 +599,10 @@ while [[ $# -ge 1 ]] ; do IMAGETAG="$2" shift ;; + -cai ) + CAIMAGETAG="$2" + shift + ;; -verbose ) VERBOSE=true shift @@ -623,6 +627,9 @@ while [[ $# -ge 1 ]] ; do shift done +export IMAGE_TAG=${IMAGETAG} +export CA_IMAGE_TAG=${CAIMAGETAG} + SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" APP_ROOT=${APP_ROOT:-"${SCRIPT_PATH}/../.."} # This function resolves the path and expands all ../../ components @@ -738,7 +745,7 @@ if [ $ROLE == "network1" ]; then . network1.env echo "FABRIC_CFG_PATH = $FABRIC_CFG_PATH" echo "NW_CFG_PATH" = $NW_CFG_PATH - rm docker.env + rm -f docker.env cat base.env network1.env > network1.tmp.env echo "APP_ROOT=${APP_ROOT}" | cat - network1.tmp.env > docker.env elif [ $ROLE == "network2" ]; then @@ -749,7 +756,7 @@ elif [ $ROLE == "network2" ]; then . network2.env echo "FABRIC_CFG_PATH = $FABRIC_CFG_PATH" echo "NW_CFG_PATH" = $NW_CFG_PATH - rm docker.env + rm -f docker.env cat base.env network2.env > network2.tmp.env echo "APP_ROOT=${APP_ROOT}" | cat - network2.tmp.env > docker.env else