| OLD | NEW |
| 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 archivist | 5 package archivist |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "strings" | 9 "strings" |
| 10 "sync" | 10 "sync" |
| 11 "testing" | 11 "testing" |
| 12 "time" | 12 "time" |
| 13 | 13 |
| 14 "github.com/golang/protobuf/proto" | 14 "github.com/golang/protobuf/proto" |
| 15 "github.com/luci/luci-go/common/clock/testclock" | 15 "github.com/luci/luci-go/common/clock/testclock" |
| 16 "github.com/luci/luci-go/common/config" | |
| 17 "github.com/luci/luci-go/common/errors" | 16 "github.com/luci/luci-go/common/errors" |
| 18 "github.com/luci/luci-go/common/gcloud/gs" | 17 "github.com/luci/luci-go/common/gcloud/gs" |
| 19 "github.com/luci/luci-go/common/proto/google" | 18 "github.com/luci/luci-go/common/proto/google" |
| 20 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/services/v1" | 19 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/services/v1" |
| 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/common/storage" | 21 "github.com/luci/luci-go/logdog/common/storage" |
| 23 "github.com/luci/luci-go/logdog/common/storage/memory" | 22 "github.com/luci/luci-go/logdog/common/storage/memory" |
| 24 "github.com/luci/luci-go/logdog/common/types" | 23 "github.com/luci/luci-go/logdog/common/types" |
| 24 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 25 "golang.org/x/net/context" | 25 "golang.org/x/net/context" |
| 26 "google.golang.org/grpc" | 26 "google.golang.org/grpc" |
| 27 | 27 |
| 28 . "github.com/luci/luci-go/common/testing/assertions" | 28 . "github.com/luci/luci-go/common/testing/assertions" |
| 29 . "github.com/smartystreets/goconvey/convey" | 29 . "github.com/smartystreets/goconvey/convey" |
| 30 ) | 30 ) |
| 31 | 31 |
| 32 // testTask is an instrumentable Task implementation. | 32 // testTask is an instrumentable Task implementation. |
| 33 type testTask struct { | 33 type testTask struct { |
| 34 task *logdog.ArchiveTask | 34 task *logdog.ArchiveTask |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 }, | 229 }, |
| 230 }}, | 230 }}, |
| 231 } | 231 } |
| 232 | 232 |
| 233 d, err := proto.Marshal(&le) | 233 d, err := proto.Marshal(&le) |
| 234 if err != nil { | 234 if err != nil { |
| 235 panic(err) | 235 panic(err) |
| 236 } | 236 } |
| 237 | 237 |
| 238 err = st.Put(storage.PutRequest{ | 238 err = st.Put(storage.PutRequest{ |
| 239 » » » » » Project: config.ProjectName(p), | 239 » » » » » Project: cfgtypes.ProjectName(p), |
| 240 Path: desc.Path(), | 240 Path: desc.Path(), |
| 241 Index: types.MessageIndex(v), | 241 Index: types.MessageIndex(v), |
| 242 Values: [][]byte{d}, | 242 Values: [][]byte{d}, |
| 243 }) | 243 }) |
| 244 if err != nil { | 244 if err != nil { |
| 245 panic(err) | 245 panic(err) |
| 246 } | 246 } |
| 247 | 247 |
| 248 // Advance the time for each log entry. | 248 // Advance the time for each log entry. |
| 249 tc.Add(time.Second) | 249 tc.Add(time.Second) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 return archiveStreamErr | 302 return archiveStreamErr |
| 303 }, | 303 }, |
| 304 } | 304 } |
| 305 | 305 |
| 306 stBase := Settings{ | 306 stBase := Settings{ |
| 307 AlwaysRender: true, | 307 AlwaysRender: true, |
| 308 } | 308 } |
| 309 | 309 |
| 310 ar := Archivist{ | 310 ar := Archivist{ |
| 311 Service: &sc, | 311 Service: &sc, |
| 312 » » » SettingsLoader: func(c context.Context, proj config.Proj
ectName) (*Settings, error) { | 312 » » » SettingsLoader: func(c context.Context, proj cfgtypes.Pr
ojectName) (*Settings, error) { |
| 313 // Extra slashes to test concatenation,. | 313 // Extra slashes to test concatenation,. |
| 314 st := stBase | 314 st := stBase |
| 315 st.GSBase = gs.Path(fmt.Sprintf("gs://archival/%
s/path/to/archive/", proj)) | 315 st.GSBase = gs.Path(fmt.Sprintf("gs://archival/%
s/path/to/archive/", proj)) |
| 316 st.GSStagingBase = gs.Path(fmt.Sprintf("gs://arc
hival-staging/%s/path/to/archive/", proj)) | 316 st.GSStagingBase = gs.Path(fmt.Sprintf("gs://arc
hival-staging/%s/path/to/archive/", proj)) |
| 317 return &st, nil | 317 return &st, nil |
| 318 }, | 318 }, |
| 319 Storage: &st, | 319 Storage: &st, |
| 320 GSClient: &gsc, | 320 GSClient: &gsc, |
| 321 } | 321 } |
| 322 | 322 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 | 726 |
| 727 So(ar.archiveTaskImpl(c, task),
ShouldErrLike, "test error") | 727 So(ar.archiveTaskImpl(c, task),
ShouldErrLike, "test error") |
| 728 So(task.consumed, ShouldBeFalse) | 728 So(task.consumed, ShouldBeFalse) |
| 729 So(archiveRequest, ShouldBeNil) | 729 So(archiveRequest, ShouldBeNil) |
| 730 }) | 730 }) |
| 731 } | 731 } |
| 732 } | 732 } |
| 733 }) | 733 }) |
| 734 }) | 734 }) |
| 735 } | 735 } |
| OLD | NEW |