| OLD | NEW |
| 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 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 . "github.com/smartystreets/goconvey/convey" | 23 . "github.com/smartystreets/goconvey/convey" |
| 24 ) | 24 ) |
| 25 | 25 |
| 26 func TestArchiveStream(t *testing.T) { | 26 func TestArchiveStream(t *testing.T) { |
| 27 t.Parallel() | 27 t.Parallel() |
| 28 | 28 |
| 29 Convey(`With a testing configuration`, t, func() { | 29 Convey(`With a testing configuration`, t, func() { |
| 30 c, tc := testclock.UseTime(context.Background(), testclock.TestT
imeUTC) | 30 c, tc := testclock.UseTime(context.Background(), testclock.TestT
imeUTC) |
| 31 c = memory.Use(c) | 31 c = memory.Use(c) |
| 32 | 32 |
| 33 fs := authtest.FakeState{} |
| 34 c = auth.WithState(c, &fs) |
| 35 |
| 33 svcStub := ct.Services{} | 36 svcStub := ct.Services{} |
| 34 svcStub.InitConfig() | 37 svcStub.InitConfig() |
| 35 svcStub.ServiceConfig.Coordinator.ServiceAuthGroup = "test-servi
ces" | 38 svcStub.ServiceConfig.Coordinator.ServiceAuthGroup = "test-servi
ces" |
| 36 c = coordinator.WithServices(c, &svcStub) | 39 c = coordinator.WithServices(c, &svcStub) |
| 37 | 40 |
| 38 svr := New() | 41 svr := New() |
| 39 | 42 |
| 40 now := ds.RoundTime(tc.Now().UTC()) | 43 now := ds.RoundTime(tc.Now().UTC()) |
| 41 | 44 |
| 42 fs := authtest.FakeState{} | |
| 43 c = auth.WithState(c, &fs) | |
| 44 | |
| 45 // Register a testing log stream with an archive tasked. | 45 // Register a testing log stream with an archive tasked. |
| 46 ls := ct.TestLogStream(c, ct.TestLogStreamDescriptor(c, "foo")) | 46 ls := ct.TestLogStream(c, ct.TestLogStreamDescriptor(c, "foo")) |
| 47 ls.State = coordinator.LSArchiveTasked | 47 ls.State = coordinator.LSArchiveTasked |
| 48 ls.ArchivalKey = []byte("archival key") | 48 ls.ArchivalKey = []byte("archival key") |
| 49 if err := ds.Get(c).Put(ls); err != nil { | 49 if err := ds.Get(c).Put(ls); err != nil { |
| 50 panic(err) | 50 panic(err) |
| 51 } | 51 } |
| 52 | 52 |
| 53 req := &logdog.ArchiveStreamRequest{ | 53 req := &logdog.ArchiveStreamRequest{ |
| 54 Path: string(ls.Path()), | 54 Path: string(ls.Path()), |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 Convey(`When datastore Put fails, returns internal error
.`, func() { | 186 Convey(`When datastore Put fails, returns internal error
.`, func() { |
| 187 c, fb := featureBreaker.FilterRDS(c, nil) | 187 c, fb := featureBreaker.FilterRDS(c, nil) |
| 188 fb.BreakFeatures(errors.New("test error"), "PutM
ulti") | 188 fb.BreakFeatures(errors.New("test error"), "PutM
ulti") |
| 189 | 189 |
| 190 _, err := svr.ArchiveStream(c, req) | 190 _, err := svr.ArchiveStream(c, req) |
| 191 So(err, ShouldBeRPCInternal) | 191 So(err, ShouldBeRPCInternal) |
| 192 }) | 192 }) |
| 193 }) | 193 }) |
| 194 }) | 194 }) |
| 195 } | 195 } |
| OLD | NEW |