Skip to content

Commit

Permalink
Improve integration tests (#1259)
Browse files Browse the repository at this point in the history
Signed-off-by: D <d_kelsey@uk.ibm.com>

Co-authored-by: D <d_kelsey@uk.ibm.com>
  • Loading branch information
davidkel and davidkel committed Mar 11, 2022
1 parent a84cdd9 commit ba1ffcf
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 16 deletions.
27 changes: 23 additions & 4 deletions .build/benchmark-integration-test-direct.sh
Expand Up @@ -20,13 +20,32 @@ set -o pipefail
# Bootstrap the project again
npm i && npm run repoclean -- --yes && npm run bootstrap

# Call CLI directly
# The CWD will be in one of the caliper-tests-integration/*_tests directories
export CALL_METHOD="node ../../caliper-cli/caliper.js"
# Get the root directory of the caliper source
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
echo $ROOT_DIR

# Call the CLI directly in the source tree
export CALL_METHOD="node $ROOT_DIR/packages/caliper-cli/caliper.js"
# Use explicit binding for
export BIND_IN_PACKAGE_DIR=true
export GENERATOR_METHOD="yo ../../../generator-caliper/generators/benchmark/index.js"

# Call the Generator code directly from source
export GENERATOR_METHOD="yo $ROOT_DIR/packages/generator-caliper/generators/benchmark/index.js"

# Create a directory outside of the source code tree to install SUT binding node modules
# We have to do this otherwise npm will attempt to hoist the npm modules to a directory
# which subsequently doesn't get searched
# This approach means we can drop having to declare dependencies on SUT bound modules in the
# connector and makes it more like the way a user would use caliper.
export SUT_DIR=$HOME/sut
echo $SUT_DIR
mkdir -p $SUT_DIR

# Ensure node searches this directory by setting NODE_PATH
export NODE_PATH=$SUT_DIR/node_modules

echo "---- Running Integration test for adaptor ${BENCHMARK}"
cd ./packages/caliper-tests-integration/
./run-tests.sh

rm -fr $SUT_DIR
4 changes: 3 additions & 1 deletion packages/caliper-cli/lib/lib/config.yaml
Expand Up @@ -52,8 +52,10 @@ sut:
latest: *fisco-latest

ethereum:
1.2.1: &ethereum-latest
1.2.1:
packages: ['web3@1.2.2']
1.3: &ethereum-latest
packages: ['web3@1.3.0']
latest: *ethereum-latest

besu:
Expand Down
1 change: 0 additions & 1 deletion packages/caliper-ethereum/package.json
Expand Up @@ -24,7 +24,6 @@
"dependencies": {
"@hyperledger/caliper-core": "0.5.0-unstable",
"ethereumjs-wallet": "^0.6.3",
"web3": "1.3.0",
"web3-eea": "0.10.0"
},
"devDependencies": {
Expand Down
3 changes: 0 additions & 3 deletions packages/caliper-fabric/package.json
Expand Up @@ -27,9 +27,6 @@
"semver": "7.1.1"
},
"devDependencies": {
"fabric-ca-client": "^1.4.19",
"fabric-client": "^1.4.19",
"fabric-network": "^1.4.19",
"fabric-protos": "2.1.0",
"chai": "^3.5.0",
"chai-as-promised": "^7.1.1",
Expand Down
1 change: 0 additions & 1 deletion packages/caliper-fisco-bcos/package.json
Expand Up @@ -33,7 +33,6 @@
"uuid": "^3.3.2"
},
"devDependencies": {
"web3": "0.20.7",
"license-check-and-add": "2.3.6"
},
"license-check-and-add-config": {
Expand Down
4 changes: 3 additions & 1 deletion packages/caliper-tests-integration/besu_tests/run.sh
Expand Up @@ -25,7 +25,9 @@ npm i
# bind during CI tests, using the package dir as CWD
# Note: do not use env variables for binding settings, as subsequent launch calls will pick them up and bind again
if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then
${CALL_METHOD} bind --caliper-bind-sut besu:latest --caliper-bind-cwd ./../../caliper-ethereum/ --caliper-bind-args="--no-save"
pushd $SUT_DIR
${CALL_METHOD} bind --caliper-bind-sut besu:latest
popd
fi

# change default settings (add config paths too)
Expand Down
4 changes: 3 additions & 1 deletion packages/caliper-tests-integration/ethereum_tests/run.sh
Expand Up @@ -23,7 +23,9 @@ cd "${DIR}"
# bind during CI tests, using the package dir as CWD
# Note: do not use env variables for binding settings, as subsequent launch calls will pick them up and bind again
if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then
${CALL_METHOD} bind --caliper-bind-sut ethereum:latest --caliper-bind-cwd ./../../caliper-ethereum/ --caliper-bind-args="--no-save"
pushd $SUT_DIR
${CALL_METHOD} bind --caliper-bind-sut ethereum:latest
popd
fi

# change default settings (add config paths too)
Expand Down
12 changes: 9 additions & 3 deletions packages/caliper-tests-integration/fabric_tests/run.sh
Expand Up @@ -30,7 +30,9 @@ cd ${DIR}
# bind during CI tests, using the package dir as CWD
# Note: do not use env variables for binding settings, as subsequent launch calls will pick them up and bind again
if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then
${CALL_METHOD} bind --caliper-bind-sut fabric:1.4 --caliper-bind-cwd ./../../caliper-fabric/
pushd $SUT_DIR
${CALL_METHOD} bind --caliper-bind-sut fabric:1.4
popd
fi

# change default settings (add config paths too)
Expand Down Expand Up @@ -103,12 +105,16 @@ fi
# UNBIND SDK, using the package dir as CWD
# Note: do not use env variables for unbinding settings, as subsequent launch calls will pick them up and bind again
if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then
${CALL_METHOD} unbind --caliper-bind-sut fabric:1.4 --caliper-bind-cwd ./../../caliper-fabric/ --caliper-projectconfig ./caliper.yaml
pushd $SUT_DIR
${CALL_METHOD} unbind --caliper-bind-sut fabric:1.4
popd
fi
# BIND with 2.2 SDK, using the package dir as CWD
# Note: do not use env variables for unbinding settings, as subsequent launch calls will pick them up and bind again
if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then
${CALL_METHOD} bind --caliper-bind-sut fabric:2.2 --caliper-bind-cwd ./../../caliper-fabric/
pushd $SUT_DIR
${CALL_METHOD} bind --caliper-bind-sut fabric:2.2
popd
fi

# PHASE 6: testing through the gateway API (v2 SDK)
Expand Down
4 changes: 3 additions & 1 deletion packages/caliper-tests-integration/fisco-bcos_tests/run.sh
Expand Up @@ -23,7 +23,9 @@ cd "${DIR}"
# bind during CI tests, using the package dir as CWD
# Note: do not use env variables for binding settings, as subsequent launch calls will pick them up and bind again
if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then
${CALL_METHOD} bind --caliper-bind-sut fisco-bcos:latest --caliper-bind-cwd ./../../caliper-fisco-bcos/ --caliper-bind-args="--no-save"
pushd $SUT_DIR
${CALL_METHOD} bind --caliper-bind-sut fisco-bcos:latest
popd
fi

# change default settings (add config paths too)
Expand Down
Expand Up @@ -45,6 +45,10 @@ docker image tag hyperledger/fabric-ccenv:1.4.8 hyperledger/fabric-ccenv:latest
${GENERATOR_METHOD} -- --workspace 'myWorkspace' --contractId 'mymarbles' --contractVersion 'v0' --contractFunction 'queryMarblesByOwner' --contractArguments '["Alice"]' --workers 'marbles' --benchmarkName 'A name for the marbles benchmark' --benchmarkDescription 'A description for the marbles benchmark' --label 'A label for the round' --rateController 'fixed-rate' --txType 'txDuration' --txDuration 'marbles'
# start network and run benchmark test
cd ../
# bind the sdk into the packages directory as it will search for it there, this ensures it doesn't contaminate real node_modules dirs (2.2 will work with a 1.4 fabric)
pushd $SUT_DIR
${CALL_METHOD} bind --caliper-bind-sut fabric:2.2
popd
${CALL_METHOD} launch manager --caliper-workspace 'fabric/myWorkspace' --caliper-networkconfig 'networkconfig.yaml' --caliper-benchconfig 'benchmarks/config.yaml' --caliper-flow-skip-end
rc=$?
if [[ ${rc} != 0 ]]; then
Expand Down

0 comments on commit ba1ffcf

Please sign in to comment.