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

Unified Diff: logdog/server/archivist/archivist_test.go

Issue 2321173002: LogDog/Archivist: Conditionally render data. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « logdog/server/archivist/archivist.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/server/archivist/archivist_test.go
diff --git a/logdog/server/archivist/archivist_test.go b/logdog/server/archivist/archivist_test.go
index 38fcd4fbf28da9dfb3a904c0c4bb5ae40289daa2..d2d1bf96449046341094dd74bdb24584eec8a9e8 100644
--- a/logdog/server/archivist/archivist_test.go
+++ b/logdog/server/archivist/archivist_test.go
@@ -210,13 +210,8 @@ func TestHandleArchive(t *testing.T) {
// Set up our test log stream.
project := "test-project"
desc := logpb.LogStreamDescriptor{
- Prefix: "testing",
- Name: "foo",
- BinaryFileExt: "bin",
- }
- descBytes, err := proto.Marshal(&desc)
- if err != nil {
- panic(err)
+ Prefix: "testing",
+ Name: "foo",
}
// Utility function to add a log entry for "ls".
@@ -280,13 +275,22 @@ func TestHandleArchive(t *testing.T) {
Archived: false,
Purged: false,
},
- Desc: descBytes,
// Age is ON the expiration threshold, so not expired.
Age: archiveTask.CompletePeriod,
ArchivalKey: archiveTask.Key,
}
+ // Allow tests to modify the log stream descriptor.
+ reloadDesc := func() {
+ descBytes, err := proto.Marshal(&desc)
+ if err != nil {
+ panic(err)
+ }
+ stream.Desc = descBytes
+ }
+ reloadDesc()
+
var archiveRequest *logdog.ArchiveStreamRequest
var archiveStreamErr error
sc := testServicesClient{
@@ -299,7 +303,9 @@ func TestHandleArchive(t *testing.T) {
},
}
- stBase := Settings{}
+ stBase := Settings{
+ AlwaysRender: true,
+ }
ar := Archivist{
Service: &sc,
@@ -592,6 +598,49 @@ func TestHandleArchive(t *testing.T) {
})
})
+ Convey(`When not configured to always render`, func() {
+ stBase.AlwaysRender = false
+
+ addTestEntry(project, 0, 1, 2, 3, 4)
+ stream.State.TerminalIndex = 4
+
+ Convey(`Will not emit a data stream if no binary file extension is specified.`, func() {
+ So(ar.archiveTaskImpl(c, task), ShouldBeNil)
+ So(task.consumed, ShouldBeTrue)
+
+ So(hasStreams(true, true, false), ShouldBeTrue)
+ So(archiveRequest, ShouldResemble, &logdog.ArchiveStreamRequest{
+ Project: project,
+ Id: archiveTask.Id,
+ LogEntryCount: 5,
+ TerminalIndex: 4,
+
+ StreamUrl: gsURL(project, "logstream.entries"),
+ IndexUrl: gsURL(project, "logstream.index"),
+ })
+ })
+
+ Convey(`Will emit a data stream if a binary file extension is specified.`, func() {
+ desc.BinaryFileExt = "foobar"
+ reloadDesc()
+
+ So(ar.archiveTaskImpl(c, task), ShouldBeNil)
+ So(task.consumed, ShouldBeTrue)
+
+ So(hasStreams(true, true, true), ShouldBeTrue)
+ So(archiveRequest, ShouldResemble, &logdog.ArchiveStreamRequest{
+ Project: project,
+ Id: archiveTask.Id,
+ LogEntryCount: 5,
+ TerminalIndex: 4,
+
+ StreamUrl: gsURL(project, "logstream.entries"),
+ IndexUrl: gsURL(project, "logstream.index"),
+ DataUrl: gsURL(project, "data.foobar"),
+ })
+ })
+ })
+
Convey(`With an empty project name, will fail and consume the task.`, func() {
archiveTask.Project = ""
« no previous file with comments | « logdog/server/archivist/archivist.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698