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") |