| 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 coordinator | 5 package coordinator |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "sync" | 9 "sync" |
| 10 "sync/atomic" | 10 "sync/atomic" |
| 11 "testing" | 11 "testing" |
| 12 "time" | 12 "time" |
| 13 | 13 |
| 14 "github.com/luci/luci-go/common/clock/testclock" | 14 "github.com/luci/luci-go/common/clock/testclock" |
| 15 "github.com/luci/luci-go/common/config" | |
| 16 "github.com/luci/luci-go/common/errors" | 15 "github.com/luci/luci-go/common/errors" |
| 17 "github.com/luci/luci-go/logdog/common/types" | 16 "github.com/luci/luci-go/logdog/common/types" |
| 17 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 18 "golang.org/x/net/context" | 18 "golang.org/x/net/context" |
| 19 | 19 |
| 20 . "github.com/smartystreets/goconvey/convey" | 20 . "github.com/smartystreets/goconvey/convey" |
| 21 ) | 21 ) |
| 22 | 22 |
| 23 // testCoordinator is an implementation of Coordinator that can be used for | 23 // testCoordinator is an implementation of Coordinator that can be used for |
| 24 // testing. | 24 // testing. |
| 25 type testCoordinator struct { | 25 type testCoordinator struct { |
| 26 // calls is the number of calls made to the interface's methods. | 26 // calls is the number of calls made to the interface's methods. |
| 27 calls int32 | 27 calls int32 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 tcc.errC = nil | 313 tcc.errC = nil |
| 314 | 314 |
| 315 err := ssc.TerminateStream(c, &t
r) | 315 err := ssc.TerminateStream(c, &t
r) |
| 316 So(err, ShouldNotBeNil) | 316 So(err, ShouldNotBeNil) |
| 317 So(tcc.calls, ShouldEqual, 1) | 317 So(tcc.calls, ShouldEqual, 1) |
| 318 }) | 318 }) |
| 319 }) | 319 }) |
| 320 }) | 320 }) |
| 321 | 321 |
| 322 Convey(`Different projects with the same stream name wil
l not conflict.`, func() { | 322 Convey(`Different projects with the same stream name wil
l not conflict.`, func() { |
| 323 » » » » var projects = []config.ProjectName{"", "foo", "
bar"} | 323 » » » » var projects = []cfgtypes.ProjectName{"", "foo",
"bar"} |
| 324 | 324 |
| 325 for i, p := range projects { | 325 for i, p := range projects { |
| 326 st.Project = p | 326 st.Project = p |
| 327 s, err := ssc.RegisterStream(c, &st, nil
) | 327 s, err := ssc.RegisterStream(c, &st, nil
) |
| 328 So(err, ShouldBeNil) | 328 So(err, ShouldBeNil) |
| 329 | 329 |
| 330 So(ssc.TerminateStream(c, &TerminateRequ
est{ | 330 So(ssc.TerminateStream(c, &TerminateRequ
est{ |
| 331 Project: s.Project, | 331 Project: s.Project, |
| 332 Path: s.Path, | 332 Path: s.Path, |
| 333 ID: s.ID, | 333 ID: s.ID, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 remotes := 0 | 387 remotes := 0 |
| 388 for i := 0; i < count; i++ { | 388 for i := 0; i < count; i++ { |
| 389 if state[i].ProtoVersion == "remote" { | 389 if state[i].ProtoVersion == "remote" { |
| 390 remotes++ | 390 remotes++ |
| 391 } | 391 } |
| 392 } | 392 } |
| 393 So(remotes, ShouldEqual, count) | 393 So(remotes, ShouldEqual, count) |
| 394 }) | 394 }) |
| 395 }) | 395 }) |
| 396 } | 396 } |
| OLD | NEW |