OLD | NEW |
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 services | 5 package services |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 "fmt" | 9 "fmt" |
10 "testing" | 10 "testing" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 293 |
294 Convey(`Will not register if the descrip
tor doesn't validate.`, func() { | 294 Convey(`Will not register if the descrip
tor doesn't validate.`, func() { |
295 tls.Desc.ContentType = "" | 295 tls.Desc.ContentType = "" |
296 So(tls.Desc.Validate(true), Shou
ldNotBeNil) | 296 So(tls.Desc.Validate(true), Shou
ldNotBeNil) |
297 req.Desc = tls.DescBytes() | 297 req.Desc = tls.DescBytes() |
298 | 298 |
299 _, err := svr.RegisterStream(c,
&req) | 299 _, err := svr.RegisterStream(c,
&req) |
300 So(err, ShouldBeRPCInvalidArgume
nt, "Invalid log stream descriptor") | 300 So(err, ShouldBeRPCInvalidArgume
nt, "Invalid log stream descriptor") |
301 }) | 301 }) |
302 }) | 302 }) |
303 | |
304 Convey(`The registerStreamMutation`, func() { | |
305 svcs := coordinator.GetServices(c) | |
306 cfg, err := svcs.Config(c) | |
307 if err != nil { | |
308 panic(err) | |
309 } | |
310 pcfg, err := svcs.ProjectConfig(c, "proj
-foo") | |
311 if err != nil { | |
312 panic(err) | |
313 } | |
314 | |
315 rsm := registerStreamMutation{ | |
316 RegisterStreamRequest: &req, | |
317 | |
318 cfg: cfg, | |
319 pcfg: pcfg, | |
320 | |
321 desc: tls.Desc, | |
322 pfx: tls.Prefix, | |
323 ls: tls.Stream, | |
324 lst: tls.State, | |
325 } | |
326 | |
327 Convey(`Can RollForward.`, func() { | |
328 _, err := rsm.RollForward(c) | |
329 So(err, ShouldBeNil) | |
330 }) | |
331 | |
332 Convey(`Returns internal server error if
the stream Put() fails (tumble).`, func() { | |
333 c, fb := featureBreaker.FilterRD
S(c, nil) | |
334 fb.BreakFeatures(errors.New("tes
t error"), "PutMulti") | |
335 | |
336 _, err := rsm.RollForward(c) | |
337 So(err, ShouldBeRPCInternal) | |
338 }) | |
339 }) | |
340 }) | 303 }) |
341 }) | 304 }) |
342 }) | 305 }) |
343 } | 306 } |
344 | 307 |
345 func BenchmarkRegisterStream(b *testing.B) { | 308 func BenchmarkRegisterStream(b *testing.B) { |
346 c, env := ct.Install() | 309 c, env := ct.Install() |
347 | 310 |
348 // Set our archival delays. The project delay is smaller than the servic
e | 311 // Set our archival delays. The project delay is smaller than the servic
e |
349 // delay, so it should be used. | 312 // delay, so it should be used. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 Desc: tls.DescBytes(), | 347 Desc: tls.DescBytes(), |
385 TerminalIndex: -1, | 348 TerminalIndex: -1, |
386 } | 349 } |
387 | 350 |
388 _, err := svr.RegisterStream(c, &req) | 351 _, err := svr.RegisterStream(c, &req) |
389 if err != nil { | 352 if err != nil { |
390 b.Fatalf("failed to get OK response (%s)", err) | 353 b.Fatalf("failed to get OK response (%s)", err) |
391 } | 354 } |
392 } | 355 } |
393 } | 356 } |
OLD | NEW |