Skip to content

Commit

Permalink
Decouple fabric tools image from fabric sample
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Yuan <yy19902439@126.com>
  • Loading branch information
SamYuan1990 committed Mar 22, 2024
1 parent a5eea8c commit fad329d
Show file tree
Hide file tree
Showing 17 changed files with 793 additions and 73 deletions.
2 changes: 2 additions & 0 deletions ci/scripts/run-test-network-sbe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function stopNetwork() {
# Run Javascript application
createNetwork
print "Initializing Javascript application"
# sleep 60s wait for chaincode ready
sleep 60
pushd ../asset-transfer-sbe/application-javascript
npm install
print "Executing app.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ context PEER_IMAGE ghcr.io/hyperledger-labs/fabric-builder-k8s/k8
context PEER_IMAGE_LABEL 0.11.0 # When using k8s-fabric-peer in Fabric v2.5+, 0.11.0+ should be specified
context ORDERER_IMAGE ${FABRIC_CONTAINER_REGISTRY}/fabric-orderer
context ORDERER_IMAGE_LABEL ${FABRIC_VERSION}
context TOOLS_IMAGE ${FABRIC_CONTAINER_REGISTRY}/fabric-tools
context TOOLS_IMAGE_LABEL ${FABRIC_VERSION}
context OPERATOR_IMAGE ghcr.io/hyperledger-labs/fabric-operator
context OPERATOR_IMAGE_LABEL 1.0.4
context INIT_IMAGE registry.access.redhat.com/ubi8/ubi-minimal
Expand All @@ -102,7 +100,6 @@ export FABRIC_DEPLOYER_IMAGE=${DEPLOYER_IMAGE}:${DEPLOYER_IMAGE_LABEL}
export FABRIC_CA_IMAGE=${CA_IMAGE}:${CA_IMAGE_LABEL}
export FABRIC_PEER_IMAGE=${PEER_IMAGE}:${PEER_IMAGE_LABEL}
export FABRIC_ORDERER_IMAGE=${ORDERER_IMAGE}:${ORDERER_IMAGE_LABEL}
export FABRIC_TOOLS_IMAGE=${TOOLS_IMAGE}:${TOOLS_IMAGE_LABEL}

export TEMP_DIR=${PWD}/temp

Expand Down
4 changes: 2 additions & 2 deletions test-network/addOrg3/addOrg3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ function addOrg3 () {
# Use the CLI container to create the configuration transaction needed to add
# Org3 to the network
infoln "Generating and submitting config tx to add Org3"
${CONTAINER_CLI} exec cli ./scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
. ../scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
if [ $? -ne 0 ]; then
fatalln "ERROR !!!! Unable to create config tx"
fi

infoln "Joining Org3 peers to network"
${CONTAINER_CLI} exec cli ./scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
. ../scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
if [ $? -ne 0 ]; then
fatalln "ERROR !!!! Unable to join Org3 peers to network"
fi
Expand Down
775 changes: 775 additions & 0 deletions test-network/addOrg3/core.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test-network/addOrg3/organizations
1 change: 1 addition & 0 deletions test-network/addOrg3/scripts
23 changes: 0 additions & 23 deletions test-network/compose/compose-bft-test-net.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,26 +262,3 @@ services:
- 9445:9445
networks:
- test

cli:
container_name: cli
image: hyperledger/fabric-tools:latest
labels:
service: hyperledger-fabric
tty: true
stdin_open: true
environment:
- GOPATH=/opt/gopath
- FABRIC_LOGGING_SPEC=INFO
- FABRIC_CFG_PATH=/etc/hyperledger/peercfg
#- FABRIC_LOGGING_SPEC=DEBUG
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- ../organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations
- ../scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
depends_on:
- peer0.org1.example.com
- peer0.org2.example.com
networks:
- test
23 changes: 0 additions & 23 deletions test-network/compose/compose-test-net.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,3 @@ services:
- 9445:9445
networks:
- test

cli:
container_name: cli
image: hyperledger/fabric-tools:latest
labels:
service: hyperledger-fabric
tty: true
stdin_open: true
environment:
- GOPATH=/opt/gopath
- FABRIC_LOGGING_SPEC=INFO
- FABRIC_CFG_PATH=/etc/hyperledger/peercfg
#- FABRIC_LOGGING_SPEC=DEBUG
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- ../organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations
- ../scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
depends_on:
- peer0.org1.example.com
- peer0.org2.example.com
networks:
- test
6 changes: 0 additions & 6 deletions test-network/compose/docker/docker-compose-bft-test-net.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,3 @@ services:
volumes:
- ./docker/peercfg:/etc/hyperledger/peercfg
- ${DOCKER_SOCK}:/host/var/run/docker.sock

cli:
container_name: cli
image: hyperledger/fabric-tools:latest
volumes:
- ./docker/peercfg:/etc/hyperledger/peercfg
6 changes: 0 additions & 6 deletions test-network/compose/docker/docker-compose-test-net.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,3 @@ services:
volumes:
- ./docker/peercfg:/etc/hyperledger/peercfg
- ${DOCKER_SOCK}:/host/var/run/docker.sock

cli:
container_name: cli
image: hyperledger/fabric-tools:latest
volumes:
- ./docker/peercfg:/etc/hyperledger/peercfg
2 changes: 1 addition & 1 deletion test-network/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function checkPrereqs() {
# use the fabric tools container to see if the samples and binaries match your
# docker images
LOCAL_VERSION=$(peer version | sed -ne 's/^ Version: //p')
DOCKER_IMAGE_VERSION=$(${CONTAINER_CLI} run --rm hyperledger/fabric-tools:latest peer version | sed -ne 's/^ Version: //p')
DOCKER_IMAGE_VERSION=$(${CONTAINER_CLI} run --rm hyperledger/fabric-peer:latest peer version | sed -ne 's/^ Version: //p')

infoln "LOCAL_VERSION=$LOCAL_VERSION"
infoln "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION"
Expand Down
2 changes: 1 addition & 1 deletion test-network/scripts/configUpdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fetchChannelConfig() {

infoln "Fetching the most recent configuration block for the channel"
set -x
peer channel fetch config config_block.pb -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile "$ORDERER_CA"
peer channel fetch config config_block.pb -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL --tls --cafile "$ORDERER_CA"
{ set +x; } 2>/dev/null

infoln "Decoding config block to JSON and isolating config to ${OUTPUT}"
Expand Down
2 changes: 1 addition & 1 deletion test-network/scripts/createChannel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ joinChannel() {

setAnchorPeer() {
ORG=$1
${CONTAINER_CLI} exec cli ./scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME
. scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME
}


Expand Down
5 changes: 3 additions & 2 deletions test-network/scripts/org3-scripts/joinChannel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ COUNTER=1
MAX_RETRY=5

# import environment variables
. scripts/envVar.sh
. ./scripts/envVar.sh

# joinChannel ORG
joinChannel() {
ORG=$1
setGlobals $ORG
local rc=1
local COUNTER=1
## Sometimes Join takes time, hence retry
Expand All @@ -54,7 +55,7 @@ BLOCKFILE="${CHANNEL_NAME}.block"

echo "Fetching channel config block from orderer..."
set -x
peer channel fetch 0 $BLOCKFILE -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME --tls --cafile "$ORDERER_CA" >&log.txt
peer channel fetch 0 $BLOCKFILE -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME --tls --cafile "$ORDERER_CA" >&log.txt
res=$?
{ set +x; } 2>/dev/null
cat log.txt
Expand Down
1 change: 1 addition & 0 deletions test-network/scripts/org3-scripts/scripts
8 changes: 4 additions & 4 deletions test-network/scripts/org3-scripts/updateChannelConfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ MAX_RETRY=5


# imports
. scripts/envVar.sh
. scripts/configUpdate.sh
. scripts/utils.sh
. ./scripts/envVar.sh
. ./scripts/configUpdate.sh
. ./scripts/utils.sh

infoln "Creating config transaction to add org3 to network"

Expand All @@ -46,7 +46,7 @@ signConfigtxAsPeerOrg 1 org3_update_in_envelope.pb
infoln "Submitting transaction from a different peer (peer0.org2) which also signs it"
setGlobals 2
set -x
peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA"
peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA"
{ set +x; } 2>/dev/null

successln "Config transaction to add org3 to network submitted"
2 changes: 1 addition & 1 deletion test-network/scripts/setAnchorPeer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ createAnchorPeerUpdate() {
}

updateAnchorPeer() {
peer channel update -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ${CORE_PEER_LOCALMSPID}anchors.tx --tls --cafile "$ORDERER_CA" >&log.txt
peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ${CORE_PEER_LOCALMSPID}anchors.tx --tls --cafile "$ORDERER_CA" >&log.txt
res=$?
cat log.txt
verifyResult $res "Anchor peer update failed"
Expand Down

0 comments on commit fad329d

Please sign in to comment.