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

Side by Side Diff: appengine/logdog/coordinator/endpoints/logs/get_test.go

Issue 1863973002: LogDog: Update to archival V2. (Closed) Base URL: https://github.com/luci/luci-go@grpcutil-errors
Patch Set: Minor fixes, works in dev now. Created 4 years, 8 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 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 fs := authtest.FakeState{} 155 fs := authtest.FakeState{}
156 c = auth.WithState(c, &fs) 156 c = auth.WithState(c, &fs)
157 157
158 c = ct.UseConfig(c, &svcconfig.Coordinator{ 158 c = ct.UseConfig(c, &svcconfig.Coordinator{
159 AdminAuthGroup: "test-administrators", 159 AdminAuthGroup: "test-administrators",
160 }) 160 })
161 161
162 // Generate our test stream. 162 // Generate our test stream.
163 desc := ct.TestLogStreamDescriptor(c, "foo/bar") 163 desc := ct.TestLogStreamDescriptor(c, "foo/bar")
164 ls := ct.TestLogStream(c, desc) 164 ls := ct.TestLogStream(c, desc)
165 » » if err := ls.Put(ds.Get(c)); err != nil { 165 » » if err := ds.Get(c).Put(ls); err != nil {
166 panic(err) 166 panic(err)
167 } 167 }
168 168
169 tc.Add(time.Second) 169 tc.Add(time.Second)
170 var entries []*logpb.LogEntry 170 var entries []*logpb.LogEntry
171 protobufs := map[uint64][]byte{} 171 protobufs := map[uint64][]byte{}
172 for _, v := range []int{0, 1, 2, 4, 5, 7} { 172 for _, v := range []int{0, 1, 2, 4, 5, 7} {
173 le := ct.TestLogEntry(c, ls, v) 173 le := ct.TestLogEntry(c, ls, v)
174 le.GetText().Lines = append(le.GetText().Lines, &logpb.T ext_Line{ 174 le.GetText().Lines = append(le.GetText().Lines, &logpb.T ext_Line{
175 Value: "another line of text", 175 Value: "another line of text",
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 Desc: desc, 273 Desc: desc,
274 Source: &src, 274 Source: &src,
275 LogWriter: &lbuf, 275 LogWriter: &lbuf,
276 IndexWriter: &ibuf, 276 IndexWriter: &ibuf,
277 StreamIndexRange: 2, 277 StreamIndexRange: 2,
278 } 278 }
279 if err := archive.Archive(m); err != nil { 279 if err := archive.Archive(m); err != nil {
280 panic(err) 280 panic(err)
281 } 281 }
282 282
283 now := tc.Now().UTC()
284
283 gsc.put("testbucket", "stream", lbuf.Byt es()) 285 gsc.put("testbucket", "stream", lbuf.Byt es())
284 gsc.put("testbucket", "index", ibuf.Byte s()) 286 gsc.put("testbucket", "index", ibuf.Byte s())
285 ls.State = coordinator.LSArchived 287 ls.State = coordinator.LSArchived
288 ls.TerminatedTime = now
289 ls.ArchivedTime = now
286 ls.ArchiveStreamURL = "gs://testbucket/s tream" 290 ls.ArchiveStreamURL = "gs://testbucket/s tream"
287 ls.ArchiveIndexURL = "gs://testbucket/in dex" 291 ls.ArchiveIndexURL = "gs://testbucket/in dex"
288 } 292 }
289 » » » » if err := ls.Put(ds.Get(c)); err != nil { 293 » » » » if err := ds.Get(c).Put(ls); err != nil {
290 panic(err) 294 panic(err)
291 } 295 }
292 296
293 Convey(`Testing Get requests`, func() { 297 Convey(`Testing Get requests`, func() {
294 req := logdog.GetRequest{ 298 req := logdog.GetRequest{
295 Path: string(ls.Path()), 299 Path: string(ls.Path()),
296 } 300 }
297 301
298 Convey(`When the log stream is purged`, func() { 302 Convey(`When the log stream is purged`, func() {
299 ls.Purged = true 303 ls.Purged = true
300 » » » » » » if err := ls.Put(ds.Get(c)); err != nil { 304 » » » » » » if err := ds.Get(c).Put(ls); err != nil {
301 panic(err) 305 panic(err)
302 } 306 }
303 307
304 Convey(`Will return NotFound if the user is not an administrator.`, func() { 308 Convey(`Will return NotFound if the user is not an administrator.`, func() {
305 _, err := s.Get(c, &req) 309 _, err := s.Get(c, &req)
306 So(err, ShouldBeRPCNotFo und) 310 So(err, ShouldBeRPCNotFo und)
307 }) 311 })
308 312
309 Convey(`Will process the request if the user is an administrator.`, func() { 313 Convey(`Will process the request if the user is an administrator.`, func() {
310 fs.IdentityGroups = []st ring{"test-administrators"} 314 fs.IdentityGroups = []st ring{"test-administrators"}
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 req.LogCount = -1 419 req.LogCount = -1
416 420
417 Convey(`Will successfully retrie ve stream state.`, func() { 421 Convey(`Will successfully retrie ve stream state.`, func() {
418 resp, err := s.Get(c, &r eq) 422 resp, err := s.Get(c, &r eq)
419 So(err, ShouldBeRPCOK) 423 So(err, ShouldBeRPCOK)
420 So(resp.State, ShouldRes emble, loadLogStreamState(ls)) 424 So(resp.State, ShouldRes emble, loadLogStreamState(ls))
421 So(len(resp.Logs), Shoul dEqual, 0) 425 So(len(resp.Logs), Shoul dEqual, 0)
422 }) 426 })
423 427
424 Convey(`Will return Internal if the protobuf descriptor data is corrupt.`, func() { 428 Convey(`Will return Internal if the protobuf descriptor data is corrupt.`, func() {
425 » » » » » » » // We can't use "ls.Put" here because it validates the protobuf! 429 » » » » » » » ls.SetDSValidate(false)
426 ls.Descriptor = []byte{0 x00} // Invalid protobuf, zero tag. 430 ls.Descriptor = []byte{0 x00} // Invalid protobuf, zero tag.
427 if err := ds.Get(c).Put( ls); err != nil { 431 if err := ds.Get(c).Put( ls); err != nil {
428 panic(err) 432 panic(err)
429 } 433 }
430 434
431 _, err := s.Get(c, &req) 435 _, err := s.Get(c, &req)
432 So(err, ShouldBeRPCInter nal) 436 So(err, ShouldBeRPCInter nal)
433 }) 437 })
434 }) 438 })
435 439
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 resp, err := s.Tail(c, &req) 573 resp, err := s.Tail(c, &req)
570 So(err, ShouldBeRPCOK) 574 So(err, ShouldBeRPCOK)
571 So(resp, shouldHaveLogs, 7) 575 So(resp, shouldHaveLogs, 7)
572 So(resp.State, ShouldResemble, l oadLogStreamState(ls)) 576 So(resp.State, ShouldResemble, l oadLogStreamState(ls))
573 }) 577 })
574 }) 578 })
575 }) 579 })
576 } 580 }
577 }) 581 })
578 } 582 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698