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

Side by Side Diff: logdog/server/collector/utils_test.go

Issue 2435883002: LogDog: Fix archival Get/Tail implementations. (Closed)
Patch Set: LogDog: Fix archival Get/Tail implementations. Created 4 years, 2 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 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 collector 5 package collector
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "crypto/sha256" 9 "crypto/sha256"
10 "encoding/hex" 10 "encoding/hex"
11 "errors" 11 "errors"
12 "fmt" 12 "fmt"
13 "sort" 13 "sort"
14 "strings" 14 "strings"
15 "sync" 15 "sync"
16 16
17 "github.com/golang/protobuf/proto"
18 "github.com/luci/luci-go/common/clock" 17 "github.com/luci/luci-go/common/clock"
19 "github.com/luci/luci-go/common/config" 18 "github.com/luci/luci-go/common/config"
20 "github.com/luci/luci-go/common/proto/google" 19 "github.com/luci/luci-go/common/proto/google"
21 "github.com/luci/luci-go/logdog/api/logpb" 20 "github.com/luci/luci-go/logdog/api/logpb"
22 "github.com/luci/luci-go/logdog/client/butlerproto" 21 "github.com/luci/luci-go/logdog/client/butlerproto"
23 "github.com/luci/luci-go/logdog/common/storage" 22 "github.com/luci/luci-go/logdog/common/storage"
24 "github.com/luci/luci-go/logdog/common/types" 23 "github.com/luci/luci-go/logdog/common/types"
25 cc "github.com/luci/luci-go/logdog/server/collector/coordinator" 24 cc "github.com/luci/luci-go/logdog/server/collector/coordinator"
25
26 "golang.org/x/net/context" 26 "golang.org/x/net/context"
27 ) 27 )
28 28
29 var testSecret = bytes.Repeat([]byte{0x55}, types.PrefixSecretLength) 29 var testSecret = bytes.Repeat([]byte{0x55}, types.PrefixSecretLength)
30 30
31 type streamKey struct { 31 type streamKey struct {
32 project string 32 project string
33 id string 33 id string
34 } 34 }
35 35
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 expected = expected[2:] 294 expected = expected[2:]
295 295
296 // Load all entries for this stream. 296 // Load all entries for this stream.
297 req := storage.GetRequest{ 297 req := storage.GetRequest{
298 Project: config.ProjectName(project), 298 Project: config.ProjectName(project),
299 Path: types.StreamPath(name), 299 Path: types.StreamPath(name),
300 } 300 }
301 301
302 entries := make(map[int]*logpb.LogEntry) 302 entries := make(map[int]*logpb.LogEntry)
303 var ierr error 303 var ierr error
304 » err := st.Get(req, func(idx types.MessageIndex, d []byte) bool { 304 » err := st.Get(req, func(e *storage.Entry) bool {
305 » » le := logpb.LogEntry{} 305 » » var le *logpb.LogEntry
306 » » if ierr = proto.Unmarshal(d, &le); ierr != nil { 306 » » if le, ierr = e.GetLogEntry(); ierr != nil {
307 return false 307 return false
308 } 308 }
309 » » entries[int(idx)] = &le 309 » » entries[int(le.StreamIndex)] = le
310 return true 310 return true
311 }) 311 })
312 if ierr != nil { 312 if ierr != nil {
313 err = ierr 313 err = ierr
314 } 314 }
315 if err != nil && err != storage.ErrDoesNotExist { 315 if err != nil && err != storage.ErrDoesNotExist {
316 return fmt.Sprintf("error: %v", err) 316 return fmt.Sprintf("error: %v", err)
317 } 317 }
318 318
319 assertLogEntry := func(i int) string { 319 assertLogEntry := func(i int) string {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 if len(failed) > 0 { 371 if len(failed) > 0 {
372 return strings.Join(failed, ", ") 372 return strings.Join(failed, ", ")
373 } 373 }
374 return "" 374 return ""
375 } 375 }
376 376
377 func idFromPath(path string) string { 377 func idFromPath(path string) string {
378 hash := sha256.Sum256([]byte(path)) 378 hash := sha256.Sum256([]byte(path))
379 return hex.EncodeToString(hash[:]) 379 return hex.EncodeToString(hash[:])
380 } 380 }
OLDNEW
« logdog/common/storage/archive/storage.go ('K') | « logdog/server/archivist/storageSource.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698