jrmccluskey commented on code in PR #28413:
URL: https://github.com/apache/beam/pull/28413#discussion_r1323436745
##########
sdks/go/container/tools/buffered_logging_test.go:
##########
@@ -166,4 +167,59 @@ func TestBufferedLogger(t *testing.T) {
}
}
})
+
+ t.Run("direct print", func(t *testing.T) {
+ catcher := &logCatcher{}
+ l := &Logger{client: catcher}
+ bl := NewBufferedLogger(l)
+
+ bl.Printf(ctx, "foo %v", "bar")
+
+ received := catcher.msgs[0].GetLogEntries()[0]
+
+ if got, want := received.Message, "foo bar"; got != want {
+ t.Errorf("l.Printf(\"foo %%v\", \"bar\"): got message
%q, want %q", got, want)
+ }
+
+ if got, want := received.Severity,
fnpb.LogEntry_Severity_DEBUG; got != want {
+ t.Errorf("l.Printf(\"foo %%v\", \"bar\"): got severity
%v, want %v", got, want)
+ }
+ })
+
+ t.Run("debug flush at interval", func(t *testing.T) {
+ catcher := &logCatcher{}
+ l := &Logger{client: catcher}
+ interval := time.Duration(5e9)
+ bl := NewBufferedLoggerWithFlushInterval(context.Background(),
l, interval)
+
+ messages := []string{"foo", "bar", "baz"}
+
+ for _, message := range messages {
+ // Pause for four seconds before each message
+ time.Sleep(2e9)
Review Comment:
Little bit messier in the constructors but it made the unit tests way
faster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]