Skip to content

Commit 7b36d96

Browse files
committed
[FAB-4091] Update ledger benchmarking tool
Renaming the test tool to LTE (Ledger Traffic Engine), including a readme for the tool, changing the test driver to take arguments on which tests to run, separating the parameters to a different file. Change-Id: I51f9d95d9979950214c75e572fccdda794b11ff3 Signed-off-by: Adnan Choudhury <[email protected]>
1 parent 61d7968 commit 7b36d96

16 files changed

+172
-40
lines changed

test/tools/LTE/README.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Ledger Traffic Engine
2+
3+
This readme explains the working and the usage of Ledger Traffic Engine (LTE
4+
test tool.
5+
6+
7+
- What is the LTE Test Tool
8+
- How to Run the Tests
9+
- Where to View the Results
10+
11+
## What is the LTE Test Tool
12+
13+
The LTE test tool is test harness that engages the Ledger APIs and benchmarks
14+
the performance of the Ledger component. It contains the framework for creating
15+
and managing chains, for transaction submission, block creation, and block
16+
commit. It conducts benchmark tests for insert and read-write transactions
17+
(transactions per second) and contains scripts for launching the benchmarks. An
18+
insert benchmark followed by a readwrite benchmark on the same dataset is
19+
considered to constitute a single test-run.
20+
21+
22+
## How to Run The tests
23+
24+
To run all the available tests with default parameters, run:
25+
```
26+
cd fabric/test/tools/LTE/scripts
27+
./runbenchmark.sh all
28+
```
29+
you can run individual tests without running all the available tests by giving
30+
the name of the test as parameter, instead of `all`. You can get the available
31+
test names by:
32+
```
33+
./runbenchmark.sh help
34+
```
35+
36+
### What the Tests Do
37+
38+
Each test reads test parameters from the file `parameters_daily_CI.sh` and
39+
conducts several test-runs by varying one or two of the parameters. The
40+
parameters are:
41+
* number of chains (ledger),
42+
* number of parallel transactions in each chain,
43+
* number of Key-value pairs,
44+
* number of transactions,
45+
* number of keys in each transaction,
46+
* size of batch for ledger,
47+
* size of Key-value
48+
49+
For example, the *varyNumChains* test reads the parameters and varies the
50+
number of chains for each test-run while keeping the other parameters constant,
51+
and generate result. Varying a specific parameter for each test-runs gives
52+
insight into the parameter's influence on the Ledger performance.
53+
54+
Each test-run consists of two phases: benchmarking of ledger insert phase and
55+
benchmarking of ledger read-write phase.
56+
57+
#### Insert Phase
58+
59+
The insert benchmark starts fresh chains and inserts the Key-values by
60+
simulating writes-only transactions For each of the chains. It launches the
61+
parallel clients (based on the configuration) and the clients simulate and
62+
commit write-only transactions. The keys are divided among clients such that
63+
one key is written only once and all the keys are inserted. For instance, if
64+
this benchmark is invoked with the following parameters:
65+
```
66+
Number of chains=2,
67+
Number of parallel transactions per chain=2,
68+
Number of key-value pairs=100
69+
```
70+
then client_1 on chain_1 will insert Key_1 to key_25 and client_2 on chain_1 will
71+
insert Key_26 to key_50. Similarly client_3 on chain_2 will insert Key_1 to
72+
key_25 and client_4 on chain_2 will insert Key_26 to key_50 where, client_1 and
73+
client_2 run in parallel on chain_1 and client_3 and client_4 run in parallel
74+
on chain_2.
75+
76+
#### Read-write Phase
77+
78+
Subsequently, the Read-write benchmark step opens the existing chains and
79+
modifies the Key-values by simulating read-write transactions For each of the
80+
chains. It launches the parallel clients (based on the configuration) and the
81+
clients simulate and commit read-write transactions. This test assumes the
82+
pre-populated chain by previously running insert benchmark step (described
83+
above). Each transaction simulated by this benchmark randomly selects a
84+
configurable number of keys and modifies their values. For instance, if this
85+
benchmark is invoked with the following test parameters:
86+
```
87+
Number of chains=2,
88+
Number of parallel transactions per chain=2,
89+
Number of key-value pairs=100,
90+
Number of total transactions=200
91+
```
92+
then client_1, and client_2 both execute 50 transactions on
93+
chain_1 in parallel. Similarly, client_3, and client_4 both execute 50
94+
transactions on chain_2 in parallel In each of the transactions executed by any
95+
client, the transaction expects and modifies any key(s) between Key_1 to key_50
96+
(because, total keys are to be 100 across two chains).
97+
98+
## How to View the Test Results
99+
100+
The test results can be viewed as in the stdout where it shows how long each
101+
single operation took to complete in a test. These results are also saved in a
102+
.csv file in the following directory: `/tmp/fabric/test/tools/LTE/results`

test/tools/ledgerbenchmarks/chainmgmt/block_gen.go test/tools/LTE/chainmgmt/block_gen.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
"github.com/golang/protobuf/proto"
2323
"github.com/hyperledger/fabric/protos/common"
24-
benchcommon "github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/common"
24+
benchcommon "github.com/hyperledger/fabric/test/tools/LTE/common"
2525
)
2626

2727
const (

test/tools/ledgerbenchmarks/chainmgmt/chains.go test/tools/LTE/chainmgmt/chains.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/hyperledger/fabric/core/ledger"
2525
"github.com/hyperledger/fabric/core/ledger/ledgermgmt"
2626
"github.com/hyperledger/fabric/protos/common"
27-
benchcommon "github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/common"
27+
benchcommon "github.com/hyperledger/fabric/test/tools/LTE/common"
2828
)
2929

3030
// ChainID is a type used for the ids for the chains for experiments
File renamed without changes.
File renamed without changes.

test/tools/ledgerbenchmarks/experiments/conf.go test/tools/LTE/experiments/conf.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package experiments
1919
import (
2020
"flag"
2121

22-
"github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/chainmgmt"
22+
"github.com/hyperledger/fabric/test/tools/LTE/chainmgmt"
2323
)
2424

2525
// txConf captures the transaction related configurations

test/tools/ledgerbenchmarks/experiments/insert_txs_test.go test/tools/LTE/experiments/insert_txs_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222

2323
"fmt"
2424

25-
"github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/chainmgmt"
26-
"github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/common"
25+
"github.com/hyperledger/fabric/test/tools/LTE/chainmgmt"
26+
"github.com/hyperledger/fabric/test/tools/LTE/common"
2727
)
2828

2929
// BenchmarkInsertTxs starts fresh chains and inserts the Key-values by simulating writes-only transactions

test/tools/ledgerbenchmarks/experiments/readwrite_txs_test.go test/tools/LTE/experiments/readwrite_txs_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
"testing"
2424
"time"
2525

26-
"github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/chainmgmt"
27-
"github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/common"
26+
"github.com/hyperledger/fabric/test/tools/LTE/chainmgmt"
27+
"github.com/hyperledger/fabric/test/tools/LTE/common"
2828
)
2929

3030
// BenchmarkReadWriteTxs opens the existing chains and modifies the Key-values by simulating read-write transactions

test/tools/ledgerbenchmarks/scripts/benchmarks.sh test/tools/LTE/scripts/benchmarks.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ source ./common.sh
1111
# This shell script contains two functions that can be invoked to execute specific tests
1212
#
1313
# runInsertTxs - This function sets the environment variables and runs the benchmark function
14-
# 'BenchmarkInsertTxs' in package 'github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/experiments'
14+
# 'BenchmarkInsertTxs' in package 'github.com/hyperledger/fabric/test/tools/LTE/experiments'
1515
#
1616
# runReadWriteTxs - This function sets the environment variables and runs the benchmark function
17-
# 'BenchmarkReadWriteTxs' in package 'github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/experiments'
17+
# 'BenchmarkReadWriteTxs' in package 'github.com/hyperledger/fabric/test/tools/LTE/experiments'
1818
#
1919
# For the details of test specific parameters, refer to the documentation in 'go' files for the tests
2020
#######################################################################################################
2121

22-
PKG_NAME="github.com/hyperledger/fabric/test/tools/ledgerbenchmarks/experiments"
22+
PKG_NAME="github.com/hyperledger/fabric/test/tools/LTE/experiments"
2323

2424
function setCommonTestParams {
2525
TEST_PARAMS="-DataDir=$DataDir, -NumChains=$NumChains, -NumParallelTxPerChain=$NumParallelTxPerChain, -NumKeysInEachTx=$NumKeysInEachTx, -BatchSize=$BatchSize, -NumKVs=$NumKVs, -KVSize=$KVSize"

test/tools/ledgerbenchmarks/scripts/common.sh test/tools/LTE/scripts/common.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,26 @@ set -e
1919
# FUNCTION_NAME - Name of the Benchmark function
2020
# TEST_PARAMS - Parameters for the test
2121
# RESULTANT_DIRS - An optional list of dirs whose size needs to be captured in the results in the RESULTS_FILE
22-
#
23-
# The default values for some of the above variables are set in this script and can be overrideen by a test specific
24-
# script. For remaining variables, a test specific script needs to set the appropriate values before calling the
22+
#
23+
# The default values for some of the above variables are set in this script and can be overridden by a test specific
24+
# script. For remaining variables, a test specific script needs to set the appropriate values before calling the
2525
# function 'executeTest' of this script
26-
#
26+
#
2727
# The result file for a test gets created in a csv format in the folder
2828
# $OUTPUT_DIR_ROOT/<last_element_of>$PKG_NAME<segment>/$FUNCTION_NAME
2929
#############################################################################################################################
3030

3131

32-
OUTPUT_DIR_ROOT=`echo /tmp/fabric/test/tools/ledgerbenchmarks/results`
32+
OUTPUT_DIR_ROOT=`echo /tmp/fabric/test/tools/LTE/results`
3333
RAW_OUTPUT_FILE="output.txt"
3434
RESULTS_FILE="results.csv"
3535

3636
benchmarkLineRegex="^Benchmark.*[[:blank:]]+[[:digit:]]+[[:blank:]]+([[:digit:]]+).*$"
3737
testParamRegex="-\([^=]*\)=\([^,]*\)"
3838

39-
ulimit -n 10000
40-
echo "ulimit=`ulimit -n`"
39+
echo "**Note**: This is a Benchmark test. Please make sure to set an appropriate value for ulimit in your OS."
40+
echo "Recommended value is 10000 for default parameters."
41+
echo "Current ulimit=`ulimit -n`"
4142
TESTS_SETUP_DONE=()
4243

4344
## Execute test and generate data file
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
DataDir="/tmp/fabric/test/tools/LTE/data"
4+
NumChains=10
5+
NumParallelTxPerChain=10
6+
NumKVs=1000000
7+
NumTotalTx=1000000
8+
NumKeysInEachTx=4
9+
BatchSize=50
10+
KVSize=200
11+

test/tools/ledgerbenchmarks/scripts/runbenchmarks.sh test/tools/LTE/scripts/runbenchmarks.sh

+41-23
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,49 @@
66
#
77

88
source ./benchmarks.sh
9+
source ./parameters_daily_CI.sh
910

1011
########################################################################################################
11-
# This shell script invokes a series of benchmark tests with desired values of test specific parameters
12+
# This shell script contains a series of benchmark tests
13+
# The test parameters are imported from "parameters_daily_CI.sh"
1214
########################################################################################################
1315

14-
function setDefaultTestParams {
15-
DataDir="/tmp/fabric/test/tools/ledgerbenchmarks/data"
16-
NumChains=10
17-
NumParallelTxPerChain=10
18-
NumKVs=1000000
19-
NumTotalTx=1000000
20-
NumKeysInEachTx=4
21-
BatchSize=50
22-
KVSize=200
23-
}
24-
2516
function varyNumParallelTxPerChain {
26-
setDefaultTestParams
2717
for v in 1 5 10 20 50 100 500 2000; do
2818
NumParallelTxPerChain=$v
2919
rm -rf $DataDir;runInsertTxs;runReadWriteTxs
3020
done
3121
}
3222

3323
function varyNumChains {
34-
setDefaultTestParams
3524
for v in 1 5 10 20 50 100 500 2000; do
3625
NumChains=$v
3726
rm -rf $DataDir;runInsertTxs;runReadWriteTxs
3827
done
3928
}
4029

4130
function varyNumKeysInEachTx {
42-
setDefaultTestParams
4331
for v in 1 2 5 10 20; do
4432
NumKeysInEachTx=$v
4533
rm -rf $DataDir;runInsertTxs;runReadWriteTxs
4634
done
4735
}
4836

4937
function varyKVSize {
50-
setDefaultTestParams
5138
for v in 100 200 500 1000 2000; do
5239
KVSize=$v
5340
rm -rf $DataDir;runInsertTxs;runReadWriteTxs
5441
done
5542
}
5643

5744
function varyBatchSize {
58-
setDefaultTestParams
5945
for v in 10 20 100 500; do
6046
BatchSize=$v
6147
rm -rf $DataDir;runInsertTxs;runReadWriteTxs
6248
done
6349
}
6450

6551
function varyNumParallelTxWithSingleChain {
66-
setDefaultTestParams
6752
NumChains=1
6853
for v in 1 5 10 20 50 100 500 2000; do
6954
NumParallelTxPerChain=$v
@@ -72,7 +57,6 @@ function varyNumParallelTxWithSingleChain {
7257
}
7358

7459
function varyNumChainsWithNoParallelism {
75-
setDefaultTestParams
7660
NumParallelTxPerChain=1
7761
for v in 1 5 10 20 50 100 500 2000; do
7862
NumChains=$v
@@ -81,21 +65,41 @@ function varyNumChainsWithNoParallelism {
8165
}
8266

8367
function varyNumTxs {
84-
setDefaultTestParams
8568
for v in 1000000 2000000 5000000 10000000; do
8669
NumTotalTx=$v
8770
rm -rf $DataDir;runInsertTxs;runReadWriteTxs
8871
done
8972
}
9073

9174
function runLargeDataExperiment {
92-
setDefaultTestParams
9375
NumKVs=10000000
9476
NumTotalTx=10000000
9577
rm -rf $DataDir;runInsertTxs;runReadWriteTxs
9678
}
9779

98-
### Run tests
80+
shift $(expr $OPTIND - 1 )
81+
82+
case $1 in
83+
varyNumParallelTxPerChain)
84+
varyNumParallelTxPerChain ;;
85+
varyNumChains)
86+
varyNumChains ;;
87+
varyNumParallelTxWithSingleChain)
88+
varyNumParallelTxWithSingleChain ;;
89+
varyNumChainsWithNoParallelism)
90+
varyNumChainsWithNoParallelism ;;
91+
varyNumKeysInEachTx)
92+
varyNumKeysInEachTx ;;
93+
varyKVSize)
94+
varyKVSize ;;
95+
varyBatchSize)
96+
varyBatchSize ;;
97+
varyNumTxs)
98+
varyNumTxs ;;
99+
runLargeDataExperiment)
100+
runLargeDataExperiment ;;
101+
help)
102+
printf "Usage: ./runbenchmarks.sh [test_name]\nAvailable tests (use \"all\" to run all tests):
99103
varyNumParallelTxPerChain
100104
varyNumChains
101105
varyNumParallelTxWithSingleChain
@@ -104,4 +108,18 @@ varyNumKeysInEachTx
104108
varyKVSize
105109
varyBatchSize
106110
varyNumTxs
107-
runLargeDataExperiment
111+
runLargeDataExperiment\n"
112+
;;
113+
all)
114+
varyNumParallelTxPerChain
115+
varyNumChains
116+
varyNumParallelTxWithSingleChain
117+
varyNumChainsWithNoParallelism
118+
varyNumKeysInEachTx
119+
varyKVSize
120+
varyBatchSize
121+
varyNumTxs
122+
runLargeDataExperiment ;;
123+
*)
124+
printf "Error: test name empty/incorrect!\n" >> /dev/stderr
125+
esac

0 commit comments

Comments
 (0)