| 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 logs | 5 package logs |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "errors" | 9 "errors" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 "github.com/luci/luci-go/common/clock/testclock" | 23 "github.com/luci/luci-go/common/clock/testclock" |
| 24 "github.com/luci/luci-go/common/gcloud/gs" | 24 "github.com/luci/luci-go/common/gcloud/gs" |
| 25 "github.com/luci/luci-go/common/iotools" | 25 "github.com/luci/luci-go/common/iotools" |
| 26 "github.com/luci/luci-go/common/logdog/types" | 26 "github.com/luci/luci-go/common/logdog/types" |
| 27 "github.com/luci/luci-go/common/proto/logdog/logpb" | 27 "github.com/luci/luci-go/common/proto/logdog/logpb" |
| 28 "github.com/luci/luci-go/common/proto/logdog/svcconfig" | 28 "github.com/luci/luci-go/common/proto/logdog/svcconfig" |
| 29 "github.com/luci/luci-go/common/recordio" | 29 "github.com/luci/luci-go/common/recordio" |
| 30 "github.com/luci/luci-go/server/auth" | 30 "github.com/luci/luci-go/server/auth" |
| 31 "github.com/luci/luci-go/server/auth/authtest" | 31 "github.com/luci/luci-go/server/auth/authtest" |
| 32 "github.com/luci/luci-go/server/logdog/storage" | 32 "github.com/luci/luci-go/server/logdog/storage" |
| 33 ast "github.com/luci/luci-go/server/logdog/storage/archive" |
| 33 memoryStorage "github.com/luci/luci-go/server/logdog/storage/memory" | 34 memoryStorage "github.com/luci/luci-go/server/logdog/storage/memory" |
| 34 "golang.org/x/net/context" | 35 "golang.org/x/net/context" |
| 35 | 36 |
| 36 . "github.com/luci/luci-go/common/testing/assertions" | 37 . "github.com/luci/luci-go/common/testing/assertions" |
| 37 . "github.com/smartystreets/goconvey/convey" | 38 . "github.com/smartystreets/goconvey/convey" |
| 38 ) | 39 ) |
| 39 | 40 |
| 40 type staticArchiveSource []*logpb.LogEntry | 41 type staticArchiveSource []*logpb.LogEntry |
| 41 | 42 |
| 42 func (s *staticArchiveSource) NextLogEntry() (le *logpb.LogEntry, err error) { | 43 func (s *staticArchiveSource) NextLogEntry() (le *logpb.LogEntry, err error) { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 panic(err) | 206 panic(err) |
| 206 } | 207 } |
| 207 protobufs[uint64(v)] = d | 208 protobufs[uint64(v)] = d |
| 208 } | 209 } |
| 209 | 210 |
| 210 // Define and populate our Storage. | 211 // Define and populate our Storage. |
| 211 s := Server{} | 212 s := Server{} |
| 212 | 213 |
| 213 ms := memoryStorage.Storage{} | 214 ms := memoryStorage.Storage{} |
| 214 gsc := testGSClient{} | 215 gsc := testGSClient{} |
| 215 » » s.StorageFunc = func(context.Context) (storage.Storage, error) { | 216 » » s.IntermediateStorageFunc = func(c context.Context) (storage.Sto
rage, error) { |
| 216 return &ms, nil | 217 return &ms, nil |
| 217 } | 218 } |
| 218 » » s.GSClientFunc = func(context.Context) (gs.Client, error) { | 219 » » s.ArchiveStorageFunc = func(c context.Context, ls *coordinator.L
ogStream) (storage.Storage, error) { |
| 219 » » » return gsc, nil | 220 » » » return ast.New(c, ast.Options{ |
| 221 » » » » IndexURL: ls.ArchiveIndexURL, |
| 222 » » » » StreamURL: ls.ArchiveStreamURL, |
| 223 » » » » Client: &gsc, |
| 224 » » » }) |
| 220 } | 225 } |
| 221 | 226 |
| 222 Convey(`Testing Get requests (no logs)`, func() { | 227 Convey(`Testing Get requests (no logs)`, func() { |
| 223 req := logs.GetRequest{ | 228 req := logs.GetRequest{ |
| 224 Path: string(ls.Path()), | 229 Path: string(ls.Path()), |
| 225 } | 230 } |
| 226 | 231 |
| 227 Convey(`Will fail if the Path is not a stream path or a
hash.`, func() { | 232 Convey(`Will fail if the Path is not a stream path or a
hash.`, func() { |
| 228 req.Path = "not/a/full/stream/path" | 233 req.Path = "not/a/full/stream/path" |
| 229 _, err := s.Get(c, &req) | 234 _, err := s.Get(c, &req) |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 resp, err := s.Tail(c, &req) | 577 resp, err := s.Tail(c, &req) |
| 573 So(err, ShouldBeRPCOK) | 578 So(err, ShouldBeRPCOK) |
| 574 So(resp, shouldHaveLogs, 7) | 579 So(resp, shouldHaveLogs, 7) |
| 575 So(resp.State, ShouldResemble, l
oadLogStreamState(ls)) | 580 So(resp.State, ShouldResemble, l
oadLogStreamState(ls)) |
| 576 }) | 581 }) |
| 577 }) | 582 }) |
| 578 }) | 583 }) |
| 579 } | 584 } |
| 580 }) | 585 }) |
| 581 } | 586 } |
| OLD | NEW |