| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package collector | 5 package collector |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "fmt" | 9 "fmt" |
| 10 "sync/atomic" | 10 "sync/atomic" |
| 11 "testing" | 11 "testing" |
| 12 | 12 |
| 13 "github.com/luci/luci-go/common/clock/testclock" | 13 "github.com/luci/luci-go/common/clock/testclock" |
| 14 "github.com/luci/luci-go/common/config" | |
| 15 "github.com/luci/luci-go/common/errors" | 14 "github.com/luci/luci-go/common/errors" |
| 16 "github.com/luci/luci-go/logdog/api/logpb" | 15 "github.com/luci/luci-go/logdog/api/logpb" |
| 17 "github.com/luci/luci-go/logdog/client/butlerproto" | 16 "github.com/luci/luci-go/logdog/client/butlerproto" |
| 18 "github.com/luci/luci-go/logdog/common/storage/memory" | 17 "github.com/luci/luci-go/logdog/common/storage/memory" |
| 19 "github.com/luci/luci-go/logdog/common/types" | 18 "github.com/luci/luci-go/logdog/common/types" |
| 20 cc "github.com/luci/luci-go/logdog/server/collector/coordinator" | 19 cc "github.com/luci/luci-go/logdog/server/collector/coordinator" |
| 20 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 21 "golang.org/x/net/context" | 21 "golang.org/x/net/context" |
| 22 | 22 |
| 23 . "github.com/luci/luci-go/common/testing/assertions" | 23 . "github.com/luci/luci-go/common/testing/assertions" |
| 24 . "github.com/smartystreets/goconvey/convey" | 24 . "github.com/smartystreets/goconvey/convey" |
| 25 ) | 25 ) |
| 26 | 26 |
| 27 // TestCollector runs through a series of end-to-end Collector workflows and | 27 // TestCollector runs through a series of end-to-end Collector workflows and |
| 28 // ensures that the Collector behaves appropriately. | 28 // ensures that the Collector behaves appropriately. |
| 29 func testCollectorImpl(t *testing.T, caching bool) { | 29 func testCollectorImpl(t *testing.T, caching bool) { |
| 30 Convey(fmt.Sprintf(`Using a test configuration with caching == %v`, cach
ing), t, func() { | 30 Convey(fmt.Sprintf(`Using a test configuration with caching == %v`, cach
ing), t, func() { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 bb.addFullStream("foo/+/baz", 3) | 195 bb.addFullStream("foo/+/baz", 3) |
| 196 | 196 |
| 197 err := coll.Process(c, bb.bundle()) | 197 err := coll.Process(c, bb.bundle()) |
| 198 So(err, ShouldErrLike, "invalid bundle project name") | 198 So(err, ShouldErrLike, "invalid bundle project name") |
| 199 So(errors.IsTransient(err), ShouldBeFalse) | 199 So(errors.IsTransient(err), ShouldBeFalse) |
| 200 }) | 200 }) |
| 201 | 201 |
| 202 Convey(`Will drop streams with invalid project names.`, func() { | 202 Convey(`Will drop streams with invalid project names.`, func() { |
| 203 b := bb.genBase() | 203 b := bb.genBase() |
| 204 b.Project = "!!!invalid name!!!" | 204 b.Project = "!!!invalid name!!!" |
| 205 » » » So(config.ProjectName(b.Project).Validate(), ShouldNotBe
Nil) | 205 » » » So(cfgtypes.ProjectName(b.Project).Validate(), ShouldNot
BeNil) |
| 206 | 206 |
| 207 err := coll.Process(c, bb.bundle()) | 207 err := coll.Process(c, bb.bundle()) |
| 208 So(err, ShouldErrLike, "invalid bundle project name") | 208 So(err, ShouldErrLike, "invalid bundle project name") |
| 209 So(errors.IsTransient(err), ShouldBeFalse) | 209 So(errors.IsTransient(err), ShouldBeFalse) |
| 210 }) | 210 }) |
| 211 | 211 |
| 212 Convey(`Will drop streams with empty bundle prefixes.`, func() { | 212 Convey(`Will drop streams with empty bundle prefixes.`, func() { |
| 213 b := bb.genBase() | 213 b := bb.genBase() |
| 214 b.Prefix = "" | 214 b.Prefix = "" |
| 215 | 215 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 testCollectorImpl(t, false) | 316 testCollectorImpl(t, false) |
| 317 } | 317 } |
| 318 | 318 |
| 319 // TestCollectorWithCaching runs through a series of end-to-end Collector | 319 // TestCollectorWithCaching runs through a series of end-to-end Collector |
| 320 // workflows and ensures that the Collector behaves appropriately. | 320 // workflows and ensures that the Collector behaves appropriately. |
| 321 func TestCollectorWithCaching(t *testing.T) { | 321 func TestCollectorWithCaching(t *testing.T) { |
| 322 t.Parallel() | 322 t.Parallel() |
| 323 | 323 |
| 324 testCollectorImpl(t, true) | 324 testCollectorImpl(t, true) |
| 325 } | 325 } |
| OLD | NEW |