github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/bddtests/regression/go/ote/README.md (about)

     1  # Orderer Traffic Engine (OTE)
     2  
     3  ## What does OTE do?
     4  
     5  + This Orderer Traffic Engine (OTE) tool creates and tests the operation of a
     6  hyperledger fabric ordering service.
     7  + The focus is strictly on the orderers themselves.
     8  No peers are involved: no endorsements or validations or committing to ledgers.
     9  No SDK is used.
    10  
    11  + OTE sends transactions to
    12  every channel on every orderer, and verifies that the correct number
    13  of transactions and blocks are delivered on every channel from every orderer.
    14  + OTE generates report logs and returns
    15  a pass/fail boolean and a resultSummaryString.
    16  
    17  ## How does OTE do it?
    18  
    19  + OTE invokes a local copy of the tool driver.sh (including helper files
    20  network.json and json2yml.js) -
    21  which is a close copy of the original version at
    22  https://github.com/dongmingh/v1FabricGenOption.
    23  + The driver.sh launches an orderer service network per the user-provided
    24  parameters including number of orderers, orderer type,
    25  number of channels, and more.
    26  + Producer clients are created to connect via
    27  grpc ports to the orderers to concurrently send traffic until the
    28  requested number of transactions are sent.
    29  Each client generates unique transactions - a fraction of the total
    30  requested number of transactions.
    31  + Consumer clients are created to connect via
    32  grpc ports to the orderers to concurrently receive delivered traffic
    33  until all batches of transactions are tallied.
    34  OTE checks if the correct number of blocks and TXs are delivered
    35  by all the orderers on all the channels
    36  
    37  ## Prerequisites
    38  - <a href="https://git-scm.com/downloads" target="_blank">Git client</a>
    39  - <a href="https://www.docker.com/products/overview" target="_blank">Docker v1.12 or higher</a>
    40  - [Docker-Compose v1.8 or higher](https://docs.docker.com/compose/overview/)
    41  - GO
    42  
    43  Check your Docker and Docker-Compose versions with the following commands:
    44  ```bash
    45      docker version
    46      docker-compose version
    47  ```
    48  
    49  ### Prepare binaries and images:
    50  
    51  - Alternative 1: Prepare all binaries and images using a script
    52  ```bash
    53        cd $GOPATH/src/github.com/hyperledger/fabric/bddtests/regression/ote
    54        ./docker_images.sh
    55  ```
    56  
    57  - Alternative 2: Prepare binaries and images manually
    58  - - Clone the fabric repository, build the binaries and images
    59  ```bash
    60          cd $GOPATH/src/github.com/hyperledger/fabric
    61          make native docker
    62  ```
    63  - - Clone the fabric-ca repository, build the images
    64  ```bash
    65          cd $GOPATH/src/github.com/hyperledger/
    66  
    67          # Use ONE of these methods to clone the repository:
    68              go get github.com/hyperledger/fabric-ca
    69              git clone https://github.com/hyperledger/fabric-ca.git
    70              git clone ssh://YOUR-ID@gerrit.hyperledger.org:29418/fabric-ca
    71  
    72          cd $GOPATH/src/github.com/hyperledger/fabric-ca
    73          make docker
    74  ```
    75  
    76  ### Environment Variables for test setup, with defaults:
    77  ```
    78    OTE_TXS                                      55
    79    OTE_CHANNELS                                 1
    80    OTE_ORDERERS                                 1
    81    OTE_KAFKABROKERS                             0
    82    OTE_MASTERSPY                                false
    83    OTE_PRODUCERS_PER_CHANNEL                    1
    84  ```
    85  
    86  ### Environment Variables for configuration
    87  Find default values of all variables in hyperledger/fabric/sampleconfig/orderer.yaml
    88  and hyperledger/fabric/sampleconfig/core.yaml.
    89  ```
    90    CONFIGTX_ORDERER_ORDERERTYPE                 solo
    91    CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT   10
    92    CONFIGTX_ORDERER_BATCHTIMEOUT                10
    93  
    94    Others:
    95    CORE_LOGGING_LEVEL                           <unset>
    96    CORE_LEDGER_STATE_STATEDATABASE              leveldb
    97    CORE_SECURITY_LEVEL                          256
    98    CORE_SECURITY_HASHALGORITHM                  SHA2
    99  ```
   100  
   101  ## Execute OTE on shell command line
   102  There are several environment variables to control the test parameters,
   103  such as number of transactions, number of orderers, ordererType, and more.
   104  To see an example test using default settings, simply execute the following.
   105  ```bash
   106    cd $GOPATH/src/github.com/hyperledger/fabric/bddtests/regression/ote
   107    go build
   108    ./ote
   109    CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT=20 ./ote
   110    OTE_TXS=100  OTE_CHANNELS=4  ./ote
   111    CONFIGTX_ORDERER_ORDERERTYPE=kafka OTE_KAFKABROKERS=3  ./ote
   112  ```
   113  
   114  Choose which variables to modify from default values. For example:
   115  
   116  + This test will create eight Producer clients.
   117  + Each Producer will send 125 transactions to a different orderer and channel.
   118  + 250 total TXs will be broadcast on each channel.
   119  + 500 total TXs will be broadcast to each orderer.
   120  + Four Consumer clients will be created to receive the delivered
   121    batches on each channel on each orderer.
   122  + 50 batches (with 10 TX each) will be delivered on channel 0, and
   123    a different 50 batches will be delivered on channel 1. On both Orderers.
   124  + 100 batches will be received on every orderer; this is the sum of the
   125    totals received on each channel on the orderer.
   126  ```bash
   127    OTE_TXS=1000 OTE_CHANNELS=4 OTE_ORDERERS=2 CONFIGTX_ORDERER_ORDERERTYPE=kafka  ./ote
   128  ```
   129  
   130  ## Execute OTE GO Tests
   131  The tester may optionally define environment variables to
   132  set the test parameters and to
   133  override certain orderer configuration parameters.
   134  Then use "go test" to execute Test functions
   135  to execute either one test, or all go tests, or
   136  a subset of existing functional go tests using a regular expression
   137  to choose tests in local test files.
   138  ```bash
   139    cd $GOPATH/src/github.com/hyperledger/fabric/bddtests/regression/ote
   140    go test -run ORD77
   141    go test -run ORD7[79]
   142    go test -run batchSz -timeout 20m
   143    go test -timeout 90m
   144  
   145    go get github.com/jstemmer/go-junit-report
   146    go test -run ORD7 -v | go-junit-report > report.xml
   147  
   148  ```
   149  
   150  ## Execute OTE GO Tests for Continuous Improvement
   151  Optionally, one can translate the "go test" output to xml for reports.
   152  This is useful for automated test suites that are automatically
   153  executed from Jenkins by Continuous Improvement processes.
   154  
   155  #### Pre-requisite to convert "go test" output to xml
   156  ```bash
   157    cd $GOPATH/src/github.com/hyperledger/fabric/bddtests/regression/ote
   158    go get github.com/jstemmer/go-junit-report
   159  ```
   160  #### Example command to execute all "go tests" and convert to xml:
   161  ```
   162    cd $GOPATH/src/github.com/hyperledger/fabric/bddtests/regression/ote
   163    go test -v -timeout 120m | go-junit-report > ote_report.xml
   164  ```