Skip to content

Latest commit

 

History

History
 
 

integration

Integration and Feature Testing

Ginkgo

Ginkgo is a package used for Behavior Driven Development (BDD) testing. Ginkgo uses Golang's existing testing package.

Full documentation and usage examples for Ginkgo can be found in the online documentation.

BDD is an agile software development technique that encourages collaboration between developers, QA, and non-technical or business participants in a software project. Feel free to read more about BDD.

This directory contains implementations of integration and feature testing for Hyperledger Fabric.

Pre-requisites

You must have the following installed:
$ go get github.com/onsi/ginkgo/ginkgo

Ensure that you have Docker for Linux, Mac or Windows 1.12 or higher properly installed on your machine.

Caveats, Gotchas, and Good-To-Knows

  • The tests in this repository only exercise components that originate in the Fabric repository.
  • Currently, docker is only used in the ginkgo tests when using chaincode, kafka, zookeeper, or couchdb images.

Getting Started

The current ginkgo based tests perform some setup for you. The peer and orderer images as well as tools such as configtxgen and cryptogen are built during the setup of the tests. The config files are also generated based on the test setup.

Developers who add integration tests are responsible for adding and updating the necessary helper tools and functionalities.

When adding a new test, determine if it makes more sense to mock any aspect of what you are trying to accomplish. If you need to verify that the actual interfaces between components work as expected, the ginkgo tooling will be the direction to go. (Hint: mocked interfaces allow more focused testing and run faster.)

The "integration/" directory contains tests that will use multiple components from this repository. These tests include ensuring that transactions move through the Fabric system correctly.

The "integration/chaincode" directory contains the different chaincodes that are currently available for use in these tests.

The "integration/e2e" directory contains tests for different scenarios with different setups. If the desired test scenario setup is the same as a test that is already defined ("Describe"), use the same setup. If there is no need for a new network to be defined, add a new test case ("It") that can use an existing network setup. If the setup needs to be altered, add a new setup ("Describe"). Please be sure to add a short description of what your setup is and how it is different from the existing setup.

How to execute

The integration tests can be executed by using the ginkgo command or go test ./...

cd integration; go test ./...

Local Execution

When executing the ginkgo tests locally, there are some simple commands that may be useful.

Executes all tests in directory

$ ginkgo

Executes all tests in current directory recursively

$ ginkgo -r

Executes tests that contain the specified string from descriptions

$ ginkgo -focus <some string>

For example, ginkgo -r -focus "2 orgs" executes the tests with the string "2 orgs" in the description.

Continuous Integration (CI) Execution

There is a target in the Hyperledger Fabric Makefile for executing integration tests.

To execute the integration tests using the Makefile, execute the following:

make integration-test

Contributing

There are different ways to contribute in this area.
  • Writing helper functions
  • Writing test code

To add your contributions to the Hyperledger Fabric project, please refer to the Hyperledger Fabric Contribution page for more details.