Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Unified Diff: logdog/client/butler/butler_test.go

Issue 2601583002: Butler: fix global tags applied to empty map. (Closed)
Patch Set: Added tests, testing method to Bundler. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « logdog/client/butler/butler.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/client/butler/butler_test.go
diff --git a/logdog/client/butler/butler_test.go b/logdog/client/butler/butler_test.go
index be56e25ef9b9a909eae85929d8c1d140c6c4a525..1daa35310ab779a47fe77c4e9858efd602ab2668 100644
--- a/logdog/client/butler/butler_test.go
+++ b/logdog/client/butler/butler_test.go
@@ -9,17 +9,22 @@ import (
"errors"
"fmt"
"io"
+ "io/ioutil"
"sync"
"testing"
+ "time"
"github.com/luci/luci-go/common/clock/testclock"
+ "github.com/luci/luci-go/common/proto/google"
. "github.com/luci/luci-go/common/testing/assertions"
"github.com/luci/luci-go/logdog/api/logpb"
"github.com/luci/luci-go/logdog/client/butler/output"
"github.com/luci/luci-go/logdog/client/butlerlib/streamproto"
"github.com/luci/luci-go/logdog/common/types"
- . "github.com/smartystreets/goconvey/convey"
+
"golang.org/x/net/context"
+
+ . "github.com/smartystreets/goconvey/convey"
)
type testOutput struct {
@@ -399,6 +404,60 @@ func TestButler(t *testing.T) {
So(to.isTerminal("stderr"), ShouldBeTrue)
})
+ Convey(`Can apply global tags.`, func() {
+ conf.GlobalTags = streamproto.TagMap{
+ "foo": "bar",
+ "baz": "qux",
+ }
+ props := streamproto.Properties{
+ LogStreamDescriptor: &logpb.LogStreamDescriptor{
+ Name: "stdout",
+ ContentType: "test/data",
+ Timestamp: google.NewTimestamp(time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC)),
+ },
+ }
+
+ b := mkb(c, conf)
+ defer func() {
+ b.Activate()
+ b.Wait()
+ }()
+
+ Convey(`Applies global tags, but allows the stream to override.`, func() {
+ props.Tags = map[string]string{
+ "baz": "override",
+ }
+
+ So(b.AddStream(ioutil.NopCloser(&bytes.Buffer{}), &props), ShouldBeNil)
+ So(b.bundler.GetStreamDescs(), ShouldResemble, map[string]*logpb.LogStreamDescriptor{
+ "stdout": {
+ Name: "stdout",
+ ContentType: "test/data",
+ Timestamp: props.Timestamp,
+ Tags: map[string]string{
+ "foo": "bar",
+ "baz": "override",
+ },
+ },
+ })
+ })
+
+ Convey(`Will apply global tags if the stream has none (nil).`, func() {
+ So(b.AddStream(ioutil.NopCloser(&bytes.Buffer{}), &props), ShouldBeNil)
+ So(b.bundler.GetStreamDescs(), ShouldResemble, map[string]*logpb.LogStreamDescriptor{
+ "stdout": {
+ Name: "stdout",
+ ContentType: "test/data",
+ Timestamp: props.Timestamp,
+ Tags: map[string]string{
+ "foo": "bar",
+ "baz": "qux",
+ },
+ },
+ })
+ })
+ })
+
Convey(`Run with 256 streams, stream{0..256} will deplete and finish.`, func() {
b := mkb(c, conf)
streams := make([]*testStream, 256)
« no previous file with comments | « logdog/client/butler/butler.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698