@@ -17,6 +17,7 @@ import (
17
17
"time"
18
18
19
19
"github.com/hyperledger/fabric/common/tools/configtxgen/localconfig"
20
+ "github.com/hyperledger/fabric/common/tools/configtxgen/provisional"
20
21
"github.com/hyperledger/fabric/orderer/common/localconfig"
21
22
perf "github.com/hyperledger/fabric/orderer/common/performance"
22
23
cb "github.com/hyperledger/fabric/protos/common"
@@ -25,10 +26,10 @@ import (
25
26
26
27
// Usage: BENCHMARK=true go test -run=TestOrdererBenchmark[Solo|Kafka][Broadcast|Deliver]
27
28
//
28
- // Benchmark test makes [ch] channels, creates [bc] clients per client per channel per
29
- // orderer. There are [ord] orderer instances in total. A client ONLY interacts with ONE
30
- // channel and ONE orderer, so the number of client in total is [ch * bc * ord]. Note that
31
- // all clients execute concurrently .
29
+ // Benchmark test makes [ch] channels, creates [bc] clients per client per orderer. There are
30
+ // [ord] orderer instances in total. A client ONLY interacts with ONE channel and ONE
31
+ // orderer, so the number of client in total is [ch * bc * ord]. Note that all clients are
32
+ // concurrent .
32
33
//
33
34
// The test sends [tx] transactions of size [kb] in total. These tx are evenly distributed
34
35
// among all clients, which gives us [tx / (ch * bc * ord)] tx per client.
@@ -55,7 +56,7 @@ import (
55
56
// ordered. This is important for evaluating elapsed time of async broadcast operations.
56
57
//
57
58
// Again, each deliver client only interacts with one channel and one orderer, which
58
- // results in [ch * dc * ord ] deliver clients in total.
59
+ // results in [a * f * e ] deliver clients in total.
59
60
//
60
61
// ch -> channelCounts
61
62
// bc -> broadcastClientPerChannel
@@ -69,10 +70,8 @@ import (
69
70
// as deliver is effectively retrieving pre-generated blocks, so it shouldn't be choked
70
71
// by slower broadcast.
71
72
//
72
- // Note: At least three Kafka brokers listening on localhost:[9092-9094] are required to
73
- // run the Kafka-based benchmark. This is set in the `envvars` map and can be adjusted
74
- // if need be.
75
- // TODO Spin up ephemeral Kafka containers for test
73
+ // Note: a Kafka broker listening on localhost:9092 is required to run Kafka based benchmark
74
+ // TODO(jay_guo) use ephemeral kafka container for test
76
75
77
76
const (
78
77
MaxMessageCount = 10
@@ -88,11 +87,10 @@ var envvars = map[string]string{
88
87
"ORDERER_GENERAL_GENESISPROFILE" : localconfig .SampleDevModeSoloProfile ,
89
88
"ORDERER_GENERAL_LEDGERTYPE" : "file" ,
90
89
"ORDERER_GENERAL_LOGLEVEL" : "error" ,
91
- "ORDERER_KAFKA_VERBOSE" : "false" ,
92
90
localconfig .Prefix + "_ORDERER_BATCHSIZE_MAXMESSAGECOUNT" : strconv .Itoa (MaxMessageCount ),
93
91
localconfig .Prefix + "_ORDERER_BATCHSIZE_ABSOLUTEMAXBYTES" : strconv .Itoa (AbsoluteMaxBytes ) + " KB" ,
94
92
localconfig .Prefix + "_ORDERER_BATCHSIZE_PREFERREDMAXBYTES" : strconv .Itoa (PreferredMaxBytes ) + " KB" ,
95
- localconfig .Prefix + "_ORDERER_KAFKA_BROKERS" : "[localhost:9092, localhost:9093, localhost:9094 ]" ,
93
+ localconfig .Prefix + "_ORDERER_KAFKA_BROKERS" : "[localhost:9092]" ,
96
94
}
97
95
98
96
type factors struct {
@@ -121,13 +119,16 @@ func (f factors) String() string {
121
119
// As benchmark tests are skipped by default, we put this test here to catch
122
120
// potential code changes that might break benchmark tests. If this test fails,
123
121
// it is likely that benchmark tests need to be updated.
124
- func TestOrdererBenchmarkSolo (t * testing.T ) {
122
+ func TestOrdererBenchmark (t * testing.T ) {
123
+ os .Setenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" , provisional .ConsensusTypeSolo )
124
+ defer os .Unsetenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" )
125
+
125
126
for key , value := range envvars {
126
127
os .Setenv (key , value )
127
128
defer os .Unsetenv (key )
128
129
}
129
130
130
- t .Run ("Benchmark Sample Test (Solo) " , func (t * testing.T ) {
131
+ t .Run ("Benchmark Sample Test" , func (t * testing.T ) {
131
132
benchmarkOrderer (t , 1 , 5 , PreferredMaxBytes , 1 , 0 , 1 , true )
132
133
})
133
134
}
@@ -138,6 +139,9 @@ func TestOrdererBenchmarkSoloBroadcast(t *testing.T) {
138
139
t .Skip ("Skipping benchmark test" )
139
140
}
140
141
142
+ os .Setenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" , provisional .ConsensusTypeSolo )
143
+ defer os .Unsetenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" )
144
+
141
145
for key , value := range envvars {
142
146
os .Setenv (key , value )
143
147
defer os .Unsetenv (key )
@@ -183,6 +187,9 @@ func TestOrdererBenchmarkSoloDeliver(t *testing.T) {
183
187
t .Skip ("Skipping benchmark test" )
184
188
}
185
189
190
+ os .Setenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" , provisional .ConsensusTypeSolo )
191
+ defer os .Unsetenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" )
192
+
186
193
for key , value := range envvars {
187
194
os .Setenv (key , value )
188
195
defer os .Unsetenv (key )
@@ -228,14 +235,14 @@ func TestOrdererBenchmarkKafkaBroadcast(t *testing.T) {
228
235
t .Skip ("Skipping benchmark test" )
229
236
}
230
237
238
+ os .Setenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" , provisional .ConsensusTypeKafka )
239
+ defer os .Unsetenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" )
240
+
231
241
for key , value := range envvars {
232
242
os .Setenv (key , value )
233
243
defer os .Unsetenv (key )
234
244
}
235
245
236
- os .Setenv ("ORDERER_GENERAL_GENESISPROFILE" , localconfig .SampleDevModeKafkaProfile )
237
- defer os .Unsetenv ("ORDERER_GENERAL_GENESISPROFILE" )
238
-
239
246
var (
240
247
channelCounts = []int {1 , 10 }
241
248
totalTx = []int {10000 }
@@ -276,14 +283,14 @@ func TestOrdererBenchmarkKafkaDeliver(t *testing.T) {
276
283
t .Skip ("Skipping benchmark test" )
277
284
}
278
285
286
+ os .Setenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" , provisional .ConsensusTypeKafka )
287
+ defer os .Unsetenv (localconfig .Prefix + "_ORDERER_ORDERERTYPE" )
288
+
279
289
for key , value := range envvars {
280
290
os .Setenv (key , value )
281
291
defer os .Unsetenv (key )
282
292
}
283
293
284
- os .Setenv ("ORDERER_GENERAL_GENESISPROFILE" , localconfig .SampleDevModeKafkaProfile )
285
- defer os .Unsetenv ("ORDERER_GENERAL_GENESISPROFILE" )
286
-
287
294
var (
288
295
channelCounts = []int {1 , 10 }
289
296
totalTx = []int {10000 }
@@ -505,16 +512,16 @@ func benchmarkOrderer(
505
512
// Experiment shows that atomic counter is not bottleneck.
506
513
assert .Equal (t , uint64 (totalTx ), txCount , "Expected to send %d msg, but actually sent %d" , uint64 (totalTx ), txCount )
507
514
508
- ordererProfile := os .Getenv ("ORDERER_GENERAL_GENESISPROFILE " )
515
+ ordererType := os .Getenv (localconfig . Prefix + "_ORDERER_ORDERERTYPE " )
509
516
510
517
fmt .Printf (
511
- "Messages : %6d Message Size: %3dKB Channels: %3d Orderer (%s): %2d | " +
518
+ "Message : %6d Message Size: %3dKB Channels: %3d Orderer(%s): %2d | " +
512
519
"Broadcast Clients: %3d Write tps: %5.1f tx/s Elapsed Time: %0.2fs | " +
513
520
"Deliver clients: %3d Read tps: %8.1f blk/s Elapsed Time: %0.2fs\n " ,
514
521
totalTx ,
515
522
msgSize ,
516
523
numOfChannels ,
517
- ordererProfile ,
524
+ ordererType ,
518
525
numOfOrderer ,
519
526
broadcastClientPerChannel * numOfChannels * numOfOrderer ,
520
527
float64 (totalTx )/ btime .Seconds (),
0 commit comments