Skip to content

Commit

Permalink
Update test network
Browse files Browse the repository at this point in the history
- Simplify test-network setup
- Remove fpc ccaas scripts
- Use network.sh CCaaS install script
- Update Blockchain explorer setup
- Add test-network sample test

Signed-off-by: munapower <[email protected]>
Signed-off-by: Marcus Brandenburger <[email protected]>
  • Loading branch information
munapower authored and mbrandenburger committed Oct 1, 2024
1 parent 33fd56f commit a32ef4f
Show file tree
Hide file tree
Showing 20 changed files with 378 additions and 381 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
[submodule "common/crypto/pdo"]
path = common/crypto/pdo
url = https://github.com/hyperledger-labs/private-data-objects
[submodule "samples/deployment/test-network/fabric-samples"]
path = samples/deployment/test-network/fabric-samples
url = https://github.com/hyperledger/fabric-samples.git
2 changes: 2 additions & 0 deletions build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ include $(TOP)/config.mk

# define composites only here and not in config.mk so we can override parts in config.override.mk
DOCKER := $(DOCKER_CMD) $(DOCKERFLAGS)
DOCKER_COMPOSE := $(DOCKER_CMD) compose

ifeq (${SGX_MODE}, HW)
GOTAGS = -tags sgx_hw_mode
endif
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/hyperledger/fabric-contract-api-go v1.2.1
github.com/hyperledger/fabric-protos-go v0.3.0
github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go v0.0.0-20230505123407-84f9ba1dc4ec
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20240123083657-5d6ca326e01b
github.com/maxbrunsfeld/counterfeiter/v6 v6.6.1
github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.11.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ github.com/hyperledger/fabric-protos-go v0.3.0 h1:MXxy44WTMENOh5TI8+PCK2x6pMj47G
github.com/hyperledger/fabric-protos-go v0.3.0/go.mod h1:WWnyWP40P2roPmmvxsUXSvVI/CF6vwY1K1UFidnKBys=
github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go v0.0.0-20230505123407-84f9ba1dc4ec h1:drq6iuHjLc3H41zGfvljRZky45aLsWfc/J/lc52KjLY=
github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go v0.0.0-20230505123407-84f9ba1dc4ec/go.mod h1:Y4ClFGIk5nmTlFOtryAY+sC55tYCpA6YZItPaKwPY6s=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af h1:/DGxnlhN6Cg1PKj/5K01GUt4X1wN8nRVkZiJiQ05sCw=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af/go.mod h1:JRplpKBeAvXjsBhOCCM/KvMRUbdDyhsAh80qbXzKc10=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20240123083657-5d6ca326e01b h1:ioSmXcO2r9+Sf7QbeaCQkWuTy5uHd+4u5CtFKLJhvRU=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20240123083657-5d6ca326e01b/go.mod h1:JRplpKBeAvXjsBhOCCM/KvMRUbdDyhsAh80qbXzKc10=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down
26 changes: 22 additions & 4 deletions integration/deployment_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ CC_EP="OR('SampleOrg.member')" # note that we use .member as NodeOUs is disabled
NUM_FAILURES=0
NUM_TESTS=0

# downloads github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go
download_chaincode() {
# download destination
local samples_path=$1

git clone -n --depth=1 --filter=tree:0 https://github.com/hyperledger/fabric-samples "$samples_path"
cd "$samples_path" || { echo "$samples_path does not exist" ; exit 1; }
git sparse-checkout set --no-cone asset-transfer-basic/chaincode-go
git checkout
}

run_test() {

# install samples/chaincode/auction
Expand All @@ -42,9 +53,11 @@ run_test() {

# install something non-fpc
# following the official fabric docs at https://hyperledger-fabric.readthedocs.io/en/release-2.5/deploy_chaincode.html
CC_PATH="${FPC_PATH}/samples/deployment/test-network/fabric-samples/asset-transfer-basic/chaincode-go/"
local tmp_dir=$(mktemp -d -t fabric-samples-XXXXXXXXXX --tmpdir="${TMP_DIR}")
download_chaincode "${tmp_dir}"
CC_PATH="${tmp_dir}/asset-transfer-basic/chaincode-go/"
# jump to the basic chaincode sample and fetch deps
(cd ${CC_PATH} && GO111MODULE=on go mod vendor)
(cd "${CC_PATH}" && GO111MODULE=on go mod vendor)

CC_VER="0"
CC_SEQ="1"
Expand Down Expand Up @@ -110,8 +123,13 @@ say "Preparing Test with mixed concurrent chaincodes, FPC and non-FPC ..."
docker_clean ${ERCC_ID}
docker_clean example02

trap ledger_shutdown EXIT

# create tmp folder to store artefacts
TMP_DIR=$(mktemp -d -t tmp-XXXXXXXXXX --tmpdir="${SCRIPTDIR}")
trap cleanup SIGINT SIGTERM ERR EXIT
cleanup() {
rm -rf "${TMP_DIR}"
ledger_shutdown
}

para
say "Run test"
Expand Down
4 changes: 2 additions & 2 deletions samples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
TOP = ..
include $(TOP)/build.mk

SAMPLES = application chaincode demos #deployment
SAMPLES = application chaincode demos deployment

build clean:
build test clean clobber:
$(foreach DIR, $(SAMPLES), $(MAKE) -C $(DIR) $@ || exit;)

2 changes: 1 addition & 1 deletion samples/application/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ include $(TOP)/build.mk

SUB_DIRS = simple-cli-go simple-go

all build test clean clobber:
build test clean clobber:
$(foreach DIR, $(SUB_DIRS), $(MAKE) -C $(DIR) $@ || exit ;)
2 changes: 1 addition & 1 deletion samples/chaincode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ include $(TOP)/build.mk

SUB_DIRS = auction auction-go echo echo-go kv-test kv-test-go

all build test clean clobber:
build test clean clobber:
$(foreach DIR, $(SUB_DIRS), $(MAKE) -C $(DIR) $@ || exit ;)
12 changes: 12 additions & 0 deletions samples/deployment/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0

TOP = ../..
include $(TOP)/build.mk

DEPLOYMENT_SAMPLES = test-network

build test clean clobber:
$(foreach DIR, $(DEPLOYMENT_SAMPLES), $(MAKE) -C $(DIR) $@ || exit;)

5 changes: 3 additions & 2 deletions samples/deployment/test-network/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

**/packages/*
blockchain-explorer
blockchain-explorer/
fabric-samples/
.env
36 changes: 15 additions & 21 deletions samples/deployment/test-network/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,7 @@
TOP = ../../..
include $(TOP)/build.mk

ifeq ($(CC_ID),)
$(error CC_ID is not set)
endif
ifeq ($(CC_PATH),)
$(error CC_PATH is not set)
endif

build: ercc-container ecc-container

ercc-container:
make -C ${FPC_PATH}/ercc all docker

ecc-container:
if [ "${SGX_MODE}" = "HW" ]; then \
export HW_EXTENSION="-hw" ; \
fi && \
make -C ${CC_PATH} && \
make -C ${FPC_PATH}/ecc DOCKER_IMAGE=fpc/fpc-${CC_ID}$${HW_EXTENSION} DOCKER_ENCLAVE_SO_PATH=${CC_PATH}/_build/lib all docker

.PHONY: ercc-ecc-start
ercc-ecc-start:
if [ ! -z "${DOCKERD_FPC_PATH}" ]; then \
export SGX_CREDENTIALS_PATH="${DOCKERD_FPC_PATH}/integration/config/ias"; \
Expand All @@ -35,7 +17,19 @@ ercc-ecc-start:
SGX_DEVICE_PATH=$$(if [ -e "/dev/isgx" ]; then echo "/dev/isgx"; elif [ -e "/dev/sgx/enclave" ]; then echo "/dev/sgx/enclave"; else echo "none"; fi) && \
[ "$${SGX_DEVICE_PATH}" != "none" ] || ( echo "ERROR: SGX_MODE is HW but no sgx device found"; exit 1; ) \
fi && \
env CC_ID=${CC_ID} FPC_VERSION=${FPC_VERSION} docker-compose up
env FPC_VERSION=${FPC_VERSION} ${DOCKER_COMPOSE} up -d

.PHONY: ercc-ecc-start
ercc-ecc-stop:
env CC_ID=${CC_ID} FPC_VERSION=${FPC_VERSION} docker-compose down
${DOCKER_COMPOSE} down

clean:
docker compose down -v
./fabric-samples/test-network/network.sh down || true
rm -rf blockchain-explorer fabric-samples .env
docker system prune --force
docker network prune --force
docker volume prune --force

test:
./test.sh
Loading

0 comments on commit a32ef4f

Please sign in to comment.