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

Side by Side Diff: appengine/logdog/coordinator/endpoints/services/terminateStream_test.go

Issue 1967273002: LogDog: Implement RegisterPrefix RPC. (Closed) Base URL: https://github.com/luci/luci-go@logdog-butler-register-coordinator-endpoint
Patch Set: Add missing test. Created 4 years, 7 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package services 5 package services
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "testing" 9 "testing"
10 "time" 10 "time"
(...skipping 14 matching lines...) Expand all
25 ) 25 )
26 26
27 func TestTerminateStream(t *testing.T) { 27 func TestTerminateStream(t *testing.T) {
28 t.Parallel() 28 t.Parallel()
29 29
30 Convey(`With a testing configuration`, t, func() { 30 Convey(`With a testing configuration`, t, func() {
31 c, env := ct.Install() 31 c, env := ct.Install()
32 32
33 // Set our archival delays. The project delay is smaller than th e service 33 // Set our archival delays. The project delay is smaller than th e service
34 // delay, so it should be used. 34 // delay, so it should be used.
35 » » env.ModServiceConfig(c, func(cfg *svcconfig.Coordinator) { 35 » » env.ModServiceConfig(c, func(cfg *svcconfig.Config) {
36 » » » cfg.ArchiveTopic = "projects/test/topics/archive" 36 » » » coord := cfg.Coordinator
37 » » » cfg.ArchiveSettleDelay = google.NewDuration(10 * time.Se cond) 37 » » » coord.ArchiveTopic = "projects/test/topics/archive"
38 » » » cfg.ArchiveDelayMax = google.NewDuration(24 * time.Hour) 38 » » » coord.ArchiveSettleDelay = google.NewDuration(10 * time. Second)
39 » » » coord.ArchiveDelayMax = google.NewDuration(24 * time.Hou r)
39 }) 40 })
40 env.ModProjectConfig("proj-foo", func(pcfg *svcconfig.ProjectCon fig) { 41 env.ModProjectConfig("proj-foo", func(pcfg *svcconfig.ProjectCon fig) {
41 pcfg.MaxStreamAge = google.NewDuration(time.Hour) 42 pcfg.MaxStreamAge = google.NewDuration(time.Hour)
42 }) 43 })
43 44
44 svr := New() 45 svr := New()
45 46
46 tls := ct.MakeStream(c, "proj-foo", "testing/+/foo/bar") 47 tls := ct.MakeStream(c, "proj-foo", "testing/+/foo/bar")
47 48
48 req := logdog.TerminateStreamRequest{ 49 req := logdog.TerminateStreamRequest{
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 _, err := svr.TerminateStream(c, &req) 165 _, err := svr.TerminateStream(c, &req)
165 So(err, ShouldBeRPCOK) 166 So(err, ShouldBeRPCOK)
166 167
167 So(env.ArchivalPublisher.Hashes( ), ShouldResemble, []string{string(tls.Stream.ID)}) 168 So(env.ArchivalPublisher.Hashes( ), ShouldResemble, []string{string(tls.Stream.ID)})
168 So(len(env.ArchivalPublisher.Tas ks()), ShouldEqual, 1) 169 So(len(env.ArchivalPublisher.Tas ks()), ShouldEqual, 1)
169 So(env.ArchivalPublisher.Tasks() [0].CompletePeriod.Duration(), ShouldEqual, 24*time.Hour) 170 So(env.ArchivalPublisher.Tasks() [0].CompletePeriod.Duration(), ShouldEqual, 24*time.Hour)
170 }) 171 })
171 172
172 Convey(`When there is no service or proj ect config delay.`, func() { 173 Convey(`When there is no service or proj ect config delay.`, func() {
173 » » » » » » env.ModServiceConfig(c, func(cfg *svcconfig.Coordinator) { 174 » » » » » » env.ModServiceConfig(c, func(cfg *svcconfig.Config) {
174 » » » » » » » cfg.ArchiveDelayMax = ni l 175 » » » » » » » cfg.Coordinator.ArchiveD elayMax = nil
175 }) 176 })
176 env.ModProjectConfig("proj-foo", func(pcfg *svcconfig.ProjectConfig) { 177 env.ModProjectConfig("proj-foo", func(pcfg *svcconfig.ProjectConfig) {
177 pcfg.MaxStreamAge = nil 178 pcfg.MaxStreamAge = nil
178 }) 179 })
179 180
180 _, err := svr.TerminateStream(c, &req) 181 _, err := svr.TerminateStream(c, &req)
181 So(err, ShouldBeRPCOK) 182 So(err, ShouldBeRPCOK)
182 183
183 So(env.ArchivalPublisher.Hashes( ), ShouldResemble, []string{string(tls.Stream.ID)}) 184 So(env.ArchivalPublisher.Hashes( ), ShouldResemble, []string{string(tls.Stream.ID)})
184 So(len(env.ArchivalPublisher.Tas ks()), ShouldEqual, 1) 185 So(len(env.ArchivalPublisher.Tas ks()), ShouldEqual, 1)
(...skipping 28 matching lines...) Expand all
213 So(err, ShouldBeRPCInvalidArgument, "Invalid ID" ) 214 So(err, ShouldBeRPCInvalidArgument, "Invalid ID" )
214 }) 215 })
215 216
216 Convey(`Will fail if the stream is not registered.`, fun c() { 217 Convey(`Will fail if the stream is not registered.`, fun c() {
217 _, err := svr.TerminateStream(c, &req) 218 _, err := svr.TerminateStream(c, &req)
218 So(err, ShouldBeRPCNotFound, "is not registered" ) 219 So(err, ShouldBeRPCNotFound, "is not registered" )
219 }) 220 })
220 }) 221 })
221 }) 222 })
222 } 223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698