| Index: appengine/logdog/coordinator/endpoints/services/archiveStream_test.go
|
| diff --git a/appengine/logdog/coordinator/endpoints/services/archiveStream_test.go b/appengine/logdog/coordinator/endpoints/services/archiveStream_test.go
|
| index 512f2c1226e0f14e7995145f052badb8a6914324..3232e89e0bc41c2dd0c8993da200c9e6bfb1bd87 100644
|
| --- a/appengine/logdog/coordinator/endpoints/services/archiveStream_test.go
|
| +++ b/appengine/logdog/coordinator/endpoints/services/archiveStream_test.go
|
| @@ -14,10 +14,12 @@ import (
|
| "github.com/luci/luci-go/appengine/logdog/coordinator"
|
| ct "github.com/luci/luci-go/appengine/logdog/coordinator/coordinatorTest"
|
| "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1"
|
| + "github.com/luci/luci-go/common/logging/gologger"
|
| "github.com/luci/luci-go/common/proto/logdog/svcconfig"
|
| "github.com/luci/luci-go/server/auth"
|
| "github.com/luci/luci-go/server/auth/authtest"
|
| "golang.org/x/net/context"
|
| + "google.golang.org/grpc/codes"
|
|
|
| . "github.com/luci/luci-go/common/testing/assertions"
|
| . "github.com/smartystreets/goconvey/convey"
|
| @@ -28,6 +30,7 @@ func TestArchiveStream(t *testing.T) {
|
|
|
| Convey(`With a testing configuration`, t, func() {
|
| c := memory.Use(context.Background())
|
| + c = gologger.Use(c)
|
| be := Server{}
|
|
|
| c = ct.UseConfig(c, &svcconfig.Coordinator{
|
| @@ -113,6 +116,34 @@ func TestArchiveStream(t *testing.T) {
|
| So(ls.TerminalIndex, ShouldEqual, 1337)
|
| })
|
|
|
| + Convey(`If the archive has failed`, func() {
|
| + req.Error = true
|
| +
|
| + Convey(`If the stream is below error threshold, will increment error count and return FailedPrecondition.`, func() {
|
| + ls.ArchiveErrors = 0
|
| + So(ls.ArchiveErrors, ShouldBeLessThan, maxArchiveErrors)
|
| + So(ls.Put(ds.Get(c)), ShouldBeNil)
|
| +
|
| + _, err := be.ArchiveStream(c, req)
|
| + So(err, ShouldHaveRPCCode, codes.FailedPrecondition)
|
| +
|
| + So(ds.Get(c).Get(ls), ShouldBeNil)
|
| + So(ls.Archived(), ShouldBeFalse)
|
| + So(ls.ArchiveErrors, ShouldEqual, 1)
|
| + })
|
| +
|
| + Convey(`If the stream is above error threshold, will succeed.`, func() {
|
| + ls.ArchiveErrors = maxArchiveErrors
|
| + So(ls.Put(ds.Get(c)), ShouldBeNil)
|
| +
|
| + _, err := be.ArchiveStream(c, req)
|
| + So(err, ShouldBeNil)
|
| + So(ds.Get(c).Get(ls), ShouldBeNil)
|
| + So(ls.Archived(), ShouldBeTrue)
|
| + So(ls.TerminalIndex, ShouldEqual, 13)
|
| + })
|
| + })
|
| +
|
| Convey(`When datastore Get fails, returns internal error.`, func() {
|
| c, fb := featureBreaker.FilterRDS(c, nil)
|
| fb.BreakFeatures(errors.New("test error"), "GetMulti")
|
|
|