Skip to content

Commit e09a94c

Browse files
author
Kostas Christidis
committed
[FAB-6096] Modify benchmark test code for Kafka
1. Move to using profiles for all tests, instead of relying on just setting the CONFIGTX_ORDERER_ORDERERTYPE ENV var. 2. Switch to 3-broker default for Kafka tests 3. Add sarama verbosity flag in envvars map for easier debugging 4. Fix comments and log statements Change-Id: I1722a2de7fc413dff3fd877fed2e09e602078cd8 Signed-off-by: Kostas Christidis <kostas@christidis.io>
1 parent 129d9e5 commit e09a94c

File tree

2 files changed

+23
-30
lines changed

2 files changed

+23
-30
lines changed

orderer/common/performance/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func init() {
4646
msp := mspmgmt.GetLocalMSP()
4747
signer, err = msp.GetDefaultSigningIdentity()
4848
if err != nil {
49-
panic(fmt.Errorf("Failed to initialize get default signer: %s", err))
49+
panic(fmt.Errorf("Failed to get default signer: %s", err))
5050
}
5151
}
5252

orderer/common/server/benchmark_test.go

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"time"
1818

1919
"github.com/hyperledger/fabric/common/tools/configtxgen/localconfig"
20-
"github.com/hyperledger/fabric/common/tools/configtxgen/provisional"
2120
"github.com/hyperledger/fabric/orderer/common/localconfig"
2221
perf "github.com/hyperledger/fabric/orderer/common/performance"
2322
cb "github.com/hyperledger/fabric/protos/common"
@@ -26,10 +25,10 @@ import (
2625

2726
// Usage: BENCHMARK=true go test -run=TestOrdererBenchmark[Solo|Kafka][Broadcast|Deliver]
2827
//
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.
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.
3332
//
3433
// The test sends [tx] transactions of size [kb] in total. These tx are evenly distributed
3534
// among all clients, which gives us [tx / (ch * bc * ord)] tx per client.
@@ -56,7 +55,7 @@ import (
5655
// ordered. This is important for evaluating elapsed time of async broadcast operations.
5756
//
5857
// Again, each deliver client only interacts with one channel and one orderer, which
59-
// results in [a * f * e] deliver clients in total.
58+
// results in [ch * dc * ord] deliver clients in total.
6059
//
6160
// ch -> channelCounts
6261
// bc -> broadcastClientPerChannel
@@ -70,8 +69,10 @@ import (
7069
// as deliver is effectively retrieving pre-generated blocks, so it shouldn't be choked
7170
// by slower broadcast.
7271
//
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
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
7576

7677
const (
7778
MaxMessageCount = 10
@@ -87,10 +88,11 @@ var envvars = map[string]string{
8788
"ORDERER_GENERAL_GENESISPROFILE": localconfig.SampleDevModeSoloProfile,
8889
"ORDERER_GENERAL_LEDGERTYPE": "file",
8990
"ORDERER_GENERAL_LOGLEVEL": "error",
91+
"ORDERER_KAFKA_VERBOSE": "false",
9092
localconfig.Prefix + "_ORDERER_BATCHSIZE_MAXMESSAGECOUNT": strconv.Itoa(MaxMessageCount),
9193
localconfig.Prefix + "_ORDERER_BATCHSIZE_ABSOLUTEMAXBYTES": strconv.Itoa(AbsoluteMaxBytes) + " KB",
9294
localconfig.Prefix + "_ORDERER_BATCHSIZE_PREFERREDMAXBYTES": strconv.Itoa(PreferredMaxBytes) + " KB",
93-
localconfig.Prefix + "_ORDERER_KAFKA_BROKERS": "[localhost:9092]",
95+
localconfig.Prefix + "_ORDERER_KAFKA_BROKERS": "[localhost:9092, localhost:9093, localhost:9094]",
9496
}
9597

9698
type factors struct {
@@ -119,16 +121,13 @@ func (f factors) String() string {
119121
// As benchmark tests are skipped by default, we put this test here to catch
120122
// potential code changes that might break benchmark tests. If this test fails,
121123
// it is likely that benchmark tests need to be updated.
122-
func TestOrdererBenchmark(t *testing.T) {
123-
os.Setenv(localconfig.Prefix+"_ORDERER_ORDERERTYPE", provisional.ConsensusTypeSolo)
124-
defer os.Unsetenv(localconfig.Prefix + "_ORDERER_ORDERERTYPE")
125-
124+
func TestOrdererBenchmarkSolo(t *testing.T) {
126125
for key, value := range envvars {
127126
os.Setenv(key, value)
128127
defer os.Unsetenv(key)
129128
}
130129

131-
t.Run("Benchmark Sample Test", func(t *testing.T) {
130+
t.Run("Benchmark Sample Test (Solo)", func(t *testing.T) {
132131
benchmarkOrderer(t, 1, 5, PreferredMaxBytes, 1, 0, 1, true)
133132
})
134133
}
@@ -139,9 +138,6 @@ func TestOrdererBenchmarkSoloBroadcast(t *testing.T) {
139138
t.Skip("Skipping benchmark test")
140139
}
141140

142-
os.Setenv(localconfig.Prefix+"_ORDERER_ORDERERTYPE", provisional.ConsensusTypeSolo)
143-
defer os.Unsetenv(localconfig.Prefix + "_ORDERER_ORDERERTYPE")
144-
145141
for key, value := range envvars {
146142
os.Setenv(key, value)
147143
defer os.Unsetenv(key)
@@ -187,9 +183,6 @@ func TestOrdererBenchmarkSoloDeliver(t *testing.T) {
187183
t.Skip("Skipping benchmark test")
188184
}
189185

190-
os.Setenv(localconfig.Prefix+"_ORDERER_ORDERERTYPE", provisional.ConsensusTypeSolo)
191-
defer os.Unsetenv(localconfig.Prefix + "_ORDERER_ORDERERTYPE")
192-
193186
for key, value := range envvars {
194187
os.Setenv(key, value)
195188
defer os.Unsetenv(key)
@@ -235,14 +228,14 @@ func TestOrdererBenchmarkKafkaBroadcast(t *testing.T) {
235228
t.Skip("Skipping benchmark test")
236229
}
237230

238-
os.Setenv(localconfig.Prefix+"_ORDERER_ORDERERTYPE", provisional.ConsensusTypeKafka)
239-
defer os.Unsetenv(localconfig.Prefix + "_ORDERER_ORDERERTYPE")
240-
241231
for key, value := range envvars {
242232
os.Setenv(key, value)
243233
defer os.Unsetenv(key)
244234
}
245235

236+
os.Setenv("ORDERER_GENERAL_GENESISPROFILE", localconfig.SampleDevModeKafkaProfile)
237+
defer os.Unsetenv("ORDERER_GENERAL_GENESISPROFILE")
238+
246239
var (
247240
channelCounts = []int{1, 10}
248241
totalTx = []int{10000}
@@ -283,14 +276,14 @@ func TestOrdererBenchmarkKafkaDeliver(t *testing.T) {
283276
t.Skip("Skipping benchmark test")
284277
}
285278

286-
os.Setenv(localconfig.Prefix+"_ORDERER_ORDERERTYPE", provisional.ConsensusTypeKafka)
287-
defer os.Unsetenv(localconfig.Prefix + "_ORDERER_ORDERERTYPE")
288-
289279
for key, value := range envvars {
290280
os.Setenv(key, value)
291281
defer os.Unsetenv(key)
292282
}
293283

284+
os.Setenv("ORDERER_GENERAL_GENESISPROFILE", localconfig.SampleDevModeKafkaProfile)
285+
defer os.Unsetenv("ORDERER_GENERAL_GENESISPROFILE")
286+
294287
var (
295288
channelCounts = []int{1, 10}
296289
totalTx = []int{10000}
@@ -512,16 +505,16 @@ func benchmarkOrderer(
512505
// Experiment shows that atomic counter is not bottleneck.
513506
assert.Equal(t, uint64(totalTx), txCount, "Expected to send %d msg, but actually sent %d", uint64(totalTx), txCount)
514507

515-
ordererType := os.Getenv(localconfig.Prefix + "_ORDERER_ORDERERTYPE")
508+
ordererProfile := os.Getenv("ORDERER_GENERAL_GENESISPROFILE")
516509

517510
fmt.Printf(
518-
"Message: %6d Message Size: %3dKB Channels: %3d Orderer(%s): %2d | "+
511+
"Messages: %6d Message Size: %3dKB Channels: %3d Orderer (%s): %2d | "+
519512
"Broadcast Clients: %3d Write tps: %5.1f tx/s Elapsed Time: %0.2fs | "+
520513
"Deliver clients: %3d Read tps: %8.1f blk/s Elapsed Time: %0.2fs\n",
521514
totalTx,
522515
msgSize,
523516
numOfChannels,
524-
ordererType,
517+
ordererProfile,
525518
numOfOrderer,
526519
broadcastClientPerChannel*numOfChannels*numOfOrderer,
527520
float64(totalTx)/btime.Seconds(),

0 commit comments

Comments
 (0)