Skip to content

Commit 021b3c4

Browse files
committed
Fix occasionaly failing TestBroadcast* tests
This changeset removes a race condition responsible for the ocassional failures we see in CI in the TestBroadcast* tests that read from "disk", the construct that represents the broker's disk where all produced messages are eventually written to. The TestBroadcast* tests have been executed 10000 times and do not fail. Change-Id: I5dea63a52d64171bfd703e5cd053437b0d215cf8 Signed-off-by: Kostas Christidis <[email protected]>
1 parent c0aa1df commit 021b3c4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

orderer/kafka/producer_mock_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type mockProducerImpl struct {
2929
producer *mocks.SyncProducer
3030

3131
checker mocks.ValueChecker
32-
disk chan []byte // This is the "disk"/log that the producer writes to
32+
disk chan []byte // This simulates the broker's "disk" where the producer's messages eventually end up
3333
producedOffset int64
3434
t *testing.T
3535
}
@@ -54,13 +54,13 @@ func mockNewProducer(t *testing.T, conf *config.TopLevel, seek int64, disk chan
5454
func (mp *mockProducerImpl) Send(payload []byte) error {
5555
mp.producer.ExpectSendMessageWithCheckerFunctionAndSucceed(mp.checker)
5656
mp.producedOffset++
57-
mp.disk <- payload
5857
prt, ofs, err := mp.producer.SendMessage(newMsg(payload, mp.config.Kafka.Topic))
5958
if err != nil ||
6059
prt != mp.config.Kafka.PartitionID ||
6160
ofs != mp.producedOffset {
6261
mp.t.Fatal("Producer not functioning as expected")
6362
}
63+
mp.disk <- payload // Reaches the broker's disk
6464
return err
6565
}
6666

@@ -72,7 +72,7 @@ func (mp *mockProducerImpl) testFillWithBlocks(seek int64) {
7272
dyingChan := make(chan struct{})
7373
deadChan := make(chan struct{})
7474

75-
go func() { // This goroutine is meant to read only the "fill-in" blocks.
75+
go func() { // This goroutine is meant to read only the "fill-in" blocks
7676
for {
7777
select {
7878
case <-mp.disk:

0 commit comments

Comments
 (0)