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

Unified Diff: appengine/logdog/coordinator/endpoints/services/archiveStream_test.go

Issue 1853433002: LogDog: Handle archive failures. (Closed) Base URL: https://github.com/luci/luci-go@logdog-gs-update
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
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")

Powered by Google App Engine
This is Rietveld 408576698