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

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

Issue 1971493003: LogDog: Project READ access for user endpoints. (Closed) Base URL: https://github.com/luci/luci-go@logdog-project-service-config
Patch Set: Updated patchset dependency Created 4 years, 7 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/registerStream_test.go
diff --git a/appengine/logdog/coordinator/endpoints/services/registerStream_test.go b/appengine/logdog/coordinator/endpoints/services/registerStream_test.go
index c22bae5e915b249432bef146e1d28595d5c18a2b..303b0ba710775e7f44cb5fa7c1700c2f58f658d0 100644
--- a/appengine/logdog/coordinator/endpoints/services/registerStream_test.go
+++ b/appengine/logdog/coordinator/endpoints/services/registerStream_test.go
@@ -29,11 +29,17 @@ func TestRegisterStream(t *testing.T) {
Convey(`With a testing configuration`, t, func() {
c, env := ct.Install()
- env.ModServiceConfig(c, func(cfg *svcconfig.Coordinator) {
- cfg.ArchiveDelayMax = google.NewDuration(time.Hour)
- })
ds.Get(c).Testable().Consistent(true)
+ // Set our archival delays. The project delay is smaller than the service
+ // delay, so it should be used.
+ env.ModServiceConfig(c, func(cfg *svcconfig.Config) {
+ cfg.Coordinator.ArchiveDelayMax = google.NewDuration(24 * time.Hour)
+ })
+ env.ModProjectConfig(c, "proj-foo", func(pcfg *svcconfig.ProjectConfig) {
+ pcfg.MaxStreamAge = google.NewDuration(time.Hour)
+ })
+
svr := New()
Convey(`Returns Forbidden error if not a service.`, func() {
@@ -143,6 +149,46 @@ func TestRegisterStream(t *testing.T) {
})
})
+ Convey(`Will schedule the correct archival expiration delay`, func() {
+ Convey(`When there is no project config delay.`, func() {
+ env.ModProjectConfig(c, "proj-foo", func(pcfg *svcconfig.ProjectConfig) {
+ pcfg.MaxStreamAge = nil
+ })
+
+ _, err := svr.RegisterStream(c, &req)
+ So(err, ShouldBeRPCOK)
+ ds.Get(c).Testable().CatchupIndexes()
+
+ // The cleanup archival should be scheduled for 24 hours, so advance
+ // 12, confirm no archival, then advance another 12 and confirm that
+ // archival was tasked.
+ env.Clock.Add(12 * time.Hour)
+ env.DrainTumbleAll(c)
+ So(env.ArchivalPublisher.Hashes(), ShouldHaveLength, 0)
+
+ env.Clock.Add(12 * time.Hour)
+ env.DrainTumbleAll(c)
+ So(env.ArchivalPublisher.Hashes(), ShouldResemble, []string{string(tls.Stream.ID)})
+ })
+
+ Convey(`When there is no service or project config delay.`, func() {
+ env.ModServiceConfig(c, func(cfg *svcconfig.Config) {
+ cfg.Coordinator.ArchiveDelayMax = nil
+ })
+ env.ModProjectConfig(c, "proj-foo", func(pcfg *svcconfig.ProjectConfig) {
+ pcfg.MaxStreamAge = nil
+ })
+
+ _, err := svr.RegisterStream(c, &req)
+ So(err, ShouldBeRPCOK)
+ ds.Get(c).Testable().CatchupIndexes()
+
+ // The cleanup archival should be scheduled immediately.
+ env.DrainTumbleAll(c)
+ So(env.ArchivalPublisher.Hashes(), ShouldResemble, []string{string(tls.Stream.ID)})
+ })
+ })
+
Convey(`Returns internal server error if the datastore Get() fails.`, func() {
c, fb := featureBreaker.FilterRDS(c, nil)
fb.BreakFeatures(errors.New("test error"), "GetMulti")

Powered by Google App Engine
This is Rietveld 408576698