mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
test-network-k8s: Improve prereqs logic
This patch improves prereqs logic in test-network-k8s. - Use the newer install script instead of bootstrap.sh - Download binaries matching the Docker image versions, instead of the latest version - Add checks for Fabric versions to ensure consistency between images and binaries Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com>
This commit is contained in:
parent
3826626d00
commit
c4daea36b1
2 changed files with 29 additions and 5 deletions
|
|
@ -42,12 +42,28 @@ function check_prereqs() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Use the local fabric binaries if available. If not, go get them.
|
||||
# Define the sed expression to extract the version number
|
||||
VERSION_SED_EXPR='s/^ Version: v\?\(.*\)$/\1/p'
|
||||
|
||||
# Use the fabric peer and ca containers to check fabric image versions
|
||||
# NOTE: About extracting the version number:
|
||||
# In older versions, the prefix 'v' was not included in the version string,
|
||||
# but in recent versions, 'v' has been added.
|
||||
# The following commands remove the optional 'v' to standardize the format.
|
||||
FABRIC_IMAGE_VERSION=$(${CONTAINER_CLI} run --rm ${FABRIC_PEER_IMAGE} peer version | sed -ne "$VERSION_SED_EXPR")
|
||||
FABRIC_CA_IMAGE_VERSION=$(${CONTAINER_CLI} run --rm ${FABRIC_CONTAINER_REGISTRY}/fabric-ca:$FABRIC_CA_VERSION fabric-ca-server version | sed -ne "$VERSION_SED_EXPR")
|
||||
echo "Fabric image versions: Peer ($FABRIC_IMAGE_VERSION), CA ($FABRIC_CA_IMAGE_VERSION)"
|
||||
if [ -z "$FABRIC_IMAGE_VERSION" ] || [ -z "$FABRIC_CA_IMAGE_VERSION" ]; then
|
||||
echo "It seems some of the specified Fabric images are not available."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use the local fabric binaries if available. If not, go get them.
|
||||
bin/peer version &> /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Downloading LATEST Fabric binaries and config"
|
||||
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/bootstrap.sh \
|
||||
| bash -s -- -s -d
|
||||
echo "Downloading Fabric binaries and config"
|
||||
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh \
|
||||
| bash -s -- -f ${FABRIC_IMAGE_VERSION} -c ${FABRIC_CA_IMAGE_VERSION} binary
|
||||
|
||||
# remove sample config files extracted by the installation script
|
||||
rm config/configtx.yaml
|
||||
|
|
@ -55,6 +71,14 @@ function check_prereqs() {
|
|||
rm config/orderer.yaml
|
||||
fi
|
||||
|
||||
# Check if the binaries match your docker images
|
||||
FABRIC_LOCAL_VERSION=$(bin/peer version | sed -ne "$VERSION_SED_EXPR")
|
||||
FABRIC_CA_LOCAL_VERSION=$(bin/fabric-ca-client version | sed -ne "$VERSION_SED_EXPR")
|
||||
echo "Fabric binary versions: Peer ($FABRIC_LOCAL_VERSION), CA ($FABRIC_CA_LOCAL_VERSION)"
|
||||
if [ "$FABRIC_LOCAL_VERSION" != "$FABRIC_IMAGE_VERSION" ] || [ "$FABRIC_CA_LOCAL_VERSION" != "$FABRIC_CA_IMAGE_VERSION" ]; then
|
||||
echo "WARN: Local fabric binaries and docker images are out of sync. This may cause problems."
|
||||
fi
|
||||
|
||||
export PATH=bin:$PATH
|
||||
|
||||
# Double-check that the binary transfer was OK
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ function checkPrereqs() {
|
|||
infoln "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION"
|
||||
|
||||
if [ "$LOCAL_VERSION" != "$DOCKER_IMAGE_VERSION" ]; then
|
||||
warnln "Local fabric binaries and docker images are out of sync. This may cause problems."
|
||||
warnln "Local fabric binaries and docker images are out of sync. This may cause problems."
|
||||
fi
|
||||
|
||||
for UNSUPPORTED_VERSION in $NONWORKING_VERSIONS; do
|
||||
|
|
|
|||
Loading…
Reference in a new issue