github.com/sykesm/fabric@v1.1.0-preview.0.20200129034918-2aa12b1a0181/integration/README.rst (about)

     1  Integration and Feature Testing
     2  ====================================
     3  Ginkgo
     4  --------
     5  Ginkgo is a package used for Behavior Driven Development (BDD) testing. Ginkgo uses Golang's existing
     6  testing package.
     7  
     8  Full documentation and usage examples for Ginkgo can be found in the `online documentation`_.
     9  
    10  .. _online documentation: http://onsi.github.io/ginkgo/
    11  
    12  
    13  BDD is an agile software development technique that encourages collaboration between developers, QA,
    14  and non-technical or business participants in a software project. Feel free to read more about `BDD`_.
    15  
    16  .. _BDD: https://semaphoreci.com/community/tutorials/getting-started-with-bdd-in-go-using-ginkgo
    17  
    18  
    19  This directory contains implementations of integration and feature testing for Hyperledger Fabric.
    20  
    21  
    22  Pre-requisites
    23  --------------
    24  You must have the following installed:
    25      * `go`_
    26      * `docker`_
    27      * `docker-compose`_
    28  
    29  ::
    30  
    31      $ go get github.com/onsi/ginkgo/ginkgo
    32  
    33  Ensure that you have Docker for `Linux`_, `Mac`_ or `Windows`_ 1.12 or higher properly installed on
    34  your machine.
    35  
    36  .. _go: https://golang.org/
    37  .. _docker: https://www.docker.com/
    38  .. _docker-compose: https://docs.docker.com/compose/
    39  .. _Linux: https://docs.docker.com/engine/installation/#supported-platforms
    40  .. _Mac: https://docs.docker.com/engine/installation/mac/
    41  .. _Windows: https://docs.docker.com/engine/installation/windows/
    42  
    43  
    44  Caveats, Gotchas, and Good-To-Knows
    45  -----------------------------------
    46  * The tests in this repository only exercise components that originate in the Fabric repository.
    47  * Currently, docker is only used in the ginkgo tests when using chaincode, kafka, zookeeper,
    48    or couchdb images.
    49  
    50  
    51  Getting Started
    52  ---------------
    53  The current ginkgo based tests perform some setup for you. The peer and orderer images as well as
    54  tools such as configtxgen and cryptogen are built during the setup of the tests. The config files
    55  are also generated based on the test setup.
    56  
    57  Developers who add integration tests are responsible for adding and updating the necessary helper
    58  tools and functionalities.
    59  
    60  When adding a new test, determine if it makes more sense to mock any aspect of what you are trying
    61  to accomplish. If you need to verify that the actual interfaces between components work as expected,
    62  the ginkgo tooling will be the direction to go. (Hint: mocked interfaces allow more focused testing
    63  and run faster.)
    64  
    65  The "integration/" directory contains tests that will use multiple components from this repository.
    66  These tests include ensuring that transactions move through the Fabric system correctly.
    67  
    68  The "integration/chaincode" directory contains the different chaincodes that are currently available
    69  for use in these tests.
    70  
    71  The "integration/e2e" directory contains tests for different scenarios with different setups. If the
    72  desired test scenario setup is the same as a test that is already defined ("Describe"), use the same
    73  setup. If there is no need for a new network to be defined, add a new test case ("It") that can use
    74  an existing network setup. If the setup needs to be altered, add a new setup ("Describe"). Please be
    75  sure to add a short description of what your setup is and how it is different from the existing
    76  setup.
    77  
    78  
    79  ==============
    80  How to execute
    81  ==============
    82  The integration tests can be executed by using the ``ginkgo`` command or ``go test ./...``
    83  
    84  
    85  ::
    86  
    87      cd integration; go test ./...
    88  
    89  Local Execution
    90  ---------------
    91  When executing the ginkgo tests locally, there are some simple commands that may be useful.
    92  
    93  **Executes all tests in directory**
    94  ::
    95  
    96      $ ginkgo
    97  
    98  **Executes all tests in current directory recursively**
    99  ::
   100  
   101      $ ginkgo -r
   102  
   103  **Executes tests that contain the specified string from descriptions**
   104  ::
   105  
   106      $ ginkgo -focus <some string>
   107  
   108  For example, `ginkgo -r -focus "2 orgs"` executes the tests with the string "2 orgs" in the
   109  description.
   110  
   111  
   112  Continuous Integration (CI) Execution
   113  -------------------------------------
   114  There is a target in the Hyperledger Fabric Makefile for executing `integration`_ tests.
   115  
   116  .. _integration: https://jenkins.hyperledger.org/view/fabric/job/fabric-verify-integration-tests-x86_64
   117  
   118  To execute the integration tests using the Makefile, execute the following:
   119  
   120  ::
   121  
   122      make integration-test
   123  
   124  
   125  ============
   126  Contributing
   127  ============
   128  There are different ways to contribute in this area.
   129   * Writing helper functions
   130   * Writing test code
   131  
   132  To add your contributions to the Hyperledger Fabric project, please refer to the
   133  `Hyperledger Fabric Contribution`_ page for more details.
   134  
   135  .. _Hyperledger Fabric Contribution: http://hyperledger-fabric.readthedocs.io/en/latest/CONTRIBUTING.html
   136  
   137  
   138  .. Licensed under Creative Commons Attribution 4.0 International License
   139     https://creativecommons.org/licenses/by/4.0/