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

Side by Side Diff: server/internal/logdog/archivist/archivist_test.go

Issue 1874563005: Archivist asserts completeness through keys scan. (Closed) Base URL: https://github.com/luci/luci-go@logdog-storage-keysonly
Patch Set: Remove unused members. 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 archivist 5 package archivist
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "strings" 9 "strings"
10 "sync" 10 "sync"
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 ack, err := ar.archiveTaskImpl(c, task) 386 ack, err := ar.archiveTaskImpl(c, task)
387 So(err, ShouldErrLike, "completeness required, but strea m has no terminal index") 387 So(err, ShouldErrLike, "completeness required, but strea m has no terminal index")
388 So(ack, ShouldBeFalse) 388 So(ack, ShouldBeFalse)
389 }) 389 })
390 390
391 Convey(`With terminal index "3"`, func() { 391 Convey(`With terminal index "3"`, func() {
392 stream.State.TerminalIndex = 3 392 stream.State.TerminalIndex = 3
393 393
394 Convey(`Will fail not ACK a log stream with no entries.` , func() { 394 Convey(`Will fail not ACK a log stream with no entries.` , func() {
395 ack, err := ar.archiveTaskImpl(c, task) 395 ack, err := ar.archiveTaskImpl(c, task)
396 » » » » So(err, ShouldErrLike, "stream has missing entri es") 396 » » » » So(err, ShouldEqual, storage.ErrDoesNotExist)
397 So(ack, ShouldBeFalse) 397 So(ack, ShouldBeFalse)
398 }) 398 })
399 399
400 Convey(`Will fail to archive {0, 1, 2, 4} (incomplete).` , func() { 400 Convey(`Will fail to archive {0, 1, 2, 4} (incomplete).` , func() {
401 addTestEntry(0, 1, 2, 4) 401 addTestEntry(0, 1, 2, 4)
402 402
403 ack, err := ar.archiveTaskImpl(c, task) 403 ack, err := ar.archiveTaskImpl(c, task)
404 » » » » So(err, ShouldErrLike, "stream has missing entri es") 404 » » » » So(err, ShouldErrLike, "missing log entry")
405 So(ack, ShouldBeFalse) 405 So(ack, ShouldBeFalse)
406 }) 406 })
407 407
408 Convey(`Will successfully archive {0, 1, 2, 3, 4}, stopp ing at the terminal index.`, func() { 408 Convey(`Will successfully archive {0, 1, 2, 3, 4}, stopp ing at the terminal index.`, func() {
409 addTestEntry(0, 1, 2, 3, 4) 409 addTestEntry(0, 1, 2, 3, 4)
410 410
411 ack, err := ar.archiveTaskImpl(c, task) 411 ack, err := ar.archiveTaskImpl(c, task)
412 So(err, ShouldBeNil) 412 So(err, ShouldBeNil)
413 So(ack, ShouldBeTrue) 413 So(ack, ShouldBeTrue)
414 414
415 So(hasStreams(true, true, true), ShouldBeTrue) 415 So(hasStreams(true, true, true), ShouldBeTrue)
416 So(archiveRequest, ShouldResemble, &logdog.Archi veStreamRequest{ 416 So(archiveRequest, ShouldResemble, &logdog.Archi veStreamRequest{
417 Path: archiveTask.Path, 417 Path: archiveTask.Path,
418 LogEntryCount: 4, 418 LogEntryCount: 4,
419 TerminalIndex: 3, 419 TerminalIndex: 3,
420 420
421 StreamUrl: gsURL("logstream.entries"), 421 StreamUrl: gsURL("logstream.entries"),
422 IndexUrl: gsURL("logstream.index"), 422 IndexUrl: gsURL("logstream.index"),
423 DataUrl: gsURL("data.bin"), 423 DataUrl: gsURL("data.bin"),
424 }) 424 })
425 }) 425 })
426 426
427 » » » Convey(`When atransient archival error occurs, will not ACK it.`, func() { 427 » » » Convey(`When a transient archival error occurs, will not ACK it.`, func() {
428 » » » » addTestEntry(0, 1, 2, 3, 4)
428 gsc.newWriterErr = func(*testGSWriter) error { r eturn errors.WrapTransient(errors.New("test error")) } 429 gsc.newWriterErr = func(*testGSWriter) error { r eturn errors.WrapTransient(errors.New("test error")) }
429 430
430 ack, err := ar.archiveTaskImpl(c, task) 431 ack, err := ar.archiveTaskImpl(c, task)
431 So(err, ShouldErrLike, "test error") 432 So(err, ShouldErrLike, "test error")
432 So(ack, ShouldBeFalse) 433 So(ack, ShouldBeFalse)
433 }) 434 })
434 435
435 Convey(`When a non-transient archival error occurs`, fun c() { 436 Convey(`When a non-transient archival error occurs`, fun c() {
437 addTestEntry(0, 1, 2, 3, 4)
436 archiveErr := errors.New("archive failure error" ) 438 archiveErr := errors.New("archive failure error" )
437 gsc.newWriterErr = func(*testGSWriter) error { r eturn archiveErr } 439 gsc.newWriterErr = func(*testGSWriter) error { r eturn archiveErr }
438 440
439 Convey(`If remote report returns an error, do no t ACK.`, func() { 441 Convey(`If remote report returns an error, do no t ACK.`, func() {
440 archiveStreamErr = errors.New("test erro r") 442 archiveStreamErr = errors.New("test erro r")
441 443
442 ack, err := ar.archiveTaskImpl(c, task) 444 ack, err := ar.archiveTaskImpl(c, task)
443 So(err, ShouldErrLike, "test error") 445 So(err, ShouldErrLike, "test error")
444 So(ack, ShouldBeFalse) 446 So(ack, ShouldBeFalse)
445 447
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 ack, err := ar.archiveTaskImpl(c , task) 629 ack, err := ar.archiveTaskImpl(c , task)
628 So(err, ShouldErrLike, "test err or") 630 So(err, ShouldErrLike, "test err or")
629 So(ack, ShouldBeFalse) 631 So(ack, ShouldBeFalse)
630 So(archiveRequest, ShouldBeNil) 632 So(archiveRequest, ShouldBeNil)
631 }) 633 })
632 } 634 }
633 } 635 }
634 }) 636 })
635 }) 637 })
636 } 638 }
OLDNEW
« no previous file with comments | « server/internal/logdog/archivist/archivist.go ('k') | server/internal/logdog/archivist/storageSource.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698