-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): add a unittest for leadership tracking
TestConsumeMessagesTrackLeader ensures that in the event that leadership of a topicPartition changes and no preferredReadReplica is specified, the consumer connects back to the new leader to resume consumption and doesn't continue consuming from the follower. See #1927
- Loading branch information
Showing
3 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package sarama | ||
|
||
import "testing" | ||
|
||
// testLogger implements the StdLogger interface and records the text in the | ||
// logs of the given T passed from Test functions. | ||
// and records the text in the error log. | ||
// | ||
// nolint | ||
type testLogger struct { | ||
t *testing.T | ||
} | ||
|
||
func (l *testLogger) Print(v ...interface{}) { | ||
if l.t != nil { | ||
l.t.Helper() | ||
l.t.Log(v...) | ||
} | ||
} | ||
|
||
func (l *testLogger) Printf(format string, v ...interface{}) { | ||
if l.t != nil { | ||
l.t.Helper() | ||
l.t.Logf(format, v...) | ||
} | ||
} | ||
|
||
func (l *testLogger) Println(v ...interface{}) { | ||
if l.t != nil { | ||
l.t.Helper() | ||
l.t.Log(v...) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters