├── .build ├── benchmark-integration-test-direct.sh ├── check-prerequisites.sh ├── checks-and-unit-tests.sh └── publish-caliper.sh ├── .devcontainer └── devcontainer.json ├── .editorconfig ├── .eslintignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.yml │ ├── config.yml │ └── feature-request.yml ├── stale.yml └── workflows │ ├── coverage.yml │ ├── dci.yml │ ├── integration-tests.yml │ ├── main.yml │ ├── pr.yml │ ├── publish.yml │ └── unit-tests.yml ├── .gitignore ├── .npmrc ├── CHANGELOG.md ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE ├── LICENSE.txt ├── MAINTAINERS.md ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── RELEASE_PROCESS.md ├── SECURITY.md ├── dev-docs ├── README.md ├── figures │ └── .gitkeep ├── generate-figure.sh └── proposals │ └── 0000-proposal-template.md ├── docs ├── .gitignore ├── mkdocs.yml ├── overrides │ └── css │ │ └── custom.css ├── pip-requirements.txt └── source │ ├── _static │ ├── arch_high_level.png │ ├── arch_ipc.png │ ├── arch_local_mqtt.png │ ├── arch_manager_process.png │ ├── arch_messages.png │ ├── arch_processes.png │ ├── arch_remote_mqtt.png │ ├── arch_worker_process.png │ ├── architecture.png │ ├── benchmark.png │ ├── caliper.svg │ └── report.png │ ├── assets │ ├── img │ │ └── hyperledger_caliper_logo_color.png │ ├── project-icon.png │ └── project-logo.png │ ├── concepts │ ├── bench-config.md │ ├── benchmark-generators.md │ ├── caliper-messengers.md │ ├── caliper-monitors.md │ ├── declarative-workload-module.md │ ├── logging-control.md │ ├── rate-controllers.md │ ├── runtime-config.md │ └── workload-module.md │ ├── connectors │ ├── fabric-config.md │ └── writing-connectors.md │ ├── getting-started │ ├── architecture.md │ ├── contributing.md │ ├── faq.md │ ├── installing-caliper.md │ └── license.md │ ├── index.md │ └── tutorial │ ├── fabric.md │ └── index.md ├── json-schema └── hyperledger-caliper-runtime-configuration.schema.json ├── package-lock.json ├── package.json ├── packages ├── caliper-cli │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── caliper.js │ ├── index.js │ ├── lib │ │ ├── bindCommand.js │ │ ├── launch │ │ │ ├── launchManagerCommand.js │ │ │ ├── launchWorkerCommand.js │ │ │ └── lib │ │ │ │ ├── launchManager.js │ │ │ │ └── launchWorker.js │ │ ├── launchCommand.js │ │ ├── lib │ │ │ ├── bindCommon.js │ │ │ └── config.yaml │ │ └── unbindCommand.js │ └── package.json ├── caliper-core │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── index.js │ ├── lib │ │ ├── common │ │ │ ├── config │ │ │ │ ├── Config.js │ │ │ │ ├── config-util.js │ │ │ │ └── default.yaml │ │ │ ├── core │ │ │ │ ├── connector-base.js │ │ │ │ ├── connector-interface.js │ │ │ │ ├── transaction-statistics-collector.js │ │ │ │ └── transaction-status.js │ │ │ ├── messages │ │ │ │ ├── assignIdMessage.js │ │ │ │ ├── assignedMessage.js │ │ │ │ ├── connectedMessage.js │ │ │ │ ├── exitMessage.js │ │ │ │ ├── initializeMessage.js │ │ │ │ ├── message.js │ │ │ │ ├── parse.js │ │ │ │ ├── prepareMessage.js │ │ │ │ ├── preparedMessage.js │ │ │ │ ├── readyMessage.js │ │ │ │ ├── registerMessage.js │ │ │ │ ├── testMessage.js │ │ │ │ ├── testResultMessage.js │ │ │ │ ├── txResetMessage.js │ │ │ │ ├── txUpdateMessage.js │ │ │ │ └── workerMetricsMessage.js │ │ │ ├── messengers │ │ │ │ ├── messenger-interface.js │ │ │ │ ├── mqtt │ │ │ │ │ ├── factory.js │ │ │ │ │ └── mqtt-messenger.js │ │ │ │ └── process │ │ │ │ │ ├── factory.js │ │ │ │ │ └── process-messenger.js │ │ │ ├── prometheus │ │ │ │ ├── prometheus-query-client.js │ │ │ │ └── prometheus-query-helper.js │ │ │ └── utils │ │ │ │ ├── benchmark-validator.js │ │ │ │ ├── caliper-utils.js │ │ │ │ ├── constants.js │ │ │ │ ├── log-formats.js │ │ │ │ ├── logging-util.js │ │ │ │ └── version.js │ │ ├── manager │ │ │ ├── caliper-engine.js │ │ │ ├── charts │ │ │ │ └── chart-builder.js │ │ │ ├── monitors │ │ │ │ ├── monitor-docker.js │ │ │ │ ├── monitor-interface.js │ │ │ │ ├── monitor-process.js │ │ │ │ ├── monitor-prometheus.js │ │ │ │ └── monitor-utilities.js │ │ │ ├── orchestrators │ │ │ │ ├── monitor-orchestrator.js │ │ │ │ ├── round-orchestrator.js │ │ │ │ └── worker-orchestrator.js │ │ │ ├── report │ │ │ │ ├── report-builder.js │ │ │ │ ├── report.js │ │ │ │ └── template │ │ │ │ │ └── report.html │ │ │ └── test-observers │ │ │ │ ├── default-observer.js │ │ │ │ ├── null-observer.js │ │ │ │ ├── observer-interface.js │ │ │ │ └── test-observer.js │ │ └── worker │ │ │ ├── caliper-worker.js │ │ │ ├── rate-control │ │ │ ├── compositeRate.js │ │ │ ├── fixedFeedbackRate.js │ │ │ ├── fixedLoad.js │ │ │ ├── fixedRate.js │ │ │ ├── linearRate.js │ │ │ ├── maxRate.js │ │ │ ├── noRate.js │ │ │ ├── rateControl.js │ │ │ ├── rateInterface.js │ │ │ ├── recordRate.js │ │ │ └── replayRate.js │ │ │ ├── tx-observers │ │ │ ├── internal-tx-observer.js │ │ │ ├── logging-tx-observer.js │ │ │ ├── prometheus-manager-tx-observer.js │ │ │ ├── prometheus-push-tx-observer.js │ │ │ ├── prometheus-tx-observer.js │ │ │ ├── tx-observer-dispatch.js │ │ │ └── tx-observer-interface.js │ │ │ ├── worker-message-handler.js │ │ │ └── workload │ │ │ ├── workloadModuleBase.js │ │ │ └── workloadModuleInterface.js │ ├── package.json │ └── test │ │ ├── common │ │ ├── core │ │ │ ├── connector-base.js │ │ │ ├── transaction-statisitcs-collector.js │ │ │ ├── transaction-statistics-collector.js │ │ │ └── transaction-status.js │ │ ├── messages │ │ │ ├── assignedMessage.js │ │ │ ├── message.js │ │ │ ├── preparedMessage.js │ │ │ └── readyMessage.js │ │ ├── prometheus │ │ │ └── prometheus-query-helper.js │ │ └── utils │ │ │ └── caliper-utils.js │ │ ├── manager │ │ ├── caliper-engine.js │ │ ├── charts │ │ │ └── chart-builder.js │ │ ├── monitors │ │ │ ├── monitor-docker.js │ │ │ ├── monitor-prometheus.js │ │ │ └── monitor-utilities.js │ │ ├── orchestrators │ │ │ └── worker-orchestrator.js │ │ └── report │ │ │ └── report.js │ │ └── worker │ │ ├── caliper-worker.js │ │ ├── rate-control │ │ ├── fixedFeedbackRate.js │ │ ├── fixedLoad.js │ │ ├── fixedRate.js │ │ ├── linearRate.js │ │ ├── maxRate.js │ │ ├── mockRate.js │ │ ├── noRate.js │ │ └── recordRate.js │ │ ├── tx-observers │ │ ├── internal-tx-observer.js │ │ ├── logging-tx-observer.js │ │ ├── prometheus-manager-tx-observer.js │ │ ├── prometheus-push-tx-observer.js │ │ ├── prometheus-tx-observer.js │ │ └── tx-observer-dispatch.js │ │ └── worker-message-handler.js ├── caliper-fabric │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── .npmignore │ ├── index.js │ ├── lib │ │ ├── FabricConnectorContext.js │ │ ├── FabricConnectorFactory.js │ │ ├── connector-configuration │ │ │ ├── ConnectionProfileDefinition.js │ │ │ ├── ConnectorConfiguration.js │ │ │ └── ConnectorConfigurationFactory.js │ │ ├── connector-versions │ │ │ ├── peer-gateway │ │ │ │ ├── PeerGateway.js │ │ │ │ ├── WalletFacade.js │ │ │ │ └── WalletFacadeFactory.js │ │ │ └── v2 │ │ │ │ ├── FabricGateway.js │ │ │ │ ├── WalletFacade.js │ │ │ │ └── WalletFacadeFactory.js │ │ └── identity-management │ │ │ ├── ExportedIdentity.js │ │ │ ├── IWalletFacade.js │ │ │ ├── IWalletFacadeFactory.js │ │ │ ├── IdentityManager.js │ │ │ └── IdentityManagerFactory.js │ ├── package.json │ └── test │ │ ├── FabricConnectorFactory.js │ │ ├── connector-configuration │ │ ├── ConnectionProfileDefinition.js │ │ ├── ConnectorConfiguration.js │ │ └── ConnectorConfigurationFactory.js │ │ ├── connector-versions │ │ ├── peer-gateway │ │ │ ├── PeerGateway.js │ │ │ ├── PeerGatewayStubs.js │ │ │ └── WalletFacade.js │ │ └── v2 │ │ │ ├── FabricGateway.js │ │ │ ├── V2GatewayStubs.js │ │ │ └── WalletFacade.js │ │ ├── identity-management │ │ └── IdentityManager.js │ │ ├── sample-configs │ │ ├── BasicConfig.json │ │ ├── BasicConfig.yaml │ │ ├── BasicConfigNotMutual.yaml │ │ ├── BasicConfigNotMutualWithStaticCCP.yaml │ │ ├── BasicConfigWithStaticCCP.yaml │ │ ├── LegacyNetworkConfig.yaml │ │ ├── NetworkConfigWithPeers.json │ │ ├── NetworkConfigWithPeers.yaml │ │ ├── NoConnProfileOrPeersNetworkConfig.yaml │ │ ├── NoIdentitiesNetworkConfig.yaml │ │ ├── Org1ConnectionProfile.json │ │ ├── Org1ConnectionProfile.yaml │ │ ├── Org2StaticConnectionProfile.yaml │ │ ├── PeerGatewayNetworkConfigNotMutual.yaml │ │ ├── StaticOrg1ConnectionProfile.json │ │ ├── StaticOrg2ConnectionProfile.json │ │ ├── UnknownVersionConfig.yaml │ │ ├── User1.cert.pem │ │ ├── User1.key.pem │ │ ├── invalid.json │ │ ├── invalid.pem │ │ └── invalid.yaml │ │ └── utils │ │ ├── GenerateConfiguration.js │ │ └── GenerateWallet.js ├── caliper-publish │ ├── .dockerignore │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .gitignore │ ├── artifacts │ │ ├── docker-build.sh │ │ ├── docker-publish.sh │ │ ├── npm-publish.sh │ │ ├── start-verdaccio.sh │ │ ├── stop-verdaccio.sh │ │ └── verdaccio-config.yaml │ ├── caliper.Dockerfile │ ├── lib │ │ ├── dockerCommand.js │ │ ├── impl │ │ │ ├── docker.js │ │ │ └── npm.js │ │ ├── npmCommand.js │ │ ├── utils │ │ │ └── cmdutils.js │ │ ├── verdaccio.js │ │ ├── verdaccio │ │ │ ├── impl │ │ │ │ ├── start.js │ │ │ │ └── stop.js │ │ │ ├── startCommand.js │ │ │ └── stopCommand.js │ │ ├── version.js │ │ └── version │ │ │ ├── checkCommand.js │ │ │ ├── fixCommand.js │ │ │ └── impl │ │ │ ├── check.js │ │ │ └── fix.js │ ├── package.json │ └── publish.js ├── caliper-tests-integration │ ├── fabric_tests │ │ ├── .gitignore │ │ ├── caliper.yaml │ │ ├── docker-compose.yaml │ │ ├── init.js │ │ ├── initByChannel.js │ │ ├── mosquitto │ │ │ └── mosquitto.conf │ │ ├── phase1 │ │ │ ├── benchconfig.yaml │ │ │ └── networkconfig.yaml │ │ ├── phase2 │ │ │ ├── benchconfig.yaml │ │ │ └── networkconfig.yaml │ │ ├── phase3 │ │ │ ├── benchconfig.yaml │ │ │ └── networkconfig.yaml │ │ ├── phase4 │ │ │ ├── benchconfig.yaml │ │ │ └── networkconfig.yaml │ │ ├── prometheus │ │ │ └── prometheus-fabric.yml │ │ ├── query.js │ │ ├── queryByChannel.js │ │ ├── run.sh │ │ └── src │ │ │ └── marbles │ │ │ └── go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── marbles_chaincode.go │ │ │ └── metadata │ │ │ └── statedb │ │ │ └── couchdb │ │ │ └── indexes │ │ │ └── indexOwner.json │ ├── generator_tests │ │ ├── .gitignore │ │ ├── fabric │ │ │ ├── .gitignore │ │ │ ├── .yo-rc.json │ │ │ ├── caliper.yaml │ │ │ ├── myWorkspace │ │ │ │ └── networkconfig.yaml │ │ │ ├── run.sh │ │ │ └── src │ │ │ │ └── marbles │ │ │ │ └── go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── marbles_chaincode.go │ │ │ │ └── metadata │ │ │ │ └── statedb │ │ │ │ └── couchdb │ │ │ │ └── indexes │ │ │ │ └── indexOwner.json │ │ └── run.sh │ ├── package.json │ └── run-tests.sh └── generator-caliper │ ├── .editorconfig │ ├── .eslintignore │ ├── .eslintrc.yml │ ├── .npmignore │ ├── .yo-rc.json │ ├── README.md │ ├── generators │ ├── app │ │ └── index.js │ └── benchmark │ │ ├── index.js │ │ └── templates │ │ ├── config.yaml │ │ └── workload.js │ ├── lib │ └── generators │ │ └── dummy.md │ ├── package.json │ └── test │ └── benchmark │ ├── config.js │ └── workload.js ├── repolint.json └── scripts ├── changelog.sh ├── check-package-names.sh ├── force-clean.sh └── run-tests.sh /.build/benchmark-integration-test-direct.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -e 18 | set -o pipefail 19 | 20 | # Bootstrap the project again 21 | npm ci 22 | 23 | # Get the root directory of the caliper source 24 | ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" 25 | echo $ROOT_DIR 26 | 27 | # Call the CLI directly in the source tree 28 | export CALL_METHOD="node $ROOT_DIR/packages/caliper-cli/caliper.js" 29 | # Use explicit binding for 30 | export BIND_IN_PACKAGE_DIR=true 31 | 32 | # Call the Generator code directly from source 33 | export GENERATOR_METHOD="yo $ROOT_DIR/packages/generator-caliper/generators/benchmark/index.js" 34 | 35 | # Create a directory outside of the source code tree to install SUT binding node modules 36 | # We have to do this otherwise npm will attempt to hoist the npm modules to a directory 37 | # which subsequently doesn't get searched 38 | # This approach means we can drop having to declare dependencies on SUT bound modules in the 39 | # connector and makes it more like the way a user would use caliper. 40 | export SUT_DIR=$HOME/sut 41 | echo $SUT_DIR 42 | mkdir -p $SUT_DIR 43 | 44 | # Ensure node searches this directory by setting NODE_PATH 45 | export NODE_PATH=$SUT_DIR/node_modules 46 | 47 | echo "---- Running Integration test for adaptor ${BENCHMARK}" 48 | cd ./packages/caliper-tests-integration/ 49 | ./run-tests.sh 50 | 51 | rm -fr $SUT_DIR 52 | -------------------------------------------------------------------------------- /.build/check-prerequisites.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -e 18 | set -o pipefail 19 | 20 | CLEAR="$(tput sgr0)" 21 | RED="$(tput setaf 1)" 22 | GREEN="$(tput setaf 2)" 23 | 24 | check_npm_version() { 25 | required_version="7.24.2" 26 | installed_version=$(npm --version) 27 | versions="$required_version\n$installed_version" 28 | if echo -e $versions | sort -rV | head -n 1 | grep -q "$installed_version"; then 29 | echo "$GREEN npm version $installed_version is >= $required_version $CLEAR" 30 | return 0 31 | else 32 | echo "$RED npm version $installed_version < $required_version $CLEAR" 33 | echo "$RED Please update npm to the latest version: https://docs.npmjs.com/try-the-latest-stable-version-of-npm $CLEAR" 34 | return 1 35 | fi 36 | } 37 | 38 | check_node_version() { 39 | required_version="18.19.0" 40 | installed_version=$(node --version | cut -c2-) 41 | versions="$required_version\n$installed_version" 42 | if echo -e $versions | sort -rV | head -n 1 | grep -q "$installed_version"; then 43 | echo "$GREEN node version $installed_version is >= $required_version $CLEAR" 44 | return 0 45 | else 46 | echo "$RED node version $installed_version < $required_version $CLEAR" 47 | echo "$RED Please update node to the latest version: https://nodejs.org/en/download/ $CLEAR" 48 | return 1 49 | fi 50 | } 51 | 52 | check_node_version 53 | rc=$? 54 | check_npm_version 55 | rc=$?||$rc 56 | if [ $rc -ne 0 ]; then 57 | exit $rc 58 | fi 59 | -------------------------------------------------------------------------------- /.build/checks-and-unit-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -e 18 | set -o pipefail 19 | 20 | # check reference Caliper package names 21 | ./scripts/check-package-names.sh 22 | 23 | # Bootstrap the project again 24 | npm ci 25 | 26 | pushd ./packages/caliper-publish/ 27 | ./publish.js version check 28 | popd 29 | 30 | # Run linting, license check and unit tests 31 | npm run test --workspaces 32 | -------------------------------------------------------------------------------- /.build/publish-caliper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error 17 | set -e 18 | 19 | # distribute root README file before publishing 20 | cp ./README.md ./packages/caliper-cli/README.md 21 | cp ./README.md ./packages/caliper-core/README.md 22 | cp ./README.md ./packages/caliper-fabric/README.md 23 | 24 | cd ./packages/caliper-publish/ 25 | npm ci 26 | # temporary workaround to downgrade npm in order to publish 27 | npm install -g npm@8.19.4 28 | ./publish.js npm 29 | ./publish.js docker --publish 30 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Caliper Development", 3 | "image": "mcr.microsoft.com/vscode/devcontainers/python:3.11", 4 | "features": { 5 | "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, 6 | "ghcr.io/devcontainers/features/node:1": { 7 | "version": "lts" 8 | } 9 | }, 10 | "customizations": { 11 | "vscode": { 12 | "settings": { 13 | "terminal.integrated.shell.linux": "/bin/bash", 14 | "python.defaultInterpreterPath": "/usr/local/bin/python" 15 | }, 16 | "extensions": [ 17 | "esbenp.prettier-vscode", 18 | ] 19 | } 20 | }, 21 | "postCreateCommand": "cd docs && pip install -r pip-requirements.txt && mkdocs build", 22 | "remoteUser": "vscode", 23 | "forwardPorts": [8000] 24 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | root = true 16 | 17 | [*] 18 | indent_style = space 19 | indent_size = 4 20 | end_of_line = lf 21 | charset = utf-8 22 | trim_trailing_whitespace = true 23 | insert_final_newline = true 24 | 25 | [*.md] 26 | trim_trailing_whitespace = false 27 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | coverage 16 | node_modules 17 | 18 | # Benchmarks 19 | 20 | # Scripts 21 | /scripts 22 | 23 | # Plugins 24 | /src/gui 25 | /src/adapters/fabric/ChannelSignedTransaction.js 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Hyperledger Discord 4 | url: https://discord.com/channels/905194001349627914/941417677778473031 5 | about: Please ask general questions about the project in the Caliper channel (Discord id required). 6 | - name: Hyperledger Caliper mailing list 7 | url: https://lists.hyperledger.org/g/caliper 8 | about: Please ask general questions about the project here (LFID recommended). -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Request a new Caliper feature 3 | labels: [enhancement] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: Thank you for sharing your ideas about how to improve Caliper! 8 | - type: textarea 9 | id: limitation 10 | attributes: 11 | label: Please share the technical limitation of Caliper that you encountered. 12 | validations: 13 | required: true 14 | - type: textarea 15 | id: feature 16 | attributes: 17 | label: Please detail your feature idea that could alleviate the limitation. 18 | validations: 19 | required: true 20 | - type: textarea 21 | id: context 22 | attributes: 23 | label: Please share some details about your use case if possible, and how the new feature would make Caliper a better performance benchmarking framework. 24 | validations: 25 | required: false 26 | - type: textarea 27 | id: suggestions 28 | attributes: 29 | label: Please share any suggestions about the new feature's code/configuration API (using formatted YAML segments or pseudo-code). 30 | validations: 31 | required: false -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | # Number of days of inactivity before an issue becomes stale 16 | daysUntilStale: 30 17 | # Number of days of inactivity before a stale issue is closed 18 | daysUntilClose: 7 19 | # Issues with these labels will never be considered stale 20 | exemptLabels: 21 | - bug 22 | - documentation 23 | - enhancement 24 | # Label to use when marking an issue as stale 25 | staleLabel: wontfix 26 | # Comment to post when marking an issue as stale. Set to `false` to disable 27 | markComment: > 28 | This issue has been automatically marked as stale because it has not had 29 | recent activity. It will be closed if no further activity occurs. Thank you 30 | for your contributions. 31 | # Comment to post when closing a stale issue. Set to `false` to disable 32 | closeComment: false 33 | -------------------------------------------------------------------------------- /.github/workflows/coverage.yml: -------------------------------------------------------------------------------- 1 | name: Coverage Reports 2 | 3 | on: 4 | workflow_call: 5 | 6 | jobs: 7 | coverage: 8 | name: Coverage Reports 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | package: [caliper-core, caliper-fabric, generator-caliper] 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: Download coverage reports artifact 16 | uses: actions/download-artifact@v4.1.8 17 | with: 18 | name: coverage-reports 19 | path: packages 20 | - name: Upload coverage reports 21 | uses: codecov/codecov-action@v3.1.0 22 | with: 23 | files: packages/${{ matrix.package }}/coverage/clover.xml 24 | flags: ${{ matrix.package }} 25 | -------------------------------------------------------------------------------- /.github/workflows/dci.yml: -------------------------------------------------------------------------------- 1 | # Taken from https://github.com/petermetz/gh-action-dci-lint 2 | name: DCI 3 | 4 | on: 5 | workflow_call: 6 | 7 | jobs: 8 | DCI-lint: 9 | name: DCI-Lint 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Lint Git Repo 13 | id: lint-git-repo 14 | uses: petermetz/gh-action-dci-lint@v0.6.1 15 | with: 16 | lint-git-repo-request: '{"cloneUrl": "${{ github.server_url }}/${{ github.repository }}.git", "fetchArgs": ["--no-tags", "--prune", "--progress", "--no-recurse-submodules", "--depth=1", "origin" ,"+${{ github.sha }}:${{ github.ref }}"], "checkoutArgs": [ "${{ github.ref }}"], "targetPhrasePatterns": [], "configDefaultsUrl": "https://inclusivenaming.org/json/dci-lint-config-recommended-v1.json" }' 17 | - name: Get the output response 18 | run: echo "${{ steps.lint-git-repo.outputs.lint-git-repo-response }}" -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI (Publish) 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | 7 | jobs: 8 | unit-tests: 9 | uses: ./.github/workflows/unit-tests.yml 10 | coverage: 11 | uses: ./.github/workflows/coverage.yml 12 | needs: unit-tests 13 | publish-caliper: 14 | uses: ./.github/workflows/publish.yml 15 | needs: unit-tests 16 | secrets: inherit 17 | -------------------------------------------------------------------------------- /.github/workflows/pr.yml: -------------------------------------------------------------------------------- 1 | name: CI (PR) 2 | 3 | on: 4 | pull_request: 5 | branches: [ "main" ] 6 | 7 | jobs: 8 | dci-lint: 9 | uses: ./.github/workflows/dci.yml 10 | unit-tests: 11 | uses: ./.github/workflows/unit-tests.yml 12 | needs: dci-lint 13 | coverage: 14 | uses: ./.github/workflows/coverage.yml 15 | needs: unit-tests 16 | integration-tests: 17 | uses: ./.github/workflows/integration-tests.yml 18 | needs: unit-tests 19 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | workflow_call: 5 | 6 | jobs: 7 | publish-caliper: 8 | name: Publish Caliper 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - name: Use Node.js 18.x 13 | uses: actions/setup-node@v3 14 | with: 15 | node-version: 18.x 16 | - name: Publish Caliper 17 | run: .build/publish-caliper.sh 18 | env: 19 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 20 | DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }} 21 | DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} 22 | -------------------------------------------------------------------------------- /.github/workflows/unit-tests.yml: -------------------------------------------------------------------------------- 1 | name: Unit Tests 2 | 3 | on: 4 | workflow_call: 5 | 6 | env: 7 | NPM_VERSION: 8.15.0 8 | 9 | jobs: 10 | unit-tests: 11 | name: Unit Tests 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | node-version: [18.x, 20.x, 22.x] 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Use Node.js ${{ matrix.node-version }} 19 | uses: actions/setup-node@v3 20 | with: 21 | node-version: ${{ matrix.node-version }} 22 | - name: Install higher version of NPM 23 | run: npm install -g npm@${{ env.NPM_VERSION }} 24 | - name: Cache node modules 25 | id: cache-npm 26 | uses: actions/cache@v3 27 | with: 28 | path: | 29 | node_modules 30 | packages/*/node_modules 31 | key: ${{ matrix.node-version }}-npm-cache-${{ hashFiles('**/package.json') }} 32 | restore-keys: | 33 | ${{ matrix.node-version }}-npm-cache- 34 | - name: Check correct usage of Caliper package names 35 | run: ./scripts/check-package-names.sh 36 | - name: Install project dependencies 37 | if: steps.cache-npm.outputs.cache-hit != 'true' 38 | run: npm ci 39 | - name: Check the version consistency of subpackages 40 | run: ./packages/caliper-publish/publish.js version check 41 | - name: Run unit tests 42 | run: npm test --workspaces 43 | - name: Upload coverage reports artifact 44 | if: matrix.node-version == '18.x' 45 | uses: actions/upload-artifact@v4.4.0 46 | with: 47 | name: coverage-reports 48 | path: packages/*/coverage/clover.xml 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | 3 | # Ignore any generated html files, but include the report html template 4 | *.html 5 | 6 | !/packages/caliper-core/lib/manager/report/template/report.html 7 | 8 | # Ignore DS_Store files from Mac 9 | **.DS_Store 10 | 11 | architecture.pptx 12 | output.log 13 | lerna-debug.log 14 | 15 | .idea/ 16 | **/node_modules/ 17 | **/log/ 18 | **/*.log 19 | 20 | # Ignore code coverage logs 21 | **/.nyc_output/ 22 | **/coverage/ 23 | 24 | # Ignore IDE files 25 | .vscode/ 26 | 27 | # Website files 28 | .sass-cache/ 29 | Gemfile.lock 30 | _site/ 31 | 32 | # verdaccio files 33 | **/storage 34 | 35 | # pm2 files 36 | **/.pm2/ 37 | 38 | # lerna log 39 | lerna-debug.log 40 | 41 | # contract address file 42 | **/*.address 43 | 44 | # Ignore data 45 | data/ 46 | 47 | # Ignore temp test files 48 | temp/ 49 | 50 | # Build files of doc 51 | docs/build/ 52 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @hyperledger/caliper-committers 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | Code of Conduct Guidelines 2 | ========================== 3 | 4 | Please review the Hyperledger [Code of 5 | Conduct](https://wiki.hyperledger.org/community/hyperledger-project-code-of-conduct) 6 | before participating. It is important that we keep things civil. 7 | 8 | Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License. 9 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Hyperledger Caliper 2 | 3 | This guideline intends to make contribtuions to Caliper easier by: 4 | 5 | * presenting a simple development workflow for contributors to follow; 6 | * and providing a high-level description of the repository components. 7 | 8 | If you have further suggestions about improving the guideline, then you can follow the presented workflow to make your contribution. 9 | 10 | Jump to [Contributing documentation](https://hyperledger-caliper.github.io/caliper/0.6.0/getting-started/contributing/) to get started on your journey. 11 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Context 4 | 5 | 6 | ## Expected Behavior 7 | 8 | 9 | ## Actual Behavior 10 | 11 | 12 | ## Possible Fix 13 | 14 | 15 | ## Steps to Reproduce 16 | 17 | 18 | 1. 19 | 2. 20 | 3. 21 | 4. 22 | 23 | ## Existing issues 24 | 25 | - [ ] [Stack Overflow issues](http://stackoverflow.com/tags/hyperledger-caliper) 26 | - [ ] [GitHub Issues](https://github.com/hyperledger-caliper/caliper/issues) 27 | - [ ] [Discord Chat history](https://discord.com/channels/905194001349627914/941417677778473031) 28 | 29 | 30 | 31 | ## Context 32 | 33 | 34 | ## Your Environment 35 | 36 | * Version used: 37 | * Environment name and version (e.g. Chrome 39, node.js 5.4): 38 | * Operating System and version (desktop or mobile): 39 | * Link to your project: 40 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | Maintainers 2 | =========== 3 | The following are lists of the Caliper maintainers, Chat IDs are valid for [Discord](https://discord.com/channels/905194001349627914/941417677778473031) 4 | 5 | **Active maintainers** 6 | 7 | | Name | GitHub | Chat | 8 | |---------------------------|------------------|------------------| 9 | | Attila Klenik | aklenik | Attila Klenik | 10 | | Dave Kelsey | davidkel | NorfolkAndChance | 11 | 12 | 13 | **Retired maintainers** 14 | 15 | | Name | GitHub | Chat | 16 | |---------------------------|------------------|----------------| 17 | | FeihuJiang | feihujiang | | 18 | | HaojunZhou | haojun | | 19 | | Nick Lincoln | nklincoln | | 20 | 21 | Contributors 22 | =========== 23 | **Active contributors** 24 | 25 | | Name | GitHub | Chat | 26 | |---------------------------|------------------|----------------| 27 | | Benjamin Burns | benjamincburns | | 28 | | Chenxi Li | vita-dounai | | 29 | | Jason you | Jasonyou1995 | | 30 | 31 | 32 | Packages 33 | =========== 34 | 35 | The following is a list of packages and codeowners with familiarity in the area 36 | 37 | | Component | Contact(s) | 38 | |---------------------------|------------------| 39 | | Caliper cli | A Klenik, D Kelsey | 40 | | Caliper core | A Klenik, D Kelsey | 41 | | Caliper publish | A Klenik, D Kelsey | 42 | | Caliper fabric | A Klenik, D Kelsey | 43 | | Caliper generator | D Kelsey | 44 | 45 | Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License. 46 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Checklist 4 | - [ ] A link to the issue/user story that the pull request relates to 5 | - [ ] How to recreate the problem without the fix 6 | - [ ] Design of the fix 7 | - [ ] How to prove that the fix works 8 | - [ ] Automated tests that prove the fix keeps on working 9 | - [ ] Documentation - any JSDoc, website, or Stackoverflow answers? 10 | 11 | 12 | ## Issue/User story 13 | 14 | 15 | ## Steps to Reproduce 16 | 17 | 18 | 1. 19 | 2. 20 | 3. 21 | 4. 22 | 23 | 24 | ## Existing issues 25 | 26 | - [ ] [Stack Overflow issues](http://stackoverflow.com/tags/hyperledger-caliper) 27 | - [ ] [GitHub Issues](https://github.com/hyperledger-caliper/caliper/issues) 28 | - [ ] [Discord history](https://discord.com/channels/905194001349627914/941417677778473031) 29 | 30 | 31 | 32 | ## Design of the fix 33 | 34 | 35 | ## Validation of the fix 36 | 37 | 38 | ## Automated Tests 39 | 40 | 41 | ## What documentation has been provided for this pull request 42 | 43 | -------------------------------------------------------------------------------- /RELEASE_PROCESS.md: -------------------------------------------------------------------------------- 1 | # Release Process 2 | 3 | ## Code 4 | 1. Generate the change log using the script changelog.sh. The script must be run from the repo root directory (ie ./scripts/changelog.sh ) 5 | 2. Update all package.json files to define the new version, eg 0.7.0 and regen package-lock.json (PR 1) 6 | 3. create a release on Github with the changelog details and mark it pre-release 7 | 4. Update all the package.json files to define a new unstable version, eg 0.7.1-unstable and regen package-lock.json (PR 2) 8 | 9 | ## Caliper benchmarks 10 | 1. Create a release in caliper-benchmarks corresponding to the new release, eg 0.7.0 11 | 12 | ## Docs 13 | 14 | There are 2 aspects here 15 | 1. update an existing version 16 | 2. publishing a new version and make it the default 17 | 18 | One final point to note is that although the `mike` tool manages all the documentation we still have to maintain the /assets/img directory. This is required for Caliper 0.6.0 to find a hyperledger logo in it's report.html template. 19 | The old documentation is also currently kept in the `.OldDocs` directory 20 | 21 | ### Updating an existing version 22 | 23 | 1. create branch newdocs based off of gh-pages 24 | 2. switch to branch that contains the doc changes and change to docs directory 25 | 3. run `mike deploy -b newdocs ` (note the commit won't be signed) - specify appropriate version for , eg `0.6.0` 26 | 4. switch to newdocs and amend the last commit to sign it 27 | 5. submit pr of newdocs to gh-pages 28 | 29 | ## Publishing a new version 30 | 31 | 1. create branch newdocs 32 | 2. switch to branch that contains the doc changes and change to docs directory 33 | 3. run `mike deploy -b newdocs ` (note the commit won't be signed) - specify appropriate version for , eg `0.7.0` 34 | 4. switch to newdocs and amend the last commit to sign it 35 | 5. switch back to branch that contains the doc changes 36 | 6. run `mike set-default -b newdocs` (note the commit won't be signed) - specify same version used for the deploy 37 | 7. switch to newdocs and amend the last commit to sign it 38 | 8. submit pr of newdocs to gh-pages 39 | 40 | (see https://stackoverflow.com/questions/13043357/git-sign-off-previous-commits for a way to sign multiple commits in the future) 41 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Hyperledger Security Policy 2 | 3 | ## Reporting a Security Bug 4 | 5 | If you think you have discovered a security issue in any of the Hyperledger projects, we'd love to hear from you. We will take all security bugs seriously and if confirmed upon investigation we will patch it within a reasonable amount of time and release a public security bulletin discussing the impact and credit the discoverer. 6 | 7 | There are two ways to report a security bug. The easiest is to email a description of the flaw and any related information (e.g. reproduction steps, version) to [security at hyperledger dot org](mailto:security@hyperledger.org). 8 | 9 | The other way is to file a confidential security bug in our [JIRA bug tracking system](https://jira.hyperledger.org). Be sure to set the “Security Level” to “Security issue”. 10 | 11 | The process by which the Hyperledger Security Team handles security bugs is documented further in our [Defect Response page](https://wiki.hyperledger.org/display/SEC/Defect+Response) on our [wiki](https://wiki.hyperledger.org). 12 | 13 | -------------------------------------------------------------------------------- /dev-docs/figures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/dev-docs/figures/.gitkeep -------------------------------------------------------------------------------- /dev-docs/generate-figure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | if [ $# -eq 0 ] ; then 17 | echo "ERROR: PUML file path argument is missing! Usage: generate-figure.sh " 18 | exit 1 19 | fi 20 | 21 | if [ ! -f "$1" ]; then 22 | echo "ERROR: Input file not found: $1" 23 | exit 1 24 | fi 25 | 26 | if ! which docker; then 27 | echo "ERROR: Docker must be installed to generate figures!" 28 | exit 1 29 | fi 30 | 31 | DIR_NAME=`dirname "$1"` 32 | FILE_NAME_NO_EXT=`basename "$1" .puml` 33 | 34 | cat "$1" | docker run --rm -i think/plantuml -tpng > ${DIR_NAME}/${FILE_NAME_NO_EXT}.png -------------------------------------------------------------------------------- /dev-docs/proposals/0000-proposal-template.md: -------------------------------------------------------------------------------- 1 | # Proposal #<PR number>: <Proposal Title > 2 | 3 | ## Overview 4 | 5 | ## Current shortcomings 6 | 7 | ## Benefits of changes 8 | 9 | ## Affected modules 10 | 11 | ## Details of the proposal 12 | 13 | ## Introduced breaking changes 14 | 15 | ## Proposal work items -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | build/ -------------------------------------------------------------------------------- /docs/overrides/css/custom.css: -------------------------------------------------------------------------------- 1 | /* Move the main navigation to the left side */ 2 | .md-sidebar { 3 | float: left; 4 | width: 20%; 5 | max-width: 250px; 6 | } 7 | 8 | /* Adjust the main content to be on the right side */ 9 | .md-main { 10 | margin-left: 21%; /* slightly more than .md-sidebar width to add some padding */ 11 | } 12 | 13 | /* Ensure that the sidebar stays fixed while scrolling */ 14 | .md-sidebar.md-sidebar--primary { 15 | position: fixed; 16 | top: 0; 17 | bottom: 0; 18 | left: 0; 19 | overflow-y: auto; 20 | } 21 | 22 | /* Adjust the width of the main content container */ 23 | .md-content { 24 | max-width: 100%; 25 | } 26 | -------------------------------------------------------------------------------- /docs/pip-requirements.txt: -------------------------------------------------------------------------------- 1 | mkdocs-material==9.5.28 2 | mike==2.1.2 3 | mkdocs-redirects==1.2.1 4 | mkdocs-minify-plugin==0.8.0 -------------------------------------------------------------------------------- /docs/source/_static/arch_high_level.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/arch_high_level.png -------------------------------------------------------------------------------- /docs/source/_static/arch_ipc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/arch_ipc.png -------------------------------------------------------------------------------- /docs/source/_static/arch_local_mqtt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/arch_local_mqtt.png -------------------------------------------------------------------------------- /docs/source/_static/arch_manager_process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/arch_manager_process.png -------------------------------------------------------------------------------- /docs/source/_static/arch_messages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/arch_messages.png -------------------------------------------------------------------------------- /docs/source/_static/arch_processes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/arch_processes.png -------------------------------------------------------------------------------- /docs/source/_static/arch_remote_mqtt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/arch_remote_mqtt.png -------------------------------------------------------------------------------- /docs/source/_static/arch_worker_process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/arch_worker_process.png -------------------------------------------------------------------------------- /docs/source/_static/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/architecture.png -------------------------------------------------------------------------------- /docs/source/_static/benchmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/benchmark.png -------------------------------------------------------------------------------- /docs/source/_static/report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/_static/report.png -------------------------------------------------------------------------------- /docs/source/assets/img/hyperledger_caliper_logo_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/assets/img/hyperledger_caliper_logo_color.png -------------------------------------------------------------------------------- /docs/source/assets/project-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/assets/project-icon.png -------------------------------------------------------------------------------- /docs/source/assets/project-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledger-caliper/caliper/a4d7fe43a382259ee15725168082b3a78465f0da/docs/source/assets/project-logo.png -------------------------------------------------------------------------------- /docs/source/concepts/caliper-messengers.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | Caliper uses an orchestrator to control workers that interact with the SUT in order to perform a benchmark. Messages are passed between the orchestrator and all workers in order to keep the workers synchronized, and to progress the specified benchmark tests. A user may specify the messaging protocol that is user by Caliper in order to facilitate communications between the orchestrator and worker. 4 | 5 | ## Messengers 6 | 7 | The messaging protocol to be used for communications between the orchestrator and worker during a benchmark is declared in the `caliper runtime configuration file`. Unspecified values will default to those specified in the [default configuration file](https://github.com/hyperledger-caliper/caliper/blob/main/packages/caliper-core/lib/common/config/default.yaml). 8 | 9 | Permitted messengers are: 10 | 11 | - Process: The `process` messenger is the default messenger and is based on native NodeJS `process` based communications. This messenger type is only valid for instances when local workers are being used to perform a benchmark. 12 | - MQTT: The `mqtt` messenger uses [MQTT](https://mqtt.org/) to facilitate communication between the orchestrator and workers. This messenger type is valid for both local and distributed workers, and assumes the existence of an MQTT broker service that may be used, such as [mosquitto](https://mosquitto.org/). 13 | 14 | !!! note 15 | *Mosquitto v2 requires explicit authorization and authentication configurations, which is a breaking change compared to v1. To migrate to v2, follow the [official migration guide of Mosquitto](https://mosquitto.org/documentation/migrating-to-2-0/).* 16 | 17 | The following yaml extract specifies the use of an MQTT communication method, using an existing MQTT broker that may be connected to via the specified address: 18 | 19 | ```sh 20 | worker: 21 | communication: 22 | method: mqtt 23 | address: mqtt://localhost:1883 24 | ``` 25 | 26 | If not specifying a `caliper.yaml` configuration file, the above may be specified as command line arguments to the CLI process as: 27 | 28 | ```sh 29 | --caliper-worker-communication-method mqtt --caliper-worker-communication-address mqtt://localhost:1883 30 | ``` 31 | 32 | ## License 33 | 34 | The Caliper codebase is released under the [Apache 2.0 license](../getting-started/license.md). Any documentation developed by the Caliper Project is licensed under the Creative Commons Attribution 4.0 International License. You may obtain a copy of the license, titled CC-BY-4.0, at [http://creativecommons.org/licenses/by/4.0/](http://creativecommons.org/licenses/by/4.0/). -------------------------------------------------------------------------------- /docs/source/index.md: -------------------------------------------------------------------------------- 1 | # Caliper 2 | 3 | Caliper is a blockchain performance benchmark framework, which allows users to test different blockchain solutions with predefined use cases, and get a set of performance test results. 4 | 5 | ## Supported Blockchain Solutions 6 | 7 | Currently supported blockchain solutions: 8 | 9 | - [Hyperledger Fabric](https://github.com/hyperledger/fabric) 10 | 11 | ## Supported Performance Metrics 12 | 13 | - Transaction/read throughput 14 | - Transaction/read latency (minimum, maximum, average, percentile) 15 | - Resource consumption (CPU, Memory, Network IO, …) 16 | 17 | See [PSWG](https://www.hyperledger.org/learn/publications/blockchain-performance-metrics) for the exact definitions and corresponding measurement methods. 18 | 19 | ## Architecture 20 | 21 | It helps to have a basic understanding of how Caliper works before diving into the examples. Have a look at the [Architecture](getting-started/architecture.md) page! 22 | 23 | 24 | ## Installing Caliper 25 | 26 | Head to the [Install & Usage page](getting-started/installing-caliper.md) if you want to try Caliper right now. It’s as simple as downloading an NPM package or starting a Docker container! 27 | 28 | ## Sample Networks 29 | Sample benchmarks that may be used by Caliper are hosted on a companion [GitHub repository](https://github.com/hyperledger-caliper/caliper-benchmarks). 30 | 31 | !!! note "Important" 32 | 33 | *make sure that the version/tag of the benchmark repository matches the version of Caliper you are using! For example, if you are using Caliper v0.6.0, then `checkout` the `v0.6.0` tag after cloning the benchmark repository. The `main` branch of the benchmark repository corresponds to the latest `unstable` Caliper version.* 34 | 35 | ## How to Contribute 36 | Every contribution is welcome! See the [Contributing](getting-started/contributing.md) page for details. 37 | 38 | 39 | ## License 40 | The Caliper codebase is released under the [Apache 2.0 license](getting-started/license.md). Any documentation developed by the Caliper Project is licensed under the Creative Commons Attribution 4.0 International License. You may obtain a copy of the license, titled CC-BY-4.0, at [http://creativecommons.org/licenses/by/4.0/](http://creativecommons.org/licenses/by/4.0/). -------------------------------------------------------------------------------- /docs/source/tutorial/index.md: -------------------------------------------------------------------------------- 1 | These tutorials are specifically aimed at using Caliper to performance test different blockchain networks. 2 | 3 | Please select a tutorial from the navigation section on the left which takes you through performance testing a smart contract using Caliper. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caliper", 3 | "description": "Performance benchmarking for Hyperledger blockchain technologies.", 4 | "version": "0.6.1-unstable", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/hyperledger-caliper/caliper" 8 | }, 9 | "scripts": { 10 | "pretest": "npm run licchk --workspaces", 11 | "licchk": "license-check-and-add", 12 | "test": "npm run test --workspaces", 13 | "version-fix": "node ./packages/caliper-publish/publish.js version fix", 14 | "force-clean": "./scripts/force-clean.sh" 15 | }, 16 | "engines": { 17 | "node": ">=18.19.0", 18 | "npm": ">=7.24.2" 19 | }, 20 | "dependencies": {}, 21 | "devDependencies": { 22 | "license-check-and-add": "2.3.6", 23 | "repolinter": "0.8.2" 24 | }, 25 | "license-check-and-add-config": { 26 | "folder": ".", 27 | "license": "LICENSE.txt", 28 | "exact_paths_method": "EXCLUDE", 29 | "exact_paths": [ 30 | "CODEOWNERS", 31 | "LICENSE", 32 | ".idea", 33 | "node_modules", 34 | ".nyc_output", 35 | "coverage", 36 | "scripts", 37 | ".git", 38 | ".gitignore", 39 | "packages", 40 | "log" 41 | ], 42 | "file_type_method": "EXCLUDE", 43 | "file_types": [ 44 | ".yml", 45 | ".md", 46 | ".log", 47 | ".html" 48 | ], 49 | "insert_license": false, 50 | "license_formats": { 51 | "js|cto|qry|go": { 52 | "prepend": "/*", 53 | "append": "*/", 54 | "eachLine": { 55 | "prepend": "* " 56 | } 57 | }, 58 | "cfg|editorconfig|yaml|py": { 59 | "prepend": "#", 60 | "append": "#", 61 | "eachLine": { 62 | "prepend": "# " 63 | } 64 | }, 65 | "puml": { 66 | "prepend": "'", 67 | "append": "'", 68 | "eachLine": { 69 | "prepend": "' " 70 | } 71 | } 72 | } 73 | }, 74 | "license": "Apache-2.0", 75 | "workspaces": [ 76 | "packages/caliper-core", 77 | "packages/caliper-fabric", 78 | "packages/caliper-cli", 79 | "packages/caliper-publish", 80 | "packages/caliper-tests-integration", 81 | "packages/generator-caliper" 82 | ] 83 | } 84 | -------------------------------------------------------------------------------- /packages/caliper-cli/.eslintignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | coverage 16 | node_modules -------------------------------------------------------------------------------- /packages/caliper-cli/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaFeatures: 8 | experimentalObjectRestSpread: true 9 | ecmaVersion: 8 10 | sourceType: 11 | - script 12 | rules: 13 | indent: 14 | - error 15 | - 4 16 | linebreak-style: 17 | - error 18 | - unix 19 | quotes: 20 | - error 21 | - single 22 | semi: 23 | - error 24 | - always 25 | no-unused-vars: 26 | - error 27 | - args: none 28 | no-console: error 29 | curly: error 30 | eqeqeq: error 31 | no-throw-literal: error 32 | strict: error 33 | no-var: error 34 | dot-notation: error 35 | no-tabs: error 36 | no-trailing-spaces: error 37 | no-use-before-define: error 38 | no-useless-call: error 39 | no-with: error 40 | operator-linebreak: error 41 | require-jsdoc: 42 | - error 43 | - require: 44 | ClassDeclaration: true 45 | MethodDefinition: true 46 | FunctionDeclaration: true 47 | valid-jsdoc: 48 | - error 49 | - requireReturn: false 50 | yoda: error 51 | -------------------------------------------------------------------------------- /packages/caliper-cli/.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | 3 | # Ignore any generated html files 4 | *.html 5 | 6 | # Ignore DS_Store files from Mac 7 | **.DS_Store 8 | 9 | architecture.pptx 10 | output.log 11 | lerna-debug.log 12 | 13 | # We prefer to not use lock files 14 | **/package-lock.json 15 | 16 | .idea/ 17 | **/node_modules/ 18 | **/log/ 19 | 20 | # Ignore code coverage logs 21 | **/.nyc_output/ 22 | **/coverage/ 23 | 24 | # Ignore IDE files 25 | .vscode/ 26 | 27 | # Website files 28 | .sass-cache/ 29 | Gemfile.lock 30 | _site/ 31 | 32 | # verdaccio files 33 | **/storage 34 | 35 | # pm2 files 36 | **/.pm2/ 37 | -------------------------------------------------------------------------------- /packages/caliper-cli/.npmignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | # hidden config files 16 | .editorconfig 17 | .eslintignore 18 | .eslintrc.yml 19 | 20 | # test directory 21 | test 22 | -------------------------------------------------------------------------------- /packages/caliper-cli/caliper.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /* 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | 'use strict'; 17 | 18 | process.env.SUPPRESS_NO_CONFIG_WARNING = true; 19 | const { CaliperUtils } = require('@hyperledger/caliper-core'); 20 | const Logger = CaliperUtils.getLogger('cli'); 21 | const yargs = require('yargs'); 22 | const version = 'v' + require('./package.json').version; 23 | 24 | let results = yargs 25 | .commandDir('./lib') 26 | .completion() 27 | .recommendCommands() 28 | .help() 29 | .demandCommand(1, 1, 'Please specify a command to continue') 30 | .example('caliper bind\ncaliper unbind\ncaliper launch manager\ncaliper launch worker') 31 | .wrap(null) 32 | .epilogue('For more information on Hyperledger Caliper: https://hyperledger-caliper.github.io/caliper/') 33 | .alias('version', 'v') 34 | .alias('help', 'h') 35 | .version(version) 36 | .describe('version', 'Show version information') 37 | .describe('help', 'Show usage information') 38 | .strict(false) 39 | .argv; 40 | 41 | 42 | 43 | if (!results.thePromise) { 44 | Logger.error(`Command not recognised: '${results._[0]}'`); 45 | process.exit(1); 46 | } 47 | 48 | results.thePromise.then( () => { 49 | // DO NOT EXIT THE PROCESS HERE 50 | // The event loops of the workers are still running at this point 51 | // The default exit code is 0 anyway 52 | }).catch((error) => { 53 | Logger.error(`Error during command execution: ${error}`); 54 | process.exit(1); 55 | }); 56 | -------------------------------------------------------------------------------- /packages/caliper-cli/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | module.exports.version = require('./package.json').version; 18 | -------------------------------------------------------------------------------- /packages/caliper-cli/lib/bindCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const { CaliperUtils } = require('@hyperledger/caliper-core'); 18 | 19 | const BindCommon = require('./lib/bindCommon'); 20 | 21 | // enforces singletons 22 | const checkFn = (argv) => { 23 | const uniqueArgs = ['caliper-bind-sut', 'caliper-bind-args', 'caliper-bind-cwd', 'caliper-bind-file']; 24 | return CaliperUtils.checkSingleton(argv, uniqueArgs); 25 | }; 26 | 27 | module.exports._checkFn = checkFn; 28 | module.exports.command = 'bind [options]'; 29 | module.exports.describe = 'Bind Caliper to a specific SUT and its SDK version'; 30 | module.exports.builder = function (yargs){ 31 | 32 | yargs.options({ 33 | 'caliper-bind-sut' : {describe: 'The name and version of the platform and its SDK to bind to', type: 'string' }, 34 | 'caliper-bind-cwd' : {describe: 'The working directory for performing the SDK install', type: 'string' }, 35 | 'caliper-bind-args' : {describe: 'Additional arguments to pass to "npm install". Use the "=" notation when setting this parameter', type: 'string' }, 36 | 'caliper-bind-file' : {describe: 'Yaml file to override default (supported) package versions when binding an SDK', type: 'string' } 37 | }); 38 | yargs.usage('Usage:\n caliper bind --caliper-bind-sut fabric:2.2 --caliper-bind-cwd ./ --caliper-bind-args="-g"'); 39 | // enforce the option after these options 40 | yargs.requiresArg(['caliper-bind-sut', 'caliper-bind-args', 'caliper-bind-cwd']); 41 | 42 | // enforce singletons 43 | yargs.check(checkFn); 44 | 45 | return yargs; 46 | }; 47 | 48 | module.exports.handler = (argv) => { 49 | return argv.thePromise = BindCommon.handler(argv, true); 50 | }; 51 | -------------------------------------------------------------------------------- /packages/caliper-cli/lib/launch/launchManagerCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const LaunchManager = require('./lib/launchManager'); 18 | const { CaliperUtils } = require('@hyperledger/caliper-core'); 19 | 20 | // enforces singletons 21 | const checkFn = (argv) => { 22 | const uniqueArgs = ['caliper-bind-sut', 'caliper-bind-args', 'caliper-bind-cwd', 'caliper-bind-file']; 23 | return CaliperUtils.checkSingleton(argv, uniqueArgs); 24 | }; 25 | 26 | module.exports._checkFn = checkFn; 27 | module.exports.command = 'manager [options]'; 28 | module.exports.describe = 'Launch a Caliper manager process to coordinate the benchmark run'; 29 | module.exports.builder = yargs => { 30 | 31 | yargs.options({ 32 | 'caliper-bind-sut' : {describe: 'The name and version of the platform to bind to', type: 'string' }, 33 | 'caliper-bind-cwd' : {describe: 'The working directory for performing the SDK install', type: 'string' }, 34 | 'caliper-bind-args' : {describe: 'Additional arguments to pass to "npm install". Use the "=" notation when setting this parameter', type: 'string' }, 35 | 'caliper-bind-file' : {describe: 'Yaml file to override default (supported) package versions when binding an SDK', type: 'string' } 36 | }); 37 | yargs.usage('Usage:\n caliper launch manager --caliper-bind-sut fabric:2.2 [other options]'); 38 | 39 | // enforce singletons 40 | yargs.check(checkFn); 41 | 42 | return yargs; 43 | }; 44 | 45 | module.exports.handler = (argv) => { 46 | return argv.thePromise = LaunchManager.handler(argv).then(() => process.exit(0)); 47 | }; 48 | -------------------------------------------------------------------------------- /packages/caliper-cli/lib/launch/launchWorkerCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const LaunchWorker = require('./lib/launchWorker'); 18 | const { CaliperUtils } = require('@hyperledger/caliper-core'); 19 | 20 | // enforces singletons 21 | const checkFn = (argv) => { 22 | const uniqueArgs = ['caliper-bind-sut', 'caliper-bind-args', 'caliper-bind-cwd', 'caliper-bind-file']; 23 | return CaliperUtils.checkSingleton(argv, uniqueArgs); 24 | }; 25 | 26 | module.exports._checkFn = checkFn; 27 | module.exports.command = 'worker [options]'; 28 | module.exports.describe = 'Launch a Caliper worker process to generate the benchmark workload'; 29 | module.exports.builder = yargs => { 30 | 31 | yargs.options({ 32 | 'caliper-bind-sut' : {describe: 'The name and version of the platform to bind to', type: 'string' }, 33 | 'caliper-bind-cwd' : {describe: 'The working directory for performing the SDK install', type: 'string' }, 34 | 'caliper-bind-args' : {describe: 'Additional arguments to pass to "npm install". Use the "=" notation when setting this parameter', type: 'string' }, 35 | 'caliper-bind-file' : {describe: 'Yaml file to override default (supported) package versions when binding an SDK', type: 'string' } 36 | }); 37 | yargs.usage('Usage:\n caliper launch worker --caliper-bind-sut fabric:2.2 [other options]'); 38 | 39 | // enforce singletons 40 | yargs.check(checkFn); 41 | 42 | return yargs; 43 | }; 44 | 45 | module.exports.handler = (argv) => { 46 | return argv.thePromise = LaunchWorker.handler(argv); 47 | }; 48 | -------------------------------------------------------------------------------- /packages/caliper-cli/lib/launchCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | module.exports.command = 'launch '; 18 | module.exports.describe = 'Launch a Caliper process either in a manager or worker role.'; 19 | module.exports.builder = yargs => { 20 | return yargs 21 | .demandCommand(1, 'Command not found! Please check the list of commands given above, or try running "caliper launch --help".') 22 | .commandDir('./launch'); 23 | }; 24 | -------------------------------------------------------------------------------- /packages/caliper-cli/lib/unbindCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const { CaliperUtils } = require('@hyperledger/caliper-core'); 18 | 19 | const BindCommon = require('./lib/bindCommon'); 20 | 21 | // enforces singletons 22 | const checkFn = (argv) => { 23 | const uniqueArgs = ['caliper-bind-sut', 'caliper-bind-args', 'caliper-bind-cwd', 'caliper-bind-file']; 24 | return CaliperUtils.checkSingleton(argv, uniqueArgs); 25 | }; 26 | 27 | module.exports._checkFn = checkFn; 28 | module.exports.command = 'unbind [options]'; 29 | module.exports.describe = 'Unbind Caliper from a previously bound SUT and its SDK version'; 30 | module.exports.builder = function (yargs){ 31 | 32 | yargs.options({ 33 | 'caliper-bind-sut' : {describe: 'The name and version of the platform and its SDK to unbind', type: 'string' }, 34 | 'caliper-bind-cwd' : {describe: 'The working directory for performing the SDK removal', type: 'string' }, 35 | 'caliper-bind-args' : {describe: 'Additional arguments to pass to "npm remove". Use the "=" notation when setting this parameter', type: 'string' }, 36 | 'caliper-bind-file' : {describe: 'Yaml file to override default (supported) package versions when unbinding an SDK', type: 'string' } 37 | }); 38 | yargs.usage('Usage:\n caliper unbind --caliper-bind-sut fabric:2.2 --caliper-bind-cwd ./ --caliper-bind-args="-g"'); 39 | // enforce the option after these options 40 | yargs.requiresArg(['caliper-bind-sut', 'caliper-bind-args', 'caliper-bind-cwd']); 41 | 42 | // enforce singletons 43 | yargs.check(checkFn); 44 | 45 | return yargs; 46 | }; 47 | 48 | module.exports.handler = (argv) => { 49 | return argv.thePromise = BindCommon.handler(argv, false); 50 | }; 51 | -------------------------------------------------------------------------------- /packages/caliper-core/.eslintignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | coverage 16 | node_modules 17 | test 18 | -------------------------------------------------------------------------------- /packages/caliper-core/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaFeatures: 8 | experimentalObjectRestSpread: true 9 | ecmaVersion: 8 10 | sourceType: 11 | - script 12 | rules: 13 | indent: 14 | - error 15 | - 4 16 | linebreak-style: 17 | - error 18 | - unix 19 | quotes: 20 | - error 21 | - single 22 | semi: 23 | - error 24 | - always 25 | no-unused-vars: 26 | - error 27 | - args: none 28 | no-console: error 29 | curly: error 30 | eqeqeq: error 31 | no-throw-literal: error 32 | strict: error 33 | no-var: error 34 | dot-notation: error 35 | no-tabs: error 36 | no-trailing-spaces: error 37 | no-use-before-define: error 38 | no-useless-call: error 39 | no-with: error 40 | operator-linebreak: error 41 | require-jsdoc: 42 | - error 43 | - require: 44 | ClassDeclaration: true 45 | MethodDefinition: true 46 | FunctionDeclaration: true 47 | valid-jsdoc: 48 | - error 49 | - requireReturn: false 50 | yoda: error 51 | -------------------------------------------------------------------------------- /packages/caliper-core/.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | 3 | # Ignore any generated html files, but include the report html template 4 | *.html 5 | !/lib/manager/report/template/report.html 6 | 7 | # Ignore DS_Store files from Mac 8 | **.DS_Store 9 | 10 | architecture.pptx 11 | output.log 12 | lerna-debug.log 13 | 14 | # We prefer to not use lock files 15 | **/package-lock.json 16 | 17 | .idea/ 18 | **/node_modules/ 19 | **/log/ 20 | *.log 21 | 22 | # Ignore code coverage logs 23 | **/.nyc_output/ 24 | **/coverage/ 25 | 26 | # Ignore IDE files 27 | .vscode/ 28 | 29 | # Website files 30 | .sass-cache/ 31 | Gemfile.lock 32 | _site/ 33 | 34 | # verdaccio files 35 | **/storage 36 | 37 | # pm2 files 38 | **/.pm2/ 39 | -------------------------------------------------------------------------------- /packages/caliper-core/.npmignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | # hidden config files 16 | .editorconfig 17 | .eslintignore 18 | .eslintrc.yml 19 | 20 | *.html 21 | !/lib/manager/report/template/report.html 22 | 23 | # test directory 24 | test 25 | -------------------------------------------------------------------------------- /packages/caliper-core/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | module.exports.ConnectorInterface = require('./lib/common/core/connector-interface'); 18 | module.exports.ConnectorBase = require('./lib/common/core/connector-base'); 19 | module.exports.CaliperWorker = require('./lib/worker/caliper-worker'); 20 | module.exports.Constants = require('./lib/common/utils/constants'); 21 | module.exports.TxStatus = require('./lib/common/core/transaction-status'); 22 | module.exports.CaliperUtils = require('./lib/common/utils/caliper-utils'); 23 | module.exports.Version = require('./lib/common/utils/version'); 24 | module.exports.ConfigUtil = require('./lib/common/config/config-util'); 25 | module.exports.WorkerMessageHandler = require('./lib/worker/worker-message-handler'); 26 | module.exports.MessengerInterface = require('./lib/common/messengers/messenger-interface'); 27 | module.exports.CaliperEngine = require('./lib/manager/caliper-engine'); 28 | module.exports.MonitorOrchestrator = require('./lib/manager/orchestrators/monitor-orchestrator'); 29 | module.exports.RoundOrchestrator = require('./lib/manager/orchestrators/round-orchestrator'); 30 | module.exports.WorkerOrchestrator = require('./lib/manager/orchestrators/worker-orchestrator'); 31 | module.exports.WorkloadModuleInterface = require('./lib/worker/workload/workloadModuleInterface'); 32 | module.exports.WorkloadModuleBase = require('./lib/worker/workload/workloadModuleBase'); 33 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/config/config-util.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Config = require('./Config.js'); 18 | 19 | /** 20 | * Gets the singleton Config instance, creates it if necessary. 21 | * @return {Config} The singleton Config instance. 22 | * @private 23 | */ 24 | function _getConfigInstance() { 25 | if (!global.caliper) { 26 | global.caliper = {}; 27 | } 28 | 29 | if (!global.caliper.config) { 30 | global.caliper.config = new Config(); 31 | } 32 | 33 | return global.caliper.config; 34 | } 35 | 36 | /** 37 | * Utility function for setting a value for a key in the configuration store. 38 | * @param {string} name The key of the configuration to set. 39 | * @param {any} value The value to set. 40 | */ 41 | function set(name, value) { 42 | _getConfigInstance().set(name, value); 43 | } 44 | 45 | /** 46 | * Utility function for retrieving a value from the configuration store. 47 | * @param {string} name The key of the configuration to retrieve. 48 | * @param {any} defaultValue The value to return in case the key is not found. 49 | * @return {any} The value of the configuration or the defaultValue parameter if not found. 50 | */ 51 | function get(name, defaultValue = undefined) { 52 | return _getConfigInstance().get(name, defaultValue); 53 | } 54 | 55 | module.exports.get = get; 56 | module.exports.set = set; 57 | module.exports.keys = Config.keys; 58 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/assignIdMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | 20 | /** 21 | * Class for the "assignId" message. 22 | */ 23 | class AssignIdMessage extends Message { 24 | /** 25 | * Constructor for an "assignId" message instance. 26 | * @param {string} sender The sender of the message. 27 | * @param {string[]} recipients The recipients of the message. 28 | * @param {object} content The content of the message. 29 | * @param {string} date The date string of the message. 30 | * @param {string} error The potential error associated with the message. 31 | */ 32 | constructor(sender, recipients, content, date = undefined, error = undefined) { 33 | super(sender, recipients, MessageTypes.AssignId, content, date, error); 34 | } 35 | 36 | /** 37 | * Gets the assigned zero-based worker index. 38 | * @return {number} The worker index. 39 | */ 40 | getWorkerIndex() { 41 | return this.content.workerIndex; 42 | } 43 | } 44 | 45 | module.exports = AssignIdMessage; 46 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/assignedMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | 20 | /** 21 | * Class for the "assigned" message. 22 | */ 23 | class AssignedMessage extends Message { 24 | /** 25 | * Constructor for a "assigned" message instance. 26 | * @param {string} sender The sender of the message. 27 | * @param {string[]} recipients The recipients of the message. 28 | * @param {string} date The date string of the message. 29 | * @param {string} error The potential error associated with the message. 30 | */ 31 | constructor(sender, recipients, date = undefined, error = undefined) { 32 | super(sender, recipients, MessageTypes.Assigned, {}, date, error); 33 | } 34 | } 35 | 36 | module.exports = AssignedMessage; 37 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/connectedMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | 20 | /** 21 | * Class for the "connected" message. 22 | */ 23 | class ConnectedMessage extends Message { 24 | /** 25 | * Constructor for a "connected" message instance. 26 | * @param {string} sender The sender of the message. 27 | * @param {string[]} recipients The recipients of the message. 28 | * @param {string} date The date string of the message. 29 | * @param {string} error The potential error associated with the message. 30 | */ 31 | constructor(sender, recipients, date = undefined, error = undefined) { 32 | super(sender, recipients, MessageTypes.Connected, {}, date, error); 33 | } 34 | } 35 | 36 | module.exports = ConnectedMessage; 37 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/exitMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | const MessageTargets = require('./../utils/constants').Messages.Targets; 20 | 21 | /** 22 | * Class for the "exit" message. 23 | */ 24 | class ExitMessage extends Message { 25 | /** 26 | * Constructor for an "exit" message instance. 27 | * @param {string} sender The sender of the message. 28 | * @param {string} date The date string of the message. 29 | * @param {string} error The potential error associated with the message. 30 | */ 31 | constructor(sender, date = undefined, error = undefined) { 32 | super(sender, [MessageTargets.All], MessageTypes.Exit, {}, date, error); 33 | } 34 | } 35 | 36 | module.exports = ExitMessage; 37 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/initializeMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | const MessageTargets = require('./../utils/constants').Messages.Targets; 20 | 21 | /** 22 | * Class for the "initialize" message. 23 | */ 24 | class InitializeMessage extends Message { 25 | /** 26 | * Constructor for a "initialize" message instance. 27 | * @param {string} sender The sender of the message. 28 | * @param {string} date The date string of the message. 29 | * @param {string} error The potential error associated with the message. 30 | */ 31 | constructor(sender, date = undefined, error = undefined) { 32 | super(sender, [MessageTargets.All], MessageTypes.Initialize, {}, date, error); 33 | } 34 | } 35 | 36 | module.exports = InitializeMessage; 37 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/preparedMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | 20 | /** 21 | * Class for the "prepared" message. 22 | */ 23 | class PreparedMessage extends Message { 24 | /** 25 | * Constructor for a "prepared" message instance. 26 | * @param {string} sender The sender of the message. 27 | * @param {string[]} recipients The recipients of the message. 28 | * @param {string} date The date string of the message. 29 | * @param {string} error The potential error associated with the message. 30 | */ 31 | constructor(sender, recipients, date = undefined, error = undefined) { 32 | super(sender, recipients, MessageTypes.Prepared, {}, date, error); 33 | } 34 | } 35 | 36 | module.exports = PreparedMessage; 37 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/readyMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | 20 | /** 21 | * Class for the "ready" message. 22 | */ 23 | class ReadyMessage extends Message { 24 | /** 25 | * Constructor for a "ready" message instance. 26 | * @param {string} sender The sender of the message. 27 | * @param {string[]} recipients The recipients of the message. 28 | * @param {string} date The date string of the message. 29 | * @param {string} error The potential error associated with the message. 30 | */ 31 | constructor(sender, recipients, date = undefined, error = undefined) { 32 | super(sender, recipients, MessageTypes.Ready, {}, date, error); 33 | } 34 | } 35 | 36 | module.exports = ReadyMessage; 37 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/registerMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | const MessageTargets = require('./../utils/constants').Messages.Targets; 20 | 21 | /** 22 | * Class for the "register" message. 23 | */ 24 | class RegisterMessage extends Message { 25 | /** 26 | * Constructor for a "register" message instance. 27 | * @param {string} sender The sender of the message. 28 | * @param {string} date The date string of the message. 29 | * @param {string} error The potential error associated with the message. 30 | */ 31 | constructor(sender, date = undefined, error = undefined) { 32 | super(sender, [MessageTargets.All], MessageTypes.Register, {}, date, error); 33 | } 34 | } 35 | 36 | module.exports = RegisterMessage; 37 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/testResultMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | 20 | /** 21 | * Class for the "testResult" message. 22 | */ 23 | class TestResultMessage extends Message { 24 | /** 25 | * Constructor for a "testResult" message instance. 26 | * @param {string} sender The sender of the message. 27 | * @param {string[]} recipients The recipients of the message. 28 | * @param {object} content The content of the message. 29 | * @param {string} date The date string of the message. 30 | * @param {string} error The potential error associated with the message. 31 | */ 32 | constructor(sender, recipients, content, date = undefined, error = undefined) { 33 | super(sender, recipients, MessageTypes.TestResult, content, date, error); 34 | } 35 | } 36 | 37 | module.exports = TestResultMessage; 38 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/txResetMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | 20 | /** 21 | * Class for the "txReset" message. 22 | */ 23 | class TxResetMessage extends Message { 24 | /** 25 | * Constructor for a "txReset" message instance. 26 | * @param {string} sender The sender of the message. 27 | * @param {string[]} recipients The recipients of the message. 28 | * @param {string} date The date string of the message. 29 | * @param {string} error The potential error associated with the message. 30 | */ 31 | constructor(sender, recipients, date = undefined, error = undefined) { 32 | // the local observers needs this content, deep-deep down 33 | super(sender, recipients, MessageTypes.TxReset, { type: MessageTypes.TxReset }, date, error); 34 | } 35 | } 36 | 37 | module.exports = TxResetMessage; 38 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/txUpdateMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('./../utils/constants').Messages.Types; 19 | 20 | /** 21 | * Class for the "txUpdate" message. 22 | */ 23 | class TxUpdateMessage extends Message { 24 | /** 25 | * Constructor for a "txUpdate" message instance. 26 | * @param {string} sender The sender of the message. 27 | * @param {string[]} recipients The recipients of the message. 28 | * @param {object} content The content of the message. 29 | * @param {string} date The date string of the message. 30 | * @param {string} error The potential error associated with the message. 31 | */ 32 | constructor(sender, recipients, content, date = undefined, error = undefined) { 33 | super(sender, recipients, MessageTypes.TxUpdate, content, date, error); 34 | // the local observers needs this content, deep-deep down 35 | this.content.type = MessageTypes.TxUpdate; 36 | } 37 | } 38 | 39 | module.exports = TxUpdateMessage; 40 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messages/workerMetricsMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Message = require('./message'); 18 | const MessageTypes = require('../utils/constants').Messages.Types; 19 | 20 | /** 21 | * Class for the "workerMetricsMessage" message. 22 | */ 23 | class WorkerMetricsMessage extends Message { 24 | /** 25 | * Constructor for a "workerMetricsMessage" message instance. 26 | * @param {string} sender The sender of the message. 27 | * @param {string[]} recipients The recipients of the message. 28 | * @param {object} content The content of the message. 29 | * @param {string} date The date string of the message. 30 | * @param {string} error The potential error associated with the message. 31 | */ 32 | constructor(sender, recipients, content, date = undefined, error = undefined) { 33 | super(sender, recipients, MessageTypes.WorkerMetricsMessage, content, date, error); 34 | } 35 | } 36 | 37 | module.exports = WorkerMetricsMessage; 38 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messengers/mqtt/factory.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const MqttMessenger = require('./mqtt-messenger'); 18 | 19 | const WorkerToManagerTopic = 'worker/update'; 20 | const ManagerToWorkerTopic = 'manager/update'; 21 | 22 | /** 23 | * Creates a new MqttManagerMessenger instance. 24 | * @param {object} messengerConfig the messenger configuration 25 | * @return {MessengerInterface} The messenger instance. 26 | */ 27 | function createManagerMessenger(messengerConfig) { 28 | return new MqttMessenger(messengerConfig, WorkerToManagerTopic, ManagerToWorkerTopic); 29 | } 30 | 31 | /** 32 | * Creates a new MqttWorkerMessenger instance. 33 | * @param {object} messengerConfig the messenger configuration 34 | * @return {MessengerInterface} The messenger instance. 35 | */ 36 | function createWorkerMessenger(messengerConfig) { 37 | return new MqttMessenger(messengerConfig, ManagerToWorkerTopic, WorkerToManagerTopic); 38 | } 39 | 40 | module.exports.createManagerMessenger = createManagerMessenger; 41 | module.exports.createWorkerMessenger = createWorkerMessenger; 42 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/messengers/process/factory.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const ProcessMessenger = require('./process-messenger'); 18 | 19 | /** 20 | * Creates a new ProcessMessenger instance. 21 | * @param {object} messengerConfig the messenger configuration 22 | * @return {MessengerInterface} The messenger instance. 23 | */ 24 | function createProcessMessenger(messengerConfig) { 25 | return new ProcessMessenger(messengerConfig); 26 | } 27 | 28 | module.exports.createManagerMessenger = createProcessMessenger; 29 | module.exports.createWorkerMessenger = createProcessMessenger; 30 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/utils/constants.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | 18 | module.exports = { 19 | Messages: { 20 | Types: { 21 | Register: 'register', 22 | Connected: 'connected', 23 | AssignId: 'assignId', 24 | Assigned: 'assigned', 25 | Initialize: 'initialize', 26 | Ready: 'ready', 27 | Prepare: 'prepare', 28 | Prepared: 'prepared', 29 | Test: 'test', 30 | TxReset: 'txReset', 31 | TxUpdate: 'txUpdate', 32 | TestResult: 'testResult', 33 | Exit: 'exit' 34 | }, 35 | Targets: { 36 | All: 'all' 37 | } 38 | }, 39 | Factories: { 40 | Connector: 'ConnectorFactory', 41 | WorkerMessenger: 'createWorkerMessenger', 42 | ManagerMessenger: 'createManagerMessenger' 43 | }, 44 | Events: { 45 | Connector: { 46 | TxsSubmitted: 'txsSubmitted', 47 | TxsFinished: 'txsFinished' 48 | } 49 | }, 50 | AuthComponents: { 51 | PushGateway: 'PrometheusPush', 52 | Prometheus: 'Prometheus' 53 | } 54 | }; 55 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/common/utils/log-formats.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const colors = require('colors/safe'); 18 | const { format } = require('logform'); 19 | const { LEVEL } = require('triple-beam'); 20 | 21 | const attributeRegex = /%attribute%/gi; 22 | 23 | const colorizeExtra = format((info, opts) => { 24 | // The immutable level string of the message (the normal property could be mutated already) 25 | let lev = info[LEVEL]; 26 | // colors enables multiple styles separated by spaces 27 | let colorStyles = opts.colors[lev].split(' '); 28 | 29 | for (let key of Object.keys(info)) { 30 | if (info[key] !== undefined && (opts.all || opts[key])) { 31 | // surround the value with the style codes one by one 32 | for (let style of colorStyles) { 33 | try { 34 | info[key] = colors[style](info[key]); 35 | } catch (e) { 36 | // silent fail, can't log here 37 | } 38 | } 39 | } 40 | } 41 | 42 | return info; 43 | }); 44 | 45 | const padLevelExtra = format(info => { 46 | 47 | let padding = ' '.repeat(Math.max(5 - info[LEVEL].length, 0)); 48 | info.level = `${info.level}${padding}`; 49 | return info; 50 | }); 51 | 52 | const attributeFormat = format((info, opts) => { 53 | for (let key of Object.keys(info)) { 54 | if (typeof opts[key] === 'string') { 55 | if (typeof info[key] !== 'string') { 56 | info[key] = JSON.stringify(info[key]); 57 | } 58 | 59 | info[key] = opts[key].replace(attributeRegex, info[key]); 60 | } 61 | } 62 | 63 | return info; 64 | }); 65 | 66 | module.exports.ColorizerExtra = colorizeExtra; 67 | module.exports.PadLevelExtra = padLevelExtra; 68 | module.exports.AttributeFormat = attributeFormat; 69 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/manager/monitors/monitor-interface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 16 | 'use strict'; 17 | 18 | const ConfigUtil = require('../../common/config/config-util.js'); 19 | 20 | // TODO: now we record the performance information in local variable, it's better to use db later 21 | /** 22 | * Interface of resource consumption monitor 23 | */ 24 | class MonitorInterface { 25 | /** 26 | * Constructor 27 | * @param {JSON} resourceMonitorOptions Configuration options for the monitor 28 | */ 29 | constructor(resourceMonitorOptions) { 30 | this.options = resourceMonitorOptions; 31 | this.interval = resourceMonitorOptions.interval ? resourceMonitorOptions.interval*1000 : ConfigUtil.get(ConfigUtil.keys.Monitor.Interval); 32 | } 33 | 34 | /** 35 | * start monitoring 36 | */ 37 | async start() { 38 | throw new Error('start is not implemented for this monitor'); 39 | } 40 | 41 | /** 42 | * restart monitoring 43 | */ 44 | async restart() { 45 | throw new Error('restart is not implemented for this monitor'); 46 | } 47 | 48 | /** 49 | * stop monitoring 50 | */ 51 | async stop() { 52 | throw new Error('stop is not implemented for this monitor'); 53 | } 54 | 55 | /** 56 | * Get statistics from the monitor in the form of an Array containing Map detailing key/value pairs 57 | * @async 58 | */ 59 | async getStatistics() { 60 | throw new Error('getStatistics is not implemented for this monitor'); 61 | } 62 | } 63 | module.exports = MonitorInterface; 64 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/worker/rate-control/rateInterface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | /** 18 | * Base class for rate controllers. 19 | */ 20 | class RateInterface { 21 | 22 | /** 23 | * Initializes the rate controller instance. 24 | * @param {TestMessage} testMessage The testMessage passed for the round execution 25 | * @param {TransactionStatisticsCollector} stats The TX stats collector instance. 26 | * @param {number} workerIndex The 0-based index of the worker node. 27 | */ 28 | constructor(testMessage, stats, workerIndex) { 29 | this.testMessage = testMessage; 30 | this.stats = stats; 31 | this.workerIndex = workerIndex; 32 | this.controller = testMessage.getRateControlSpec(); 33 | this.options = this.controller.opts; 34 | this.roundIndex = testMessage.getRoundIndex(); 35 | this.roundLabel = testMessage.getRoundLabel(); 36 | this.numberOfWorkers = testMessage.getWorkersNumber(); 37 | } 38 | 39 | /** 40 | * Perform the rate control action by blocking the execution for a certain amount of time. 41 | * @async 42 | */ 43 | async applyRateControl() { 44 | throw new Error('Method \'applyRateControl\' is not implemented for this rate controller'); 45 | } 46 | 47 | /** 48 | * Notify the rate controller about the end of the round. 49 | * @async 50 | */ 51 | async end() { 52 | throw new Error('Method \'end\' is not implemented for this rate controller'); 53 | } 54 | } 55 | 56 | module.exports = RateInterface; 57 | -------------------------------------------------------------------------------- /packages/caliper-core/lib/worker/workload/workloadModuleInterface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | /** 18 | * Interface for the user-implemented workload modules used for assembling TXs for the SUT. 19 | */ 20 | class WorkloadModuleInterface { 21 | /** 22 | * Initialize the workload module with the given parameters. 23 | * @param {number} workerIndex The 0-based index of the worker instantiating the workload module. 24 | * @param {number} totalWorkers The total number of workers participating in the round. 25 | * @param {number} roundIndex The 0-based index of the currently executing round. 26 | * @param {object} roundArguments The user-provided arguments for the round from the benchmark configuration file. 27 | * @param {ConnectorBase} sutAdapter The adapter of the underlying SUT. 28 | * @param {object} sutContext The custom context object provided by the SUT adapter. 29 | * @async 30 | */ 31 | async initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext) { 32 | throw new Error('WorkloadModuleInterface.initializeWorkloadModule() must be implemented in derived class'); 33 | } 34 | 35 | /** 36 | * Assemble the next TX content(s) and submit it to the SUT adapter. 37 | * @async 38 | */ 39 | async submitTransaction() { 40 | throw new Error('WorkloadModuleInterface.submitTransaction() must be implemented in derived class'); 41 | } 42 | 43 | /** 44 | * Clean up the workload module at the end of the round. 45 | * @async 46 | */ 47 | async cleanupWorkloadModule() { 48 | throw new Error('WorkloadModuleInterface.cleanupWorkloadModule() must be implemented in derived class'); 49 | } 50 | } 51 | 52 | 53 | module.exports = WorkloadModuleInterface; 54 | -------------------------------------------------------------------------------- /packages/caliper-core/test/common/core/transaction-status.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const chai = require('chai'); 18 | chai.should(); 19 | 20 | const TxStatus = require('../../../lib/common/core/transaction-status'); 21 | 22 | describe('the transaction status', () => { 23 | it('should create a default time creation', () => { 24 | const txStatus = new TxStatus(); 25 | txStatus.GetTimeCreate().should.be.greaterThan(0); 26 | }); 27 | 28 | it('should allow changing of the default time creation', () => { 29 | const txStatus = new TxStatus(); 30 | const orgTimeCreate = txStatus.GetTimeCreate(); 31 | const newTimeCreate = Date.now() + 60000; 32 | txStatus.SetTimeCreate(newTimeCreate); 33 | txStatus.GetTimeCreate().should.not.equal(orgTimeCreate); 34 | txStatus.GetTimeCreate().should.equal(newTimeCreate); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /packages/caliper-core/test/worker/rate-control/mockRate.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | class MockRate { 16 | 17 | reset() { 18 | MockRate.applyRateControlCalled = false; 19 | } 20 | 21 | isApplyRateControlCalled() { 22 | return MockRate.applyRateControlCalled; 23 | } 24 | 25 | async applyRateControl() { 26 | MockRate.applyRateControlCalled = true; 27 | } 28 | } 29 | 30 | function createRateController(testMessage, stats, workerIndex) { 31 | return new MockRate(); 32 | } 33 | 34 | module.exports.createRateController = createRateController; -------------------------------------------------------------------------------- /packages/caliper-fabric/.eslintignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | coverage 16 | node_modules -------------------------------------------------------------------------------- /packages/caliper-fabric/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 8 8 | sourceType: script 9 | rules: 10 | indent: 11 | - error 12 | - 4 13 | linebreak-style: 14 | - error 15 | - unix 16 | prefer-const: 17 | - error 18 | quotes: 19 | - error 20 | - single 21 | semi: 22 | - error 23 | - always 24 | no-unused-vars: 25 | - error 26 | - args: none 27 | no-console: error 28 | curly: error 29 | eqeqeq: error 30 | no-throw-literal: error 31 | strict: error 32 | no-var: error 33 | dot-notation: error 34 | no-tabs: error 35 | no-trailing-spaces: error 36 | no-use-before-define: error 37 | no-useless-call: error 38 | no-with: error 39 | operator-linebreak: error 40 | require-jsdoc: 41 | - error 42 | - require: 43 | ClassDeclaration: true 44 | MethodDefinition: true 45 | FunctionDeclaration: true 46 | valid-jsdoc: 47 | - error 48 | - requireReturn: false 49 | yoda: error 50 | -------------------------------------------------------------------------------- /packages/caliper-fabric/.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | 3 | # Ignore any generated html files 4 | *.html 5 | 6 | # Ignore DS_Store files from Mac 7 | **.DS_Store 8 | 9 | architecture.pptx 10 | output.log 11 | lerna-debug.log 12 | 13 | # We prefer to not use lock files 14 | **/package-lock.json 15 | 16 | .idea/ 17 | **/node_modules/ 18 | **/log/ 19 | 20 | # Ignore code coverage logs 21 | **/.nyc_output/ 22 | **/coverage/ 23 | 24 | # Ignore IDE files 25 | .vscode/ 26 | 27 | # Website files 28 | .sass-cache/ 29 | Gemfile.lock 30 | _site/ 31 | 32 | # verdaccio files 33 | **/storage 34 | 35 | # pm2 files 36 | **/.pm2/ 37 | -------------------------------------------------------------------------------- /packages/caliper-fabric/.npmignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | # hidden config files 16 | .editorconfig 17 | .eslintignore 18 | .eslintrc.yml 19 | 20 | # test directory 21 | test 22 | -------------------------------------------------------------------------------- /packages/caliper-fabric/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | module.exports.ConnectorFactory = require('./lib/FabricConnectorFactory').ConnectorFactory; 18 | -------------------------------------------------------------------------------- /packages/caliper-fabric/lib/FabricConnectorContext.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | // This would be a public api for use by the workloads 18 | 19 | /** 20 | * THIS CLASS AND CONTENTS TO BE DECIDED 21 | */ 22 | class FabricConnectorContext { 23 | 24 | /** 25 | * 26 | * @param {number} clientIndex The worker index really 27 | */ 28 | constructor(clientIndex) { 29 | this.clientIndex = clientIndex; 30 | } 31 | } 32 | 33 | module.exports = FabricConnectorContext; 34 | -------------------------------------------------------------------------------- /packages/caliper-fabric/lib/connector-configuration/ConnectorConfigurationFactory.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const ConnectorConfiguration = require('./ConnectorConfiguration'); 18 | const IdentityManagerFactory = require('../identity-management/IdentityManagerFactory'); 19 | 20 | /** 21 | * Factory class for ConnectorConfigurations 22 | */ 23 | class ConnectorConfigurationFactory { 24 | 25 | /** 26 | * Create a ConnectorConfiguration instance 27 | * @param {string} connectorConfigurationPath path to connector configuration file 28 | * @param {IWalletFacadeFactory} walletFacadeFactory a version specific wallet facade factory 29 | * @returns {Promise} instance of a ConnectorConfiguration 30 | * @async 31 | */ 32 | async create(connectorConfigurationPath, walletFacadeFactory) { 33 | const connectorConfiguration = new ConnectorConfiguration(connectorConfigurationPath, new IdentityManagerFactory(), walletFacadeFactory); 34 | await connectorConfiguration.parseConfiguration(); 35 | return connectorConfiguration; 36 | } 37 | } 38 | 39 | module.exports = ConnectorConfigurationFactory; 40 | -------------------------------------------------------------------------------- /packages/caliper-fabric/lib/connector-versions/peer-gateway/WalletFacadeFactory.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const IWalletFacadeFactory = require('../../identity-management/IWalletFacadeFactory'); 18 | const WalletFacade = require('./WalletFacade'); 19 | 20 | /** 21 | * Factory for a Peer Gateway Wallet Facade 22 | */ 23 | class WalletFacadeFactory extends IWalletFacadeFactory { 24 | 25 | /** 26 | * create a Peer Gateway Wallet Facade 27 | * 28 | * @param {string} [walletPath] optional path to a file system wallet 29 | */ 30 | async create() { 31 | return new WalletFacade(); 32 | } 33 | } 34 | 35 | module.exports = WalletFacadeFactory; 36 | -------------------------------------------------------------------------------- /packages/caliper-fabric/lib/connector-versions/v2/WalletFacadeFactory.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const IWalletFacadeFactory = require('../../identity-management/IWalletFacadeFactory'); 18 | const WalletFacade = require('./WalletFacade'); 19 | 20 | /** 21 | * Factory for a V2 Wallet Facade 22 | */ 23 | class WalletFacadeFactory extends IWalletFacadeFactory { 24 | 25 | /** 26 | * create a V2 Wallet Facade 27 | * 28 | * @param {string} [walletPath] optional path to a file system wallet 29 | */ 30 | async create(walletPath) { 31 | const walletFacade = new WalletFacade(); 32 | await walletFacade.initialize(walletPath); 33 | return walletFacade; 34 | } 35 | } 36 | 37 | module.exports = WalletFacadeFactory; 38 | -------------------------------------------------------------------------------- /packages/caliper-fabric/lib/identity-management/ExportedIdentity.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | /** 18 | * A Class the normalizes (v1 and v2) the exported wallet identity 19 | */ 20 | class ExportedIdentity { 21 | 22 | /** 23 | * @param {string} mspid mspid 24 | * @param {string} certificate certificate 25 | * @param {string} privateKey private key 26 | */ 27 | constructor(mspid, certificate, privateKey) { 28 | this.mspid = mspid; 29 | this.certificate = certificate; 30 | this.privateKey = privateKey; 31 | } 32 | } 33 | 34 | module.exports = ExportedIdentity; 35 | -------------------------------------------------------------------------------- /packages/caliper-fabric/lib/identity-management/IWalletFacade.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | /** 18 | * Define the interface for a WalletFacade implementation 19 | */ 20 | class IWalletFacade { 21 | 22 | /** 23 | * Export an identity from a wallet in the form 24 | * 25 | * { 26 | * mspid: 'AnMspId', 27 | * certificate: 'pem encoded string', 28 | * privateKey: 'pem encoded string' 29 | * } 30 | * 31 | * @param {string} identityName the identity name that uniquely identifies the identity in the wrapped wallet 32 | * @returns {Promise} an object that represents the identity 33 | * @async 34 | */ 35 | async export(identityName) { 36 | throw new Error('Abstract method called'); 37 | } 38 | 39 | /** 40 | * Import an identity into a wallet 41 | * @param {string} mspid the mspid of the organization that owns this identity 42 | * @param {string} identityName the identity name that uniquely identifies the identity in the wallet 43 | * @param {string} certificate pem encoded string of the certificate 44 | * @param {string} privateKey pem encoded string of the private key 45 | * @async 46 | */ 47 | async import(mspid, identityName, certificate, privateKey) { 48 | throw new Error('Abstract method called'); 49 | } 50 | 51 | /** 52 | * Return a list of all the unique identity names in the wallet 53 | * @returns {Promise} a list of the unique identity names 54 | * @async 55 | */ 56 | async getAllIdentityNames() { 57 | throw new Error('Abstract method called'); 58 | } 59 | 60 | /** 61 | * Returns the instance of the version specific wrapped wallet 62 | */ 63 | getWallet() { 64 | throw new Error('Abstract method called'); 65 | } 66 | } 67 | 68 | module.exports = IWalletFacade; 69 | -------------------------------------------------------------------------------- /packages/caliper-fabric/lib/identity-management/IWalletFacadeFactory.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | /** 18 | * Factory for a WalletFacade 19 | */ 20 | class IWalletFacadeFactory { 21 | 22 | /** 23 | * Create a WalletFacade instance for either an in memory wallet or file system wallet if the walletPath 24 | * is provided 25 | * @param {*} [walletPath] optional path for a file system wallet 26 | * @returns {Promise} an instance of a wallet facade 27 | * @async 28 | */ 29 | async create(walletPath) { 30 | throw new Error('Abstract method called'); 31 | } 32 | } 33 | 34 | module.exports = IWalletFacadeFactory; 35 | -------------------------------------------------------------------------------- /packages/caliper-fabric/lib/identity-management/IdentityManagerFactory.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const IdentityManager = require('./IdentityManager'); 18 | 19 | /** 20 | * Factory to create an IdentityManager instance 21 | */ 22 | class IdentityManagerFactory { 23 | 24 | /** 25 | * Create an IdentityManager instance 26 | * @param {IWalletFacadeFactory} walletFacadeFactory instance of a WalletFacadeFactory used to create wallet facades 27 | * @param {*} organizations The organizations block from the connector configuration 28 | * @returns {Promise} an instance of an IdentityManager 29 | * @async 30 | */ 31 | async create(walletFacadeFactory, organizations) { 32 | const identityManager = new IdentityManager(walletFacadeFactory, organizations); 33 | await identityManager.initialize(); 34 | 35 | return identityManager; 36 | } 37 | } 38 | 39 | module.exports = IdentityManagerFactory; 40 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/connector-configuration/ConnectorConfigurationFactory.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const chai = require('chai'); 18 | const chaiAsPromised = require('chai-as-promised'); 19 | chai.use(chaiAsPromised); 20 | chai.should(); 21 | 22 | const ConnectorConfigurationFactory = require('../../lib/connector-configuration/ConnectorConfigurationFactory'); 23 | const ConnectorConfiguration = require('../../lib/connector-configuration/ConnectorConfiguration'); 24 | const GenerateWallet = require('../utils/GenerateWallet'); 25 | 26 | describe('A Connector Configuration Factory', () => { 27 | const {walletFacadeFactory} = new GenerateWallet().createStandardTestWalletSetup(); 28 | 29 | it('should accept a valid YAML file', async () => { 30 | const connectorConfiguration = await new ConnectorConfigurationFactory().create('./test/sample-configs/BasicConfig.yaml', walletFacadeFactory); 31 | connectorConfiguration.should.be.instanceOf(ConnectorConfiguration); 32 | }); 33 | 34 | it('should accept a valid JSON file', async () => { 35 | const connectorConfiguration = await new ConnectorConfigurationFactory().create('./test/sample-configs/BasicConfig.json', walletFacadeFactory); 36 | connectorConfiguration.should.be.instanceOf(ConnectorConfiguration); 37 | }); 38 | 39 | it('should throw an error if not a valid YAML file', async () => { 40 | await new ConnectorConfigurationFactory().create('./sample-configs/invalid.yaml', walletFacadeFactory).should.be.rejectedWith(/Failed to parse the .*invalid.yaml/); 41 | }); 42 | 43 | it('should throw an error if not a valid JSON file', async () => { 44 | await new ConnectorConfigurationFactory().create('./sample-configs/invalid.json', walletFacadeFactory).should.be.rejectedWith(/Failed to parse the .*invalid.json/); 45 | }); 46 | 47 | it('should throw an error if no file exists', async () => { 48 | await new ConnectorConfigurationFactory().create('/path/to/nonexistent/config.yaml').should.be.rejectedWith(/Failed to parse the \/path\/to\/nonexistent\/config.yaml/); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/LegacyNetworkConfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "1.0" 17 | mutual-tls: false 18 | 19 | caliper: 20 | blockchain: fabric 21 | 22 | clients: 23 | client0.org1.example.com: 24 | client: 25 | organization: Org1 26 | enrollmentSecret: Dummy 27 | credentialStore: 28 | path: /tmp/hfc-kvs/org1 29 | cryptoStore: 30 | path: /tmp/hfc-cvs/org1 31 | 32 | channels: 33 | mychannel: 34 | created: true 35 | orderers: 36 | - orderer0.example.com 37 | peers: 38 | peer0.org1.example.com: 39 | eventSource: true 40 | contracts: 41 | - id: marbles 42 | contractID: mymarbles 43 | version: v0 44 | yourchannel: 45 | created: true 46 | orderers: 47 | - orderer0.example.com 48 | peers: 49 | peer0.org1.example.com: 50 | eventSource: true 51 | contracts: 52 | - id: marbles 53 | contractID: yourmarbles 54 | version: v0 55 | 56 | organizations: 57 | Org1: 58 | mspid: Org1MSP 59 | peers: 60 | - peer0.org1.example.com 61 | certificateAuthorities: 62 | - ca.org1.example.com 63 | 64 | orderers: 65 | orderer0.example.com: 66 | url: grpc://localhost:7050 67 | grpcOptions: 68 | ssl-target-name-override: orderer0.example.com 69 | 70 | peers: 71 | peer0.org1.example.com: 72 | url: grpc://localhost:7051 73 | 74 | certificateAuthorities: 75 | ca.org1.example.com: 76 | url: http://localhost:7054 77 | httpOptions: 78 | verify: false 79 | registrar: 80 | - enrollId: admin 81 | enrollSecret: adminpw 82 | 83 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/NetworkConfigWithPeers.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Fabric", 3 | "version": "2.0.0", 4 | "caliper": { 5 | "blockchain": "fabric", 6 | "sutOptions": { 7 | "mutualTls": false 8 | } 9 | }, 10 | "channels": [ 11 | { 12 | "channelName": "mychannel", 13 | "contracts": [ 14 | { 15 | "id": "marbles", 16 | "contractID": "mymarbles" 17 | } 18 | ] 19 | }, 20 | { 21 | "channelName": "yourchannel", 22 | "contracts": [ 23 | { 24 | "id": "marbles", 25 | "contractID": "yourmarbles" 26 | } 27 | ] 28 | } 29 | ], 30 | "organizations": [ 31 | { 32 | "mspid": "Org1MSP", 33 | "peers": [ 34 | { 35 | "endpoint": "peer0.org1.example.com:7051", 36 | "tlsCACerts": { 37 | "pem": "-----BEGIN CERTIFICATE-----\nMIICWDCCAf6gAwIBAgIRAMpSgWFjDHOohXa0R6e9THgwCgYIKoZIzj0EAwIwdjEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG\ncmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHzAdBgNVBAMTFnRs\nc2NhLm9yZzEuZXhhbXBsZS5jb20wHhcNMjAwOTA3MTE0MjAwWhcNMzAwOTA1MTE0\nMjAwWjB2MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UE\nBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEfMB0G\nA1UEAxMWdGxzY2Eub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49\nAwEHA0IABMdLvSUDIjWYuBw4YVvJEW6ifFLymOAX7GKY6btVPDlkdeJ8vZErXLMz\nJWjivr/L5V2YnZqv0OWPMMfPv+zH+RGjbTBrMA4GA1UdDwEB/wQEAwIBpjAdBgNV\nHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB/zApBgNV\nHQ4EIgQg5fOhyzwaLKm3t54/H4b0aTe7/nGPyJZNh9IFRK6fDaAwCgYIKoZIzj0E\nAwIDSAAwRQIhAKEny//JY7GXZ/THsQIvUTYmXsjP/bLTI/VuLX7TzcefAiBYoSyY\ny90rdprI6Mp6RPiqjVf02P5ZC86UkP0Vw4pfiQ==\n-----END CERTIFICATE-----\n" 38 | }, 39 | "grpcOptions": { 40 | "grpc.ssl-target-name-overide": "override" 41 | } 42 | }, 43 | { 44 | "endpoint": "peer1.org1.example.com:7052", 45 | "grpcOptions": { 46 | "grpc.keepalive": 100 47 | } 48 | } 49 | ] 50 | }, 51 | { 52 | "mspid": "Org2MSP", 53 | "peers": [ 54 | { 55 | "endpoint": "peer0.org2.example.com:7051", 56 | "tlsCACerts": { 57 | "path": "path/to/some/file" 58 | } 59 | } 60 | ] 61 | } 62 | ] 63 | } 64 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/NetworkConfigWithPeers.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "2.0.0" 17 | 18 | caliper: 19 | blockchain: fabric 20 | sutOptions : 21 | mutualTls: false 22 | 23 | channels: 24 | - channelName: mychannel 25 | contracts: 26 | - id: marbles 27 | contractID: mymarbles 28 | - channelName: yourchannel 29 | contracts: 30 | - id: marbles 31 | contractID: yourmarbles 32 | 33 | organizations: 34 | - mspid: Org1MSP 35 | peers: 36 | - endpoint: peer0.org1.example.com:7051 37 | tlsCACerts: 38 | pem: | 39 | -----BEGIN CERTIFICATE----- 40 | MIICWDCCAf6gAwIBAgIRAMpSgWFjDHOohXa0R6e9THgwCgYIKoZIzj0EAwIwdjEL 41 | MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG 42 | cmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHzAdBgNVBAMTFnRs 43 | c2NhLm9yZzEuZXhhbXBsZS5jb20wHhcNMjAwOTA3MTE0MjAwWhcNMzAwOTA1MTE0 44 | MjAwWjB2MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UE 45 | BxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEfMB0G 46 | A1UEAxMWdGxzY2Eub3JnMS5leGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49 47 | AwEHA0IABMdLvSUDIjWYuBw4YVvJEW6ifFLymOAX7GKY6btVPDlkdeJ8vZErXLMz 48 | JWjivr/L5V2YnZqv0OWPMMfPv+zH+RGjbTBrMA4GA1UdDwEB/wQEAwIBpjAdBgNV 49 | HSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB/zApBgNV 50 | HQ4EIgQg5fOhyzwaLKm3t54/H4b0aTe7/nGPyJZNh9IFRK6fDaAwCgYIKoZIzj0E 51 | AwIDSAAwRQIhAKEny//JY7GXZ/THsQIvUTYmXsjP/bLTI/VuLX7TzcefAiBYoSyY 52 | y90rdprI6Mp6RPiqjVf02P5ZC86UkP0Vw4pfiQ== 53 | -----END CERTIFICATE----- 54 | grpcOptions: 55 | grpc.ssl-target-name-overide: override 56 | - endpoint: peer1.org1.example.com:7052 57 | grpcOptions: 58 | grpc.keepalive: 100 59 | 60 | - mspid: Org2MSP 61 | peers: 62 | - endpoint: peer0.org2.example.com:7051 63 | tlsCACerts: 64 | path: path/to/some/file 65 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/NoConnProfileOrPeersNetworkConfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "2.0.0" 17 | 18 | caliper: 19 | blockchain: fabric 20 | sutOptions : 21 | mutualTls: false 22 | 23 | channels: 24 | - channelName: mychannel 25 | contracts: 26 | - id: marbles 27 | contractID: mymarbles 28 | - channelName: yourchannel 29 | contracts: 30 | - id: marbles 31 | contractID: yourmarbles 32 | 33 | organizations: 34 | - mspid: Org1MSP 35 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/NoIdentitiesNetworkConfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "2.0.0" 17 | 18 | caliper: 19 | blockchain: fabric 20 | sutOptions : 21 | mutualTls: false 22 | 23 | channels: 24 | - channelName: mychannel 25 | contracts: 26 | - id: marbles 27 | contractID: mymarbles 28 | - channelName: yourchannel 29 | contracts: 30 | - id: marbles 31 | contractID: yourmarbles 32 | 33 | organizations: 34 | - mspid: Org1MSP 35 | connectionProfile: 36 | path: './test/sample-configs/Org1ConnectionProfile.yaml' 37 | discover: true 38 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/PeerGatewayNetworkConfigNotMutual.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # The name of the benchmark 17 | name: PeerGatewayNetworkConfigNotMutual 18 | # The caliper semantic version 19 | version: "2.0.0" 20 | 21 | # Global properties that define the SUT, and options that are specific to the target SUT 22 | caliper: 23 | blockchain: fabric 24 | sutOptions : 25 | mutualTls: false 26 | 27 | # Array of fabric channels for creation or use 28 | channels: 29 | - channelName: mychannel 30 | # Array of contracts to be installed/instantiated on the named channel and available for use by the workload module 31 | contracts: 32 | - id: marbles 33 | contractID: myMarbles 34 | 35 | - channelName: somechannel 36 | contracts: 37 | - id: marbles 38 | contractID: foundMyMarbles 39 | 40 | - channelName: yourchannel 41 | contracts: 42 | - id: marbles 43 | contractID: lostMyMarbles 44 | 45 | # [Minimum 1] Array of organizations that are to be used within the benchmarking, containing one of more identities to be used by the connector 46 | organizations: 47 | - mspid: Org1MSP 48 | connectionProfile: 49 | path: './test/sample-configs/Org1ConnectionProfile.yaml' 50 | discover: true 51 | - mspid: Org2MSP 52 | connectionProfile: 53 | path: './test/sample-configs/Org2StaticConnectionProfile.yaml' 54 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/UnknownVersionConfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "3.0.0" 17 | 18 | caliper: 19 | blockchain: fabric 20 | 21 | channels: 22 | - channelName: mychannel 23 | contracts: 24 | - id: marbles 25 | contractID: mymarbles 26 | - channelName: yourchannel 27 | contracts: 28 | - id: marbles 29 | contractID: yourmarbles 30 | 31 | organizations: 32 | - mspid: Org1MSP 33 | connectionProfile: 34 | path: './test/sample-configs/Org1ConnectionProfile.yaml' 35 | discover: true 36 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/User1.cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICKzCCAdGgAwIBAgIRAL0i4WmltsbdL5xDc0xJQYQwCgYIKoZIzj0EAwIwczEL 3 | MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG 4 | cmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh 5 | Lm9yZzEuZXhhbXBsZS5jb20wHhcNMjAwOTA3MTE0MjAwWhcNMzAwOTA1MTE0MjAw 6 | WjBsMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN 7 | U2FuIEZyYW5jaXNjbzEPMA0GA1UECxMGY2xpZW50MR8wHQYDVQQDDBZVc2VyMUBv 8 | cmcxLmV4YW1wbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEZ6BjhMNZ 9 | PjLYxx+Mtq08UY7Tmill5xRqbACy13wZCmb8SIW6/pjzhWVWfM7YoSLGQWgrgiB4 10 | 8NU8eubMyQA3DqNNMEswDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYD 11 | VR0jBCQwIoAgnvPwKjaMDSoQBDUfZMgJPmr5nlvrV/AdzLomWFMuLbkwCgYIKoZI 12 | zj0EAwIDSAAwRQIhAJwCKxXrCGZMgBlxbaMJzN7wcUM2qjX8jS4ZnBDl7HpaAiBH 13 | NhHITMTKPcPKgrQT/h1bTXqmxZXnwgh1n7D7VC/Fuw== 14 | -----END CERTIFICATE----- 15 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/User1.key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgIRZo3SAPXAJnGVOe 3 | jRALBJ208m+ojeCYCkmJQV2aBqahRANCAARnoGOEw1k+MtjHH4y2rTxRjtOaKWXn 4 | FGpsALLXfBkKZvxIhbr+mPOFZVZ8ztihIsZBaCuCIHjw1Tx65szJADcO 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "not valid": { 3 | "something": "else" 4 | 5 | } 6 | -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/invalid.pem: -------------------------------------------------------------------------------- 1 | MIICKzCCAdGgAwIBAgIRAL0i4WmltsbdL5xDc0xJQYQwCgYIKoZIzj0EAwIwczEL 2 | MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG 3 | cmFuY2lzY28xGTAXBgNVBAoTEG9yZzEuZXhhbXBsZS5jb20xHDAaBgNVBAMTE2Nh 4 | Lm9yZzEuZXhhbXBsZS5jb20wHhcNMjAwOTA3MTE0MjAwWhcNMzAwOTA1MTE0MjAw 5 | WjBsMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMN 6 | U2FuIEZyYW5jaXNjbzEPMA0GA1UECxMGY2xpZW50MR8wHQYDVQQDDBZVc2VyMUBv 7 | cmcxLmV4YW1wbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEZ6BjhMNZ 8 | PjLYxx+Mtq08UY7Tmill5xRqbACy13wZCmb8SIW6/pjzhWVWfM7YoSLGQWgrgiB4 9 | 8NU8eubMyQA3DqNNMEswDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYD 10 | VR0jBCQwIoAgnvPwKjaMDSoQBDUfZMgJPmr5nlvrV/AdzLomWFMuLbkwCgYIKoZI 11 | zj0EAwIDSAAwRQIhAJwCKxXrCGZMgBlxbaMJzN7wcUM2qjX8jS4ZnBDl7HpaAiBH 12 | NhHITMTKPcPKgrQT/h1bTXqmxZXnwgh1n7D7VC/Fuw== 13 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /packages/caliper-fabric/test/sample-configs/invalid.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | --- 16 | name: some name 17 | - id: some id 18 | - name: some name 19 | -------------------------------------------------------------------------------- /packages/caliper-publish/.dockerignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | lib/* 16 | node_modules/* 17 | .pm2/* 18 | .storage/* 19 | .editorconfig 20 | .eslintignore 21 | .eslintrc.yml 22 | .gitignore 23 | caliper.Dockerfile 24 | package.json 25 | package-lock.json 26 | publish.js 27 | README.md 28 | -------------------------------------------------------------------------------- /packages/caliper-publish/.eslintignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | coverage 16 | node_modules -------------------------------------------------------------------------------- /packages/caliper-publish/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaVersion: 2018 8 | sourceType: 9 | - script 10 | rules: 11 | indent: 12 | - error 13 | - 4 14 | linebreak-style: 15 | - error 16 | - unix 17 | quotes: 18 | - error 19 | - single 20 | semi: 21 | - error 22 | - always 23 | no-unused-vars: 24 | - error 25 | - args: none 26 | no-console: off 27 | curly: error 28 | eqeqeq: error 29 | no-throw-literal: error 30 | strict: error 31 | no-var: error 32 | dot-notation: error 33 | no-tabs: error 34 | no-trailing-spaces: error 35 | no-use-before-define: error 36 | no-useless-call: error 37 | no-with: error 38 | operator-linebreak: error 39 | require-jsdoc: 40 | - error 41 | - require: 42 | ClassDeclaration: true 43 | MethodDefinition: true 44 | FunctionDeclaration: true 45 | valid-jsdoc: 46 | - error 47 | - requireReturn: false 48 | yoda: error 49 | -------------------------------------------------------------------------------- /packages/caliper-publish/.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | 3 | # Ignore any generated html files 4 | *.html 5 | 6 | # Ignore DS_Store files from Mac 7 | **.DS_Store 8 | 9 | architecture.pptx 10 | output.log 11 | lerna-debug.log 12 | 13 | # We prefer to not use lock files 14 | **/package-lock.json 15 | 16 | .idea/ 17 | **/node_modules/ 18 | **/log/ 19 | 20 | # Ignore code coverage logs 21 | **/.nyc_output/ 22 | **/coverage/ 23 | 24 | # Ignore IDE files 25 | .vscode/ 26 | 27 | # Website files 28 | .sass-cache/ 29 | Gemfile.lock 30 | _site/ 31 | 32 | # verdaccio files 33 | **/storage 34 | 35 | # pm2 files 36 | **/.pm2/ 37 | -------------------------------------------------------------------------------- /packages/caliper-publish/artifacts/docker-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -e 18 | set -o pipefail 19 | 20 | # Set ARCH 21 | ARCH=`uname -m` 22 | 23 | docker build --network=host -t "${IMAGE}:${IMAGE_TAG}" -f caliper.Dockerfile --build-arg "caliper_version=${CALIPER_TAG}" --build-arg "npm_registry=${NPM_REGISTRY}" . 24 | -------------------------------------------------------------------------------- /packages/caliper-publish/artifacts/docker-publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error 17 | set -e 18 | 19 | if [[ -z "${DOCKER_TOKEN}" ]] 20 | then 21 | echo "ERROR: No DOCKER_TOKEN variable detected" 22 | exit 1 23 | fi 24 | 25 | # login to docker with secret token 26 | echo ${DOCKER_TOKEN} | docker login -u ${DOCKER_USER} --password-stdin 27 | docker push ${IMAGE}:${TAG} 28 | -------------------------------------------------------------------------------- /packages/caliper-publish/artifacts/npm-publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -e 18 | set -o pipefail 19 | 20 | # Set ARCH 21 | ARCH=`uname -m` 22 | 23 | if [[ -z "${NPM_REGISTRY}" ]] 24 | then 25 | if [[ -z "${NPM_TOKEN}" ]] 26 | then 27 | echo "NPM_TOKEN must be set when publishing to the public NPM registry." 28 | exit 1 29 | else 30 | # Set the NPM access token we will use to publish. 31 | npm config set registry https://registry.npmjs.org/ 32 | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} 33 | fi 34 | fi 35 | 36 | npm publish --access public ${NPM_REGISTRY} ${DRY_RUN} --tag ${TAG} 37 | -------------------------------------------------------------------------------- /packages/caliper-publish/artifacts/start-verdaccio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -ev 18 | set -o pipefail 19 | 20 | # Set ARCH 21 | ARCH=`uname -m` 22 | 23 | # Verdaccio server requires a dummy user if publishing via npm 24 | echo "//${BIND}/:_authToken=\"foo\"" > ${HOME}/.npmrc 25 | echo fetch-retries=10 >> ${HOME}/.npmrc 26 | export npm_config_registry=http://${BIND} 27 | 28 | # Start npm server 29 | PM2_HOME=.pm2 npx pm2 start verdaccio -- -l ${BIND} -c artifacts/verdaccio-config.yaml 30 | -------------------------------------------------------------------------------- /packages/caliper-publish/artifacts/stop-verdaccio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -ev 18 | set -o pipefail 19 | 20 | # Set ARCH 21 | ARCH=`uname -m` 22 | 23 | PM2_HOME=.pm2 npx pm2 stop verdaccio 24 | rm -rf ./.pm2 25 | rm -rf ./artifacts/storage 26 | rm -rf ${HOME}/.config/verdaccio 27 | rm -rf ${HOME}/.npmrc 28 | -------------------------------------------------------------------------------- /packages/caliper-publish/artifacts/verdaccio-config.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | # 16 | # This is the default config file. It allows all users to do anything, 17 | # so don't use it on production systems. 18 | # 19 | # Look here for more config file examples: 20 | # https://github.com/verdaccio/verdaccio/tree/5.x/conf 21 | # 22 | # path to a directory with all packages 23 | storage: ./storage 24 | max_body_size: 99999mb 25 | auth: 26 | htpasswd: 27 | file: ./htpasswd 28 | # Maximum amount of users allowed to register, defaults to "+inf". 29 | # You can set this to -1 to disable registration. 30 | #max_users: 1000 31 | # a list of other known repositories we can talk to 32 | uplinks: 33 | npmjs: 34 | url: https://registry.npmjs.org/ 35 | max_fails: 1000 36 | packages: 37 | '@*/*': 38 | # scoped packages 39 | access: $all 40 | publish: $all 41 | proxy: npmjs 42 | '**': 43 | # allow all users (including non-authenticated users) to read and 44 | # publish all packages 45 | access: $all 46 | # allow all known users to publish packages 47 | publish: $all 48 | # if package is not available locally, proxy requests to 'npmjs' registry 49 | proxy: npmjs 50 | # log settings 51 | logs: 52 | - {type: stdout, format: pretty, level: http} 53 | #- {type: file, path: verdaccio.log, level: info} 54 | listen: 55 | - localhost:4873 # default value 56 | -------------------------------------------------------------------------------- /packages/caliper-publish/caliper.Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | FROM node:18.19-alpine 16 | 17 | # require to set these explicitly to avoid mistakes 18 | ARG npm_registry 19 | ARG caliper_version 20 | 21 | # Install packages for dependency compilation 22 | RUN apk add --no-cache python3 g++ make git 23 | 24 | # execute as the "node" user, created in the base image 25 | USER node:node 26 | WORKDIR /hyperledger/caliper/workspace 27 | 28 | # 1 & 2. change the NPM global install directory 29 | # https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally#manually-change-npms-default-directory 30 | # 3. install Caliper globally (also install the core package, so it's bumped to the global root directory, so external modules can access it) 31 | RUN mkdir /home/node/.npm-global \ 32 | && npm config set prefix '/home/node/.npm-global' \ 33 | && npm install ${npm_registry} -g --only=prod @hyperledger/caliper-core@${caliper_version} @hyperledger/caliper-cli@${caliper_version} 34 | 35 | # Set NODE_PATH to the global install directory, so the global Caliper core module can be required by external modules 36 | # https://nodejs.org/docs/latest-v10.x/api/modules.html#modules_loading_from_the_global_folders 37 | ENV NODE_PATH /home/node/.npm-global/lib/node_modules 38 | ENV PATH /home/node/.npm-global/bin:$PATH 39 | ENV CALIPER_WORKSPACE /hyperledger/caliper/workspace 40 | ENV CALIPER_BIND_ARGS -g 41 | 42 | ENTRYPOINT ["caliper"] 43 | CMD ["--version"] 44 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/dockerCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Docker = require('./impl/docker'); 18 | 19 | module.exports.command = 'docker [options]'; 20 | module.exports.describe = 'Build and optionally publish the Caliper Docker image.'; 21 | module.exports.builder = yargs => { 22 | yargs.options({ 23 | image: { 24 | alias: 'i', 25 | demand: false, 26 | default: 'hyperledger/caliper', 27 | type: 'string', 28 | describe: 'The name for the built image.' 29 | }, 30 | tag: { 31 | alias: 't', 32 | demand: false, 33 | type: 'string', 34 | describe: 'Overrides the version-based tag for testing purposes' 35 | }, 36 | registry: { 37 | alias: 'r', 38 | demand: false, 39 | default: '', 40 | type: 'string', 41 | describe: 'The NPM registry address to use for building the Docker image. Defaults to the public NPM registry.' 42 | }, 43 | publish: { 44 | alias: 'p', 45 | demand: false, 46 | default: false, 47 | type: 'boolean', 48 | describe: 'Indicates whether to publish the built image. Requires that DOCKER_TOKEN and DOCKER_USER export variables are set.' 49 | }, 50 | retries: { 51 | alias: 'n', 52 | demand: false, 53 | default: 5, 54 | type: 'number', 55 | describe: 'The number of times to retry the build in case of failures.' 56 | } 57 | }); 58 | yargs.help(); 59 | yargs.usage('Example usage:\n./publish.js docker -r "http://localhost:4873" --retries 2'); 60 | return yargs; 61 | }; 62 | 63 | module.exports.handler = argv => { 64 | argv.thePromise = Docker.handler(argv.image, argv.registry, argv.publish, argv.retries, argv.tag); 65 | }; 66 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/npmCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const NPM = require('./impl/npm'); 18 | 19 | module.exports.command = 'npm [options]'; 20 | module.exports.describe = 'Publish the Caliper packages to a local or the public NPM registry.'; 21 | module.exports.builder = yargs => { 22 | yargs.options({ 23 | registry: { 24 | alias: 'r', 25 | demand: false, 26 | default: '', 27 | type: 'string', 28 | describe: 'The NPM registry address to use for publishing the packages. Defaults to the public NPM registry which requires NPM_TOKEN to be set.' 29 | }, 30 | 'dry-run': { 31 | alias: 'd', 32 | demand: false, 33 | default: false, 34 | type: 'boolean', 35 | describe: 'Indicates whether to perform only a dry run of the publishing.' 36 | }, 37 | retries: { 38 | alias: 'n', 39 | demand: false, 40 | default: 5, 41 | type: 'number', 42 | describe: 'The number of times to retry the publishing in case of failures.' 43 | } 44 | }); 45 | yargs.help(); 46 | yargs.usage('Example usage:\n./publish.js npm -r "http://localhost:4873" --retries 2'); 47 | return yargs; 48 | }; 49 | 50 | module.exports.handler = argv => { 51 | argv.thePromise = NPM.handler(argv.registry, argv['dry-run'], argv.retries); 52 | }; 53 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/verdaccio.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | exports.command = 'verdaccio '; 18 | exports.desc = 'General commands for managing a local Verdaccio NPM registry.'; 19 | exports.builder = yargs => { 20 | // apply commands in subdirectories 21 | return yargs 22 | .demandCommand(1, 'Incorrect command. Please see "./publish.js verdaccio --help"') 23 | .commandDir('verdaccio'); 24 | }; 25 | exports.handler = argv => {}; 26 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/verdaccio/impl/start.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const path = require('path'); 18 | const util = require('./../../utils/cmdutils'); 19 | 20 | /** 21 | * Implements the verdaccio start command logic. 22 | */ 23 | class Start { 24 | /** 25 | * Handler for the verdaccio start invocation. 26 | * @param {string} bind The binding endpoint for the Verdaccio process. 27 | * @async 28 | */ 29 | static async handler(bind) { 30 | const rootPath = path.join(__dirname, '..', '..', '..'); 31 | return util.invokeCommand('./artifacts/start-verdaccio.sh', [], { BIND: bind }, rootPath); 32 | } 33 | } 34 | 35 | module.exports = Start; 36 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/verdaccio/impl/stop.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const path = require('path'); 18 | const util = require('./../../utils/cmdutils'); 19 | 20 | /** 21 | * Implements the verdaccio stop command logic. 22 | */ 23 | class Stop { 24 | /** 25 | * Handler for the verdaccio stop invocation. 26 | * @async 27 | */ 28 | static async handler() { 29 | const rootPath = path.join(__dirname, '..', '..', '..'); 30 | return util.invokeCommand('./artifacts/stop-verdaccio.sh', [], {}, rootPath); 31 | } 32 | } 33 | 34 | module.exports = Stop; 35 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/verdaccio/startCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Start = require('./impl/start'); 18 | 19 | module.exports.command = 'start [options]'; 20 | module.exports.describe = 'Start a local verdaccio server.'; 21 | module.exports.builder = yargs => { 22 | yargs.options({ 23 | bind: { 24 | alias: 'b', 25 | demand: false, 26 | default: 'localhost:4873', 27 | type: 'string', 28 | describe: 'The binding endpoint for the Verdaccio process.' 29 | } 30 | }); 31 | yargs.help(); 32 | yargs.usage('Example usage:\n./publish.js verdaccio start --bind localhost:4873'); 33 | return yargs; 34 | }; 35 | 36 | module.exports.handler = argv => { 37 | argv.thePromise = Start.handler(argv.bind); 38 | }; 39 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/verdaccio/stopCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Stop = require('./impl/stop'); 18 | 19 | module.exports.command = 'stop'; 20 | module.exports.describe = 'Stop a local verdaccio server.'; 21 | module.exports.builder = yargs => { 22 | yargs.options({}); 23 | yargs.help(); 24 | yargs.usage('Example usage:\n./publish.js verdaccio stop'); 25 | return yargs; 26 | }; 27 | 28 | module.exports.handler = argv => { 29 | argv.thePromise = Stop.handler(); 30 | }; 31 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/version.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | exports.command = 'version '; 18 | exports.desc = 'Commands for checking and fixing package versions across the mono-repository'; 19 | exports.builder = yargs => { 20 | // apply commands in subdirectories 21 | return yargs 22 | .demandCommand(1, 'Incorrect command. Please see "./publish.js version --help"') 23 | .commandDir('version'); 24 | }; 25 | exports.handler = argv => {}; 26 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/version/checkCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Check = require('./impl/check'); 18 | 19 | module.exports.command = 'check'; 20 | module.exports.describe = 'Check whether the Caliper package versions match the root version'; 21 | module.exports.builder = yargs => { 22 | yargs.help(); 23 | yargs.usage('Example usage:\n./publish.js version check'); 24 | return yargs; 25 | }; 26 | 27 | module.exports.handler = argv => { 28 | argv.thePromise = Check.handler(); 29 | }; 30 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/version/fixCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const Fix = require('./impl/fix'); 18 | 19 | module.exports.command = 'fix'; 20 | module.exports.describe = 'Restore the Caliper package versions to the root version'; 21 | module.exports.builder = yargs => { 22 | yargs.help(); 23 | yargs.usage('Example usage:\n./publish.js version fix'); 24 | return yargs; 25 | }; 26 | 27 | module.exports.handler = argv => { 28 | argv.thePromise = Fix.handler(); 29 | }; 30 | -------------------------------------------------------------------------------- /packages/caliper-publish/lib/version/impl/check.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const path = require('path'); 18 | 19 | // impl => version => lib => caliper-publish => packages => root 20 | const repoRoot = path.join(__dirname, '..', '..', '..', '..', '..'); 21 | 22 | /** 23 | * Implements the version check command logic. 24 | */ 25 | class Check { 26 | /** 27 | * Handler for the version check invocation. 28 | * @async 29 | */ 30 | static async handler() { 31 | const rootPackageJsonPath = path.join(repoRoot, 'package.json'); 32 | const rootPackageObject = require(rootPackageJsonPath); 33 | const rootPackageVersion = rootPackageObject.version; 34 | const packages = Array.from(rootPackageObject.workspaces); 35 | // add the root "package" 36 | packages.push('./'); 37 | 38 | let mismatch = false; 39 | console.log('Checking package versions...'); 40 | 41 | for (const pkg of packages) { 42 | const packageJsonPath = path.join(repoRoot, pkg, 'package.json'); 43 | const packageObject = require(packageJsonPath); 44 | 45 | if (packageObject.version !== rootPackageVersion) { 46 | mismatch = true; 47 | console.log(`ERROR: package "${pkg}" version "${packageObject.version}" does not match root package version "${rootPackageVersion}"`); 48 | } 49 | 50 | for (const dep of Object.keys(packageObject.dependencies)) { 51 | if (dep.startsWith('@hyperledger/caliper-') && packageObject.dependencies[dep] !== rootPackageVersion) { 52 | mismatch = true; 53 | console.log(`ERROR: package "${pkg}" dependency "${dep}" does not match root package version "${rootPackageVersion}"`); 54 | } 55 | } 56 | } 57 | 58 | if (mismatch) { 59 | throw new Error(`Some package versions do not match the root packageversion "${rootPackageVersion}"`); 60 | } 61 | 62 | console.log('Package versions are correct'); 63 | } 64 | } 65 | 66 | module.exports = Check; 67 | -------------------------------------------------------------------------------- /packages/caliper-publish/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caliper-publish", 3 | "description": "Hyperledger Caliper internal CLI for publishing packages", 4 | "version": "0.6.1-unstable", 5 | "private": true, 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/hyperledger-caliper/caliper", 9 | "directory": "packages/caliper-publish" 10 | }, 11 | "main": "publish.js", 12 | "scripts": { 13 | "pretest": "npm run licchk", 14 | "licchk": "license-check-and-add", 15 | "test": "npm run lint", 16 | "lint": "npx eslint .", 17 | "nyc": "nyc --reporter=text --reporter=clover mocha --recursive -t 10000" 18 | }, 19 | "engines": { 20 | "node": ">=18.19.0", 21 | "npm": ">=6.14.16" 22 | }, 23 | "dependencies": { 24 | "yargs": "15.3.1" 25 | }, 26 | "devDependencies": { 27 | "eslint": "^5.16.0", 28 | "mocha": "3.4.2", 29 | "nyc": "11.1.0", 30 | "pm2": "2.10.1", 31 | "verdaccio": "3.12.0", 32 | "license-check-and-add": "2.3.6" 33 | }, 34 | "license-check-and-add-config": { 35 | "folder": ".", 36 | "license": "../../LICENSE.txt", 37 | "exact_paths_method": "EXCLUDE", 38 | "exact_paths": [ 39 | "node_modules", 40 | ".nyc_output", 41 | "coverage", 42 | ".gitignore", 43 | "log" 44 | ], 45 | "file_type_method": "EXCLUDE", 46 | "file_types": [ 47 | ".yml", 48 | ".md", 49 | ".log" 50 | ], 51 | "insert_license": false, 52 | "license_formats": { 53 | "js": { 54 | "prepend": "/*", 55 | "append": "*/", 56 | "eachLine": { 57 | "prepend": "* " 58 | } 59 | }, 60 | "editorconfig|yaml|Dockerfile": { 61 | "prepend": "#", 62 | "append": "#", 63 | "eachLine": { 64 | "prepend": "# " 65 | } 66 | } 67 | } 68 | }, 69 | "nyc": { 70 | "exclude": [ 71 | "lib/**" 72 | ], 73 | "reporter": [ 74 | "text-summary", 75 | "html" 76 | ], 77 | "all": true, 78 | "check-coverage": false, 79 | "statements": 5, 80 | "branches": 8, 81 | "functions": 7, 82 | "lines": 5 83 | }, 84 | "license": "Apache-2.0" 85 | } 86 | -------------------------------------------------------------------------------- /packages/caliper-publish/publish.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /* 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | 'use strict'; 17 | 18 | const yargs = require('yargs'); 19 | 20 | const version = 'v' + require('./package.json').version; 21 | 22 | let results = yargs 23 | .commandDir('./lib') 24 | .completion() 25 | .recommendCommands() 26 | .help() 27 | .demandCommand(1, 1, 'Please specify a command to continue') 28 | .wrap(null) 29 | .strict() 30 | .alias('version', 'v') 31 | .alias('help', 'h') 32 | .version(version) 33 | .describe('version', 'Show version information') 34 | .describe('help', 'Show usage information') 35 | .argv; 36 | 37 | results.thePromise.then( () => { 38 | console.log('Publish command successful'); 39 | process.exit(0); 40 | }).catch((error) => { 41 | console.error(`ERROR: Publish command failed: ${error.message}`); 42 | process.exit(1); 43 | }); 44 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/.gitignore: -------------------------------------------------------------------------------- 1 | **/*.log 2 | report.html 3 | fabric-samples 4 | vendor 5 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/caliper.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | caliper: 16 | benchconfig: benchconfig.yaml 17 | networkconfig: networkconfig.yaml 18 | txupdatetime: 500 19 | logging: 20 | template: '%timestamp%%level%%module%%message%%metadata%' 21 | formats: 22 | timestamp: 'YYYY.MM.DD-HH:mm:ss.SSS ZZ' 23 | label: false 24 | json: false 25 | pad: true 26 | align: false 27 | attributeformat: 28 | level: ' %attribute%' 29 | module: ' [%attribute%] ' 30 | metadata: ' (%attribute%)' 31 | colorize: 32 | all: true 33 | colors: 34 | info: green 35 | error: red 36 | warn: yellow 37 | debug: grey 38 | targets: 39 | console: 40 | target: console 41 | enabled: true 42 | options: 43 | level: info 44 | file: 45 | target: file 46 | enabled: false 47 | worker: 48 | communication: 49 | method: mqtt 50 | address: mqtt://localhost:1883 51 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | version: '3' 16 | 17 | volumes: 18 | prometheus_data: {} 19 | 20 | services: 21 | 22 | ############## 23 | # MONITORING # 24 | ############## 25 | 26 | prometheus: 27 | image: prom/prometheus 28 | container_name: prometheus 29 | volumes: 30 | - ./prometheus/prometheus-fabric.yml:/etc/prometheus/prometheus.yml 31 | - prometheus_data:/prometheus 32 | command: 33 | - '--config.file=/etc/prometheus/prometheus.yml' 34 | - '--storage.tsdb.path=/prometheus' 35 | - '--web.console.libraries=/usr/share/prometheus/console_libraries' 36 | - '--web.console.templates=/usr/share/prometheus/consoles' 37 | ports: 38 | - "9090:9090" 39 | 40 | pushGateway: 41 | image: prom/pushgateway 42 | container_name: pushGateway 43 | ports: 44 | - "9091:9091" 45 | 46 | cadvisor: 47 | image: google/cadvisor 48 | container_name: cadvisor 49 | volumes: 50 | - /var/run:/var/run:rw 51 | - /sys:/sys:ro 52 | - /var/lib/docker/:/var/lib/docker:ro 53 | ports: 54 | - 8080:8080 55 | restart: always 56 | 57 | ############### 58 | # MQTT BROKER # 59 | ############### 60 | 61 | mosquitto: 62 | image: eclipse-mosquitto 63 | hostname: mosquitto 64 | container_name: mosquitto 65 | restart: always 66 | ports: 67 | - "1883:1883" 68 | - "9001:9001" 69 | volumes: 70 | - ./mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf 71 | 72 | networks: 73 | default: 74 | name: fabric_test 75 | external: true 76 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/mosquitto/mosquitto.conf: -------------------------------------------------------------------------------- 1 | persistence false 2 | listener 1883 3 | allow_anonymous true 4 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/phase1/benchconfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | --- 16 | test: 17 | workers: 18 | number: 2 19 | rounds: 20 | - label: init1 21 | txNumber: 100 22 | rateControl: { type: 'fixed-rate', opts: { tps: 20 } } 23 | workload: 24 | module: ./../init.js 25 | - label: init2 26 | txNumber: 200 27 | rateControl: { type: 'fixed-feedback-rate', opts: { tps: 20, maximum_transaction_load: 5 } } 28 | workload: 29 | module: ./../init.js 30 | - label: query 31 | txNumber: 100 32 | rateControl: { type: 'linear-rate', opts: { startingTps: 10, finishingTps: 20 } } 33 | workload: 34 | module: ./../query.js 35 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/phase1/networkconfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "2.0.0" 17 | 18 | caliper: 19 | blockchain: fabric 20 | command: 21 | start: docker compose -p caliper up -d; sleep 5s 22 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/phase2/benchconfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | --- 16 | test: 17 | workers: 18 | number: 2 19 | rounds: 20 | - label: init1 21 | txNumber: 25 22 | rateControl: { type: 'fixed-rate', opts: { tps: 5 } } 23 | workload: 24 | module: ./../init.js 25 | arguments: 26 | marblePrefix: marbles_phase_4 27 | - label: query1 28 | txNumber: 25 29 | rateControl: { type: 'linear-rate', opts: { startingTps: 5, finishingTps: 10 } } 30 | workload: 31 | module: ./../query.js 32 | - label: init2 33 | txNumber: 25 34 | rateControl: { type: 'fixed-rate', opts: { tps: 5 } } 35 | workload: 36 | module: ./../initByChannel.js 37 | arguments: 38 | marblePrefix: marbles_phase_4 39 | - label: query2 40 | txNumber: 25 41 | rateControl: { type: 'linear-rate', opts: { startingTps: 5, finishingTps: 10 } } 42 | workload: 43 | module: ./../queryByChannel.js 44 | monitors: 45 | transaction: 46 | - module: prometheus-push 47 | options: 48 | pushInterval: 5000 49 | pushUrl: "http://localhost:9091" 50 | resource: 51 | - module: prometheus 52 | options: 53 | url: "http://localhost:9090" 54 | metrics: 55 | include: [peer*, dev*] 56 | queries: 57 | - name: Endorse Time (s) 58 | query: rate(endorser_propsal_duration_sum{chaincode="marbles:v0"}[1m])/rate(endorser_propsal_duration_count{chaincode="marbles:v0"}[1m]) 59 | step: 1 60 | label: instance 61 | statistic: avg 62 | - name: Max Memory (MB) 63 | query: sum(container_memory_rss{name=~".+"}) by (name) 64 | step: 10 65 | label: name 66 | statistic: max 67 | multiplier: 0.000001 68 | charting: 69 | polar: 70 | metrics: [Max Memory (MB)] 71 | bar: 72 | metrics: [all] 73 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/phase2/networkconfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "2.0.0" 17 | 18 | caliper: 19 | blockchain: fabric 20 | sutOptions : 21 | mutualTls: false 22 | 23 | channels: 24 | - channelName: mychannel 25 | contracts: 26 | - id: mymarbles 27 | - channelName: yourchannel 28 | contracts: 29 | - id: yourmarbles 30 | 31 | organizations: 32 | - mspid: Org1MSP 33 | identities: 34 | certificates: 35 | - name: 'client0.org1.example.com' 36 | clientPrivateKey: 37 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/priv_sk' 38 | clientSignedCert: 39 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem' 40 | connectionProfile: 41 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/connection-org1.yaml' 42 | discover: true 43 | 44 | - mspid: Org2MSP 45 | identities: 46 | certificates: 47 | - name: 'client0.org2.example.com' 48 | clientPrivateKey: 49 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/priv_sk' 50 | clientSignedCert: 51 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem' 52 | connectionProfile: 53 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/connection-org2.yaml' 54 | discover: true 55 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/phase3/networkconfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "2.0.0" 17 | 18 | caliper: 19 | blockchain: fabric 20 | sutOptions : 21 | mutualTls: false 22 | 23 | channels: 24 | - channelName: mychannel 25 | contracts: 26 | - id: mymarbles 27 | - channelName: yourchannel 28 | contracts: 29 | - id: yourmarbles 30 | 31 | organizations: 32 | - mspid: Org1MSP 33 | identities: 34 | certificates: 35 | - name: 'client0.org1.example.com' 36 | clientPrivateKey: 37 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/priv_sk' 38 | clientSignedCert: 39 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem' 40 | peers: 41 | - endpoint: localhost:7051 42 | grpcOptions: 43 | ssl-target-name-override: peer0.org1.example.com 44 | grpc.keepalive_time_ms: 600000 45 | tlsCACerts: 46 | path: ../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem 47 | 48 | - mspid: Org2MSP 49 | identities: 50 | certificates: 51 | - name: 'client0.org2.example.com' 52 | clientPrivateKey: 53 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/priv_sk' 54 | clientSignedCert: 55 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/signcerts/User1@org2.example.com-cert.pem' 56 | peers: 57 | - endpoint: localhost:9051 58 | grpcOptions: 59 | ssl-target-name-override: peer0.org2.example.com 60 | grpc.keepalive_time_ms: 600000 61 | tlsCACerts: 62 | path: ../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/tlscacerts/tlsca.org2.example.com-cert.pem 63 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/phase4/benchconfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | --- 16 | test: 17 | workers: 18 | number: 2 19 | rounds: 20 | - label: init1 21 | txNumber: 100 22 | rateControl: { type: 'fixed-rate', opts: { tps: 20 } } 23 | workload: 24 | module: ./../init.js 25 | arguments: 26 | marblePrefix: marbles_phase_6 27 | - label: init2 28 | txNumber: 200 29 | rateControl: { type: 'fixed-feedback-rate', opts: { tps: 20, maximum_transaction_load: 5 } } 30 | workload: 31 | module: ./../init.js 32 | arguments: 33 | marblePrefix: marbles_phase_6 34 | - label: query 35 | txNumber: 100 36 | rateControl: { type: 'linear-rate', opts: { startingTps: 10, finishingTps: 20 } } 37 | workload: 38 | module: ./../query.js 39 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/phase4/networkconfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "2.0.0" 17 | 18 | caliper: 19 | blockchain: fabric 20 | command: 21 | end: docker compose -p caliper down 22 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/prometheus/prometheus-fabric.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 1s 3 | 4 | scrape_configs: 5 | - job_name: 'prometheus' 6 | honor_labels: true # Retain labels, as within PushGateway use 7 | static_configs: 8 | - targets: ['prometheus:9090', 'pushGateway:9091','peer0.org1.example.com:9000', 'peer0.org2.example.com:9000'] 9 | 10 | - job_name: cadvisor 11 | scrape_interval: 1s 12 | static_configs: 13 | - targets: ['cadvisor:8080'] 14 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/query.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const { WorkloadModuleBase } = require('@hyperledger/caliper-core'); 18 | 19 | /** 20 | * Workload module for querying the SUT for various marbles. 21 | */ 22 | class MarblesQueryWorkload extends WorkloadModuleBase { 23 | /** 24 | * Initializes the parameters of the marbles workload. 25 | */ 26 | constructor() { 27 | super(); 28 | this.txIndex = -1; 29 | this.owners = ['Alice', 'Bob', 'Claire', 'David']; 30 | } 31 | 32 | /** 33 | * Assemble TXs for querying existing marbles based on their owners. 34 | * @return {Promise} 35 | */ 36 | async submitTransaction() { 37 | this.txIndex++; 38 | let marbleOwner = this.owners[this.txIndex % this.owners.length]; 39 | 40 | let args = { 41 | contractId: this.txIndex % 2 === 0 ? 'mymarbles' : 'yourmarbles', 42 | contractFunction: 'queryMarblesByOwner', 43 | contractArguments: [marbleOwner], 44 | invokerIdentity: 'client0.org1.example.com', 45 | targetPeers: ['peer0.org1.example.com'], 46 | timeout: 10 47 | }; 48 | 49 | await this.sutAdapter.sendRequests(args); 50 | } 51 | } 52 | 53 | /** 54 | * Create a new instance of the workload module. 55 | * @return {WorkloadModuleInterface} 56 | */ 57 | function createWorkloadModule() { 58 | return new MarblesQueryWorkload(); 59 | } 60 | 61 | module.exports.createWorkloadModule = createWorkloadModule; 62 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/queryByChannel.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | const { WorkloadModuleBase } = require('@hyperledger/caliper-core'); 18 | 19 | /** 20 | * Workload module for querying the SUT for various marbles. 21 | */ 22 | class MarblesQueryByChannelWorkload extends WorkloadModuleBase { 23 | /** 24 | * Initializes the parameters of the marbles workload. 25 | */ 26 | constructor() { 27 | super(); 28 | this.txIndex = -1; 29 | this.owners = ['Alice', 'Bob', 'Claire', 'David']; 30 | } 31 | 32 | /** 33 | * Assemble TXs for querying existing marbles based on their owners. 34 | * @return {Promise} 35 | */ 36 | async submitTransaction() { 37 | this.txIndex++; 38 | let marbleOwner = this.owners[this.txIndex % this.owners.length]; 39 | 40 | let args = { 41 | contractId: this.txIndex % 2 === 0 ? 'mymarbles' : 'yourmarbles', 42 | contractVersion: 'v0', 43 | channel: this.txIndex % 2 === 0 ? 'mychannel' : 'yourchannel', 44 | contractFunction: 'queryMarblesByOwner', 45 | contractArguments: [marbleOwner], 46 | invokerIdentity: 'client0.org1.example.com', 47 | targetPeers: ['peer0.org1.example.com'], 48 | timeout: 10 49 | }; 50 | 51 | await this.sutAdapter.sendRequests(args); 52 | } 53 | } 54 | 55 | /** 56 | * Create a new instance of the workload module. 57 | * @return {WorkloadModuleInterface} 58 | */ 59 | function createWorkloadModule() { 60 | return new MarblesQueryByChannelWorkload(); 61 | } 62 | 63 | module.exports.createWorkloadModule = createWorkloadModule; 64 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/src/marbles/go/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hyperledger/fabric-samples/chaincode/marbles02/go 2 | 3 | go 1.21.0 4 | toolchain go1.24.1 5 | 6 | require ( 7 | github.com/hyperledger/fabric-chaincode-go v0.0.0-20240704073638-9fb89180dc17 8 | github.com/hyperledger/fabric-protos-go v0.3.3 9 | ) 10 | 11 | require ( 12 | github.com/golang/protobuf v1.5.4 // indirect 13 | golang.org/x/net v0.36.0 // indirect 14 | golang.org/x/sys v0.30.0 // indirect 15 | golang.org/x/text v0.22.0 // indirect 16 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240823204242-4ba0660f739c // indirect 17 | google.golang.org/grpc v1.65.0 // indirect 18 | google.golang.org/protobuf v1.34.2 // indirect 19 | ) 20 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/src/marbles/go/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= 4 | github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= 5 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= 6 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 7 | github.com/hyperledger/fabric-chaincode-go v0.0.0-20240704073638-9fb89180dc17 h1:SCsBjYLaoHCuyN6D3AAEX+YjBEnXn7MVpxn3rNX5gu4= 8 | github.com/hyperledger/fabric-chaincode-go v0.0.0-20240704073638-9fb89180dc17/go.mod h1:6R5/nmBVrNVvk76xqH30j/ecqphXD3zS6gCeYPKK4nk= 9 | github.com/hyperledger/fabric-protos-go v0.3.3 h1:0nssqz8QWJNVNBVQz+IIfAd2j1ku7QPKFSM/1anKizI= 10 | github.com/hyperledger/fabric-protos-go v0.3.3/go.mod h1:BPXse9gIOQwyAePQrwQVUcc44bTW4bB5V3tujuvyArk= 11 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 12 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 13 | github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= 14 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 15 | golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA= 16 | golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I= 17 | golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= 18 | golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 19 | golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= 20 | golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= 21 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240823204242-4ba0660f739c h1:Kqjm4WpoWvwhMPcrAczoTyMySQmYa9Wy2iL6Con4zn8= 22 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240823204242-4ba0660f739c/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= 23 | google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= 24 | google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= 25 | google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= 26 | google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= 27 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 28 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 29 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/fabric_tests/src/marbles/go/metadata/statedb/couchdb/indexes/indexOwner.json: -------------------------------------------------------------------------------- 1 | {"index":{"fields":["docType","owner"]},"ddoc":"indexOwnerDoc", "name":"indexOwner","type":"json"} 2 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/generator_tests/.gitignore: -------------------------------------------------------------------------------- 1 | fabric-samples 2 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/generator_tests/fabric/.gitignore: -------------------------------------------------------------------------------- 1 | **/*.log 2 | report.html 3 | 4 | **/myWorkspace/benchmarks 5 | 6 | vendor 7 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/generator_tests/fabric/.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-caliper-benchmarks": { 3 | "promptValues": { 4 | "subgenerator": "benchmark" 5 | }, 6 | "workspace": {} 7 | }, 8 | "generator-caliper": { 9 | "promptValues": { 10 | "subgenerator": "benchmark" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /packages/caliper-tests-integration/generator_tests/fabric/caliper.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | caliper: 16 | benchconfig: benchconfig.yaml 17 | networkconfig: networkconfig.yaml 18 | logging: 19 | template: '%timestamp%%level%%module%%message%%metadata%' 20 | formats: 21 | timestamp: 'YYYY.MM.DD-HH:mm:ss.SSS ZZ' 22 | label: false 23 | json: false 24 | pad: true 25 | align: false 26 | attributeformat: 27 | level: ' %attribute%' 28 | module: ' [%attribute%] ' 29 | metadata: ' (%attribute%)' 30 | colorize: 31 | all: true 32 | colors: 33 | info: green 34 | error: red 35 | warn: yellow 36 | debug: grey 37 | targets: 38 | console: 39 | target: console 40 | enabled: true 41 | options: 42 | level: info 43 | file: 44 | target: file 45 | enabled: false 46 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/generator_tests/fabric/myWorkspace/networkconfig.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | name: Fabric 16 | version: "2.0.0" 17 | 18 | caliper: 19 | blockchain: fabric 20 | sutOptions : 21 | mutualTls: true 22 | 23 | channels: 24 | - channelName: mychannel 25 | contracts: 26 | - id: mymarbles 27 | 28 | organizations: 29 | - mspid: Org1MSP 30 | identities: 31 | certificates: 32 | - name: 'admin.org1.example.com' 33 | admin: true 34 | clientPrivateKey: 35 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk' 36 | clientSignedCert: 37 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem' 38 | connectionProfile: 39 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/connection-org1.yaml' 40 | discover: true 41 | 42 | - mspid: Org2MSP 43 | identities: 44 | certificates: 45 | - name: 'admin.org2.example.com' 46 | admin: true 47 | clientPrivateKey: 48 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore/priv_sk' 49 | clientSignedCert: 50 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts/Admin@org2.example.com-cert.pem' 51 | connectionProfile: 52 | path: '../fabric-samples/test-network/organizations/peerOrganizations/org2.example.com/connection-org2.yaml' 53 | discover: true 54 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/generator_tests/fabric/src/marbles/go/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hyperledger/fabric-samples/chaincode/marbles02/go 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/hyperledger/fabric-chaincode-go v0.0.0-20220920210243-7bc6fa0dd58b 7 | github.com/hyperledger/fabric-protos-go v0.0.0-20220613214546-bf864f01d75e 8 | ) 9 | 10 | require ( 11 | github.com/golang/protobuf v1.5.2 // indirect 12 | golang.org/x/net v0.38.0 // indirect 13 | golang.org/x/sys v0.31.0 // indirect 14 | golang.org/x/text v0.23.0 // indirect 15 | google.golang.org/genproto v0.0.0-20220718134204-073382fd740c // indirect 16 | google.golang.org/grpc v1.48.0 // indirect 17 | google.golang.org/protobuf v1.33.0 // indirect 18 | ) 19 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/generator_tests/fabric/src/marbles/go/metadata/statedb/couchdb/indexes/indexOwner.json: -------------------------------------------------------------------------------- 1 | {"index":{"fields":["docType","owner"]},"ddoc":"indexOwnerDoc", "name":"indexOwner","type":"json"} 2 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/generator_tests/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -e 18 | set -o pipefail 19 | 20 | # Generator tests for Hyperledger Fabric 21 | generator_tests/fabric/run.sh 22 | -------------------------------------------------------------------------------- /packages/caliper-tests-integration/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -ev 18 | set -o pipefail 19 | 20 | # Barf if we don't recognize this test connector. 21 | if [[ "${BENCHMARK}" = "" ]]; then 22 | echo You must set BENCHMARK to one of the desired test adaptors 'fabric|generator' 23 | echo For example: 24 | echo export BENCHMARK=fabric 25 | exit 1 26 | fi 27 | 28 | TEST_DIR="${BENCHMARK}_tests" 29 | if [[ -d "${TEST_DIR}" ]]; then 30 | "${TEST_DIR}"/run.sh 31 | else 32 | echo "Unknown target benchmark ${BENCHMARK}" 33 | exit 1 34 | fi 35 | -------------------------------------------------------------------------------- /packages/generator-caliper/.editorconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | root = true 16 | 17 | [*] 18 | indent_style = space 19 | indent_size = 4 20 | end_of_line = lf 21 | charset = utf-8 22 | trim_trailing_whitespace = true 23 | insert_final_newline = true 24 | 25 | [*.md] 26 | trim_trailing_whitespace = false 27 | -------------------------------------------------------------------------------- /packages/generator-caliper/.eslintignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | coverage 16 | node_modules 17 | generators/benchmark/templates/workload.js -------------------------------------------------------------------------------- /packages/generator-caliper/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | node: true 4 | mocha: true 5 | extends: 'eslint:recommended' 6 | parserOptions: 7 | ecmaFeatures: 8 | experimentalObjectRestSpread: true 9 | ecmaVersion: 8 10 | sourceType: script 11 | rules: 12 | indent: 13 | - error 14 | - 4 15 | linebreak-style: 16 | - error 17 | - unix 18 | quotes: 19 | - error 20 | - single 21 | semi: 22 | - error 23 | - always 24 | no-unused-vars: 25 | - error 26 | - args: none 27 | no-console: 0 28 | curly: error 29 | eqeqeq: error 30 | no-throw-literal: error 31 | strict: error 32 | no-var: error 33 | dot-notation: error 34 | no-tabs: error 35 | no-trailing-spaces: error 36 | no-use-before-define: error 37 | no-useless-call: error 38 | no-with: error 39 | operator-linebreak: error 40 | require-jsdoc: 41 | - error 42 | - require: 43 | ClassDeclaration: true 44 | MethodDefinition: true 45 | FunctionDeclaration: true 46 | valid-jsdoc: 47 | - error 48 | - requireReturn: false 49 | yoda: error 50 | -------------------------------------------------------------------------------- /packages/generator-caliper/.npmignore: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | # hidden config files 16 | .editorconfig 17 | .eslintignore 18 | .eslintrc.yml 19 | 20 | # test directory 21 | test 22 | -------------------------------------------------------------------------------- /packages/generator-caliper/.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-node": { 3 | "promptValues": { 4 | "authorName": "Caliper", 5 | "authorEmail": "", 6 | "authorUrl": "https://github.com/hyperledger-caliper/caliper" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /packages/generator-caliper/README.md: -------------------------------------------------------------------------------- 1 | # generator-caliper 2 | 3 | A [Yeoman](http://yeoman.io) generator for scaffolding Hyperledger Caliper resources. Our generator currently generates: 4 | * Benchmark files: the benchmark configuration and callback files used to perform benchmarks. 5 | 6 | ## Getting started 7 | * Install: npm install -g @hyperledger/generator-caliper 8 | * Run: yo @hyperledger/caliper 9 | 10 | See the [documentation](https://hyperledger-caliper.github.io/caliper/vNext/benchmark-generator) for more information. 11 | -------------------------------------------------------------------------------- /packages/generator-caliper/generators/app/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | 'use strict'; 16 | 17 | let Generator = require('yeoman-generator'); 18 | 19 | module.exports = class extends Generator { 20 | /** 21 | * Prompts the user the question about the generator to use. 22 | * @async 23 | */ 24 | async prompting() { 25 | this.log('Welcome to the Hyperledger Caliper generator!'); 26 | const question = [{ 27 | type: 'list', 28 | name: 'subgenerator', 29 | message: 'Which generator would you like to run?', 30 | choices: [ 31 | {name: 'Benchmark', value: 'benchmark'} 32 | ], 33 | store: true, 34 | when: () => !this.options.subgenerator 35 | }]; 36 | const answers = await this.prompt(question); 37 | Object.assign(this.options, answers); 38 | } 39 | 40 | /** 41 | * Sets/configures the selected sub-generator. 42 | */ 43 | async configuring() { 44 | const { subgenerator } = this.options; 45 | this.log(`You can also run the ${subgenerator} generator using: yo @hyperledger/caliper:${subgenerator}\n`); 46 | this.composeWith(require.resolve(`../${subgenerator}`)); 47 | } 48 | }; 49 | -------------------------------------------------------------------------------- /packages/generator-caliper/generators/benchmark/templates/config.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | # See the License for the specific language governing permissions and 12 | # limitations under the License. 13 | # 14 | 15 | --- 16 | test: 17 | name: <%= benchmarkName %> 18 | description: <%= benchmarkDescription %> 19 | workers: 20 | number: <%= workers %> 21 | rounds: 22 | - label: <%= label %> 23 | contractId: <%= contractId %> 24 | <%= txType %>: <%= txValue %> 25 | rateControl: 26 | type: <%= rateController %> 27 | opts: { <%= opts %> } 28 | workload: 29 | module: benchmarks/workloads/<%= workload %> 30 | arguments: 31 | contractId: <%= contractId %> 32 | contractVersion: <%= contractVersion %> 33 | -------------------------------------------------------------------------------- /packages/generator-caliper/lib/generators/dummy.md: -------------------------------------------------------------------------------- 1 | # Needs investigation 2 | 3 | For some reason the yo generator integration tests fails unless lib/generators directory exists when moved to node18/20. -------------------------------------------------------------------------------- /scripts/changelog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright IBM Corp. All Rights Reserved. 4 | # 5 | # SPDX-License-Identifier: Apache-2.0 6 | # 7 | 8 | # 9 | # This script generates an updated CHANGELOG.md file containing all the 10 | # commits from the last release commit hash. It requires manual update 11 | # to include the entries in the Notable section 12 | # 13 | 14 | if [ $# -ne 2 ]; then 15 | echo 'Missing required arguments: lastReleaseCommitHash releaseVersion' >&2 16 | echo 'ex. ./changelog.sh bf94701285d29fb58806255682237b059b672f66 0.5.0' >&2 17 | exit 1 18 | fi 19 | 20 | echo "## $2 ($(date))\n" >> CHANGELOG.new 21 | echo "### Notable\n\n" >> CHANGELOG.new 22 | echo "### Commits\n" >> CHANGELOG.new 23 | git log $1..HEAD --oneline | grep -v Merge | sed -e "s/\([0-9|a-z]*\)/* \[\1\](https:\/\/github.com\/hyperledger\/caliper\/commit\/\1)/" >> CHANGELOG.new 24 | echo "" >> CHANGELOG.new 25 | cat CHANGELOG.md >> CHANGELOG.new 26 | mv -f CHANGELOG.new CHANGELOG.md -------------------------------------------------------------------------------- /scripts/check-package-names.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # publishNpmPackages.js contains the package dir names as caliper-*, those are fine 4 | if grep -rnE --exclude-dir=".idea" --exclude-dir="caliper-publish" --exclude-dir="coverage" "['\"]caliper-(cli|core|fabric)['\"]" . ; then 5 | echo "^^^ Found incorrect Caliper package names. Use the @hyperledger/ prefix for Caliper packages, e.g., @hyperledger/caliper-core" 6 | exit 1 7 | else 8 | echo "Caliper package names are correct." 9 | exit 0 10 | fi 11 | -------------------------------------------------------------------------------- /scripts/force-clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | rm -rf ./node_modules 18 | 19 | rm -rf ./packages/caliper-cli/node_modules 20 | rm -rf ./packages/caliper-core/node_modules 21 | rm -rf ./packages/caliper-fabric/node_modules 22 | rm -rf ./packages/caliper-publish/node_modules 23 | rm -rf ./packages/caliper-tests-integration/node_modules 24 | rm -rf ./packages/generator-caliper/node_modules 25 | 26 | git checkout -- ./packages/caliper-fabric/package.json 27 | -------------------------------------------------------------------------------- /scripts/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | # Exit on first error, print all commands. 17 | set -e 18 | set -o pipefail 19 | 20 | # Run linting, license check and unit tests 21 | npm test 22 | 23 | # Call CLI directly 24 | # The CWD will be in one of the caliper-tests-integration/*_tests directories 25 | export CALL_METHOD="node ../../caliper-cli/caliper.js" 26 | 27 | IFS=' ' read -r -a array <<< "${TESTS}" 28 | 29 | cd ./packages/caliper-tests-integration/ 30 | 31 | for element in "${array[@]}" 32 | do 33 | export BENCHMARK="${element}" 34 | ./run-tests.sh 35 | done 36 | --------------------------------------------------------------------------------