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

     1  ## tdk
     2  Hyperledger Fabric Go language Test Development Kit (TDK): tests, scripts, and
     3  supporting framework for testing hyperledger/fabric
     4  
     5  ## SETUP
     6  
     7  ###Obtain the TDK and test programs:
     8  In v1.0, find them within hyperledger/fabric repository.
     9  
    10          $ cd .../fabric/bddtests/regression/go/tdk
    11          $ git checkout master
    12  
    13  In v0.6, clone from private repo to the src directory where GO is
    14  installed (use either $GOROOT/src or $GOPATH/src).
    15  
    16          $ cd $GOPATH/src
    17          $ git clone https://github.ibm.com/IBM-Blockchain/release-criteria
    18          $ cd release-criteria/fvt/consensus
    19          $ git checkout v0.6
    20  
    21  Bash scripts local_fabric_gerrit.sh and others will create docker containers
    22  to run the peers. For more information on setting up a peer network,
    23  [read these instructions] (https://github.com/rameshthoomu/fabric1/blob/tools/localpeersetup/local_Readme.md)
    24  
    25  ## USAGE
    26  
    27  ###How to execute the programs:
    28  - If you wish to connect to an existing network, change the credentials in
    29    NetworkCredentials.json as needed.
    30  - Helpful shell scripts are located in the tdk/automation directory:
    31  ```
    32          ../automation/go_record.sh <tests.go>   - execute this from any of the
    33          test directories, to run go tests and record stdout logs in unique
    34          GO_TEST* named files in the current working directory.
    35  ```
    36  - LOGFILES for all Peers can be saved in the automation directory by
    37    uncommenting a few lines in the local_fabric_gerrit.sh script. (Search for
    38    LOGFILE.) Execute go_record.sh (or local_fabric.sh or similar script) without
    39    parameters to get help with the options to control the log detail level.
    40  - Go to the test directories and execute the tests. Good luck!
    41  ```
    42          #  Examples how you can preload some of the environment vars for local
    43          #  vagrant/docker network testing:
    44          $  .   ../automation/ENVVARS_LOCAL
    45          $  .   ../automation/ENVVARS_Z
    46          # OR, for HSBN/BlueMix network:
    47          $  .   ../automation/ENVVARS_Z
    48          $  export COMMIT=<commit>
    49  
    50          # To run a basic test to create a 4-peer network and exercise the
    51          # REST API functionalities:
    52          $ cd tdk/chcotest
    53          $ go run BasicFuncNewNetwork.go
    54  
    55          # To run Consensus Acceptance Tests or two of the long-run tests:
    56          $ cd tdk/CAT
    57          $ ../automation/go_record.sh CAT*go
    58          $ ../automation/go_record.sh CRT_501_StopAndRestartRandom_10Hrs.go
    59          $ ../automation/go_record.sh CRT_502_StopAndRestart1or2_10Hrs.go
    60  
    61          # To run ledger stress tests: After first starting up a new network by
    62          # running a test that creates and uses a networkcredentials file
    63          # (which maps to tdk/util/NetworkCredentials.json),
    64          # simply run these tests by:
    65          $ cd tdk/CAT
    66          $ go run testtemplate.go
    67          $ cd tdk/ledgerstresstest
    68          $ TEST_NETWORK=LOCAL go run LST_2Client2Peer20K.go
    69  
    70          # Or, here is the easiest way to run the basic API test and five
    71          # concurrency testcases in this directory:
    72          $ cd tdk/ledgerstresstest
    73          $ ./run_LST_regression.sh
    74  
    75          # To run COMMIT=821a3c7, the v0.6 Sep 7th build, in local environment
    76          # with one of these commands:
    77          $ cd tdk/automation
    78          $ ./local_fabric_gerrit.sh -c 821a3c7 -n 4 -f 1 -l error -m pbft -b 500 -s
    79          $ export COMMIT=821a3c7; export REPOSITORY_SOURCE=GERRIT
    80          $ go_record.sh ../CAT/testtemplate.go ../chcotest/BasicFuncNewNetwork.go
    81  ```
    82  ###Running tests on remote network requires some tweaking to make things run.
    83  - Put the IP address info of the peers into the util/NetworkCredentials.json;
    84    use script update_z.py to help generate that file for BlueMix networks.
    85  - Set environment variable TEST_NET_COMM_PROTOCOL to use HTTPS instead of
    86    default HTTP; required for Ledger Stress Tests on Z network, and may also
    87    be useful when running other tests in other networks that could use HTTPS,
    88  - Define its own usernames/passwords (may need to edit threadutil/threadutil.go)
    89  - (Ledger Stress Tests only): Set environment variable TEST_NETWORK to Z when
    90    using the Z network and its usernames/passwords
    91  - (Ledger Stress Tests only): set the correct chaincode name in lstutil/util.go
    92    to change it from "mycc" (a special version of example02 that adds payloads
    93    records the ledger, instead of just changing the values of A and B) to
    94    whatever is deployed on the actual Z network you are using. Before running
    95    any tests, rebuild:  "cd ledgerstresstest; ../automation/go_build_all.sh"
    96  ```
    97          # For example:
    98  
    99          $ cd ../CAT; TEST_NET_COMM_PROTOCOL=HTTPS go run CAT_101*.go
   100  
   101          # To run tests with example02 in BlueMix network on
   102          # v.5 (COMMIT=3e0e80a) or v.6 (COMMIT=821a3c7),
   103          # download the ServiceCredentials from BlueMix and run script
   104          # update_z.py to generate the networkcredentials file for the
   105          # Z or Starter or HSBN network; then try one of:
   106  
   107          $ ./update_z.py -b -f <service_credentials_file>
   108          $ cp networkcredentials ../util/NetworkCredentials.json
   109          $ export TEST_NET_COMM_PROTOCOL=HTTPS; export TEST_NETWORK=Z
   110          $     export COMMIT=821a3c7; export REPOSITORY_SOURCE=GERRIT
   111          #   OR
   112          $     export COMMIT=3e0e80a; export REPOSITORY_SOURCE=GITHUB
   113          $ go run ../chcotest/BasicFuncExistingNetwork.go;
   114          $ go_record.sh ../CAT/testtemplate.go
   115  
   116          # To run ledger stress tests with a different chaincode named
   117          # example02_addrecs, which is a modified version of example02,
   118          # in BlueMix network on v05 or v06:
   119          $ cd ../ledgerstresstest
   120          $ export TEST_NETWORK=Z ; export TEST_NET_COMM_PROTOCOL=HTTPS
   121          $ go run BasicFuncExistingNetworkLST.go
   122          $ go run LST_1Client1Peer20K.go
   123  ```