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

Side by Side Diff: common/logdog/coordinator/stream_test.go

Issue 1863973002: LogDog: Update to archival V2. (Closed) Base URL: https://github.com/luci/luci-go@grpcutil-errors
Patch Set: Fix proto comment. Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « common/logdog/coordinator/stream.go ('k') | common/proto/logdog/svcconfig/config.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package coordinator 5 package coordinator
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "testing" 9 "testing"
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 var ls LogStream 158 var ls LogStream
159 p = p.State(&ls) 159 p = p.State(&ls)
160 160
161 svc.GH = func(*logdog.GetRequest) (*logd og.GetResponse, error) { 161 svc.GH = func(*logdog.GetRequest) (*logd og.GetResponse, error) {
162 return &logdog.GetResponse{ 162 return &logdog.GetResponse{
163 Logs: []*logpb.LogEntry{ 163 Logs: []*logpb.LogEntry{
164 genLog(1337, "kt hxbye"), 164 genLog(1337, "kt hxbye"),
165 }, 165 },
166 State: &logdog.LogStream State{ 166 State: &logdog.LogStream State{
167 Created: google. NewTimestamp(now), 167 Created: google. NewTimestamp(now),
168 Updated: google. NewTimestamp(now),
169 Archive: &logdog .LogStreamState_ArchiveInfo{ 168 Archive: &logdog .LogStreamState_ArchiveInfo{
170 IndexUrl : "index", 169 IndexUrl : "index",
171 StreamUr l: "stream", 170 StreamUr l: "stream",
172 DataUrl: "data", 171 DataUrl: "data",
173 }, 172 },
174 }, 173 },
175 Desc: &logpb.LogStreamDe scriptor{ 174 Desc: &logpb.LogStreamDe scriptor{
176 Prefix: "tes t", 175 Prefix: "tes t",
177 Name: "a", 176 Name: "a",
178 StreamType: logp b.StreamType_TEXT, 177 StreamType: logp b.StreamType_TEXT,
179 }, 178 },
180 }, nil 179 }, nil
181 } 180 }
182 181
183 l, err := s.Get(c, p) 182 l, err := s.Get(c, p)
184 So(err, ShouldBeNil) 183 So(err, ShouldBeNil)
185 So(l, ShouldResemble, []*logpb.LogEntry{ genLog(1337, "kthxbye")}) 184 So(l, ShouldResemble, []*logpb.LogEntry{ genLog(1337, "kthxbye")})
186 So(ls, ShouldResemble, LogStream{ 185 So(ls, ShouldResemble, LogStream{
187 Path: "test/+/a", 186 Path: "test/+/a",
188 Desc: &logpb.LogStreamDescriptor { 187 Desc: &logpb.LogStreamDescriptor {
189 Prefix: "test", 188 Prefix: "test",
190 Name: "a", 189 Name: "a",
191 StreamType: logpb.Stream Type_TEXT, 190 StreamType: logpb.Stream Type_TEXT,
192 }, 191 },
193 State: &StreamState{ 192 State: &StreamState{
194 Created: now, 193 Created: now,
195 Updated: now,
196 Archived: true, 194 Archived: true,
197 ArchiveIndexURL: "index ", 195 ArchiveIndexURL: "index ",
198 ArchiveStreamURL: "strea m", 196 ArchiveStreamURL: "strea m",
199 ArchiveDataURL: "data" , 197 ArchiveDataURL: "data" ,
200 }, 198 },
201 }) 199 })
202 }) 200 })
203 201
204 Convey(`Will return ErrNoSuchStream if the strea m is not found.`, func() { 202 Convey(`Will return ErrNoSuchStream if the strea m is not found.`, func() {
205 svc.GH = func(*logdog.GetRequest) (*logd og.GetResponse, error) { 203 svc.GH = func(*logdog.GetRequest) (*logd og.GetResponse, error) {
(...skipping 22 matching lines...) Expand all
228 So(err, ShouldEqual, ErrNoAccess) 226 So(err, ShouldEqual, ErrNoAccess)
229 }) 227 })
230 }) 228 })
231 229
232 Convey(`Test State`, func() { 230 Convey(`Test State`, func() {
233 Convey(`Will request just the state if asked.`, func() { 231 Convey(`Will request just the state if asked.`, func() {
234 svc.GH = func(*logdog.GetRequest) (*logd og.GetResponse, error) { 232 svc.GH = func(*logdog.GetRequest) (*logd og.GetResponse, error) {
235 return &logdog.GetResponse{ 233 return &logdog.GetResponse{
236 State: &logdog.LogStream State{ 234 State: &logdog.LogStream State{
237 Created: google. NewTimestamp(now), 235 Created: google. NewTimestamp(now),
238 Updated: google. NewTimestamp(now),
239 }, 236 },
240 }, nil 237 }, nil
241 } 238 }
242 239
243 l, err := s.State(c) 240 l, err := s.State(c)
244 So(err, ShouldBeNil) 241 So(err, ShouldBeNil)
245 So(l, ShouldResemble, &LogStream{ 242 So(l, ShouldResemble, &LogStream{
246 Path: "test/+/a", 243 Path: "test/+/a",
247 State: &StreamState{ 244 State: &StreamState{
248 Created: now.UTC(), 245 Created: now.UTC(),
249 Updated: now.UTC(),
250 }, 246 },
251 }) 247 })
252 248
253 // Validate the HTTP request that we mad e. 249 // Validate the HTTP request that we mad e.
254 So(svc.GR, ShouldResemble, logdog.GetReq uest{ 250 So(svc.GR, ShouldResemble, logdog.GetReq uest{
255 Path: "test/+/a", 251 Path: "test/+/a",
256 LogCount: -1, 252 LogCount: -1,
257 State: true, 253 State: true,
258 }) 254 })
259 }) 255 })
(...skipping 25 matching lines...) Expand all
285 So(err, ShouldEqual, ErrNoAccess) 281 So(err, ShouldEqual, ErrNoAccess)
286 }) 282 })
287 }) 283 })
288 284
289 Convey(`Test Tail`, func() { 285 Convey(`Test Tail`, func() {
290 Convey(`Will form a proper Tail query.`, func() { 286 Convey(`Will form a proper Tail query.`, func() {
291 svc.TH = func(*logdog.TailRequest) (*log dog.GetResponse, error) { 287 svc.TH = func(*logdog.TailRequest) (*log dog.GetResponse, error) {
292 return &logdog.GetResponse{ 288 return &logdog.GetResponse{
293 State: &logdog.LogStream State{ 289 State: &logdog.LogStream State{
294 Created: google. NewTimestamp(now), 290 Created: google. NewTimestamp(now),
295 Updated: google. NewTimestamp(now),
296 }, 291 },
297 Desc: &logpb.LogStreamDe scriptor{ 292 Desc: &logpb.LogStreamDe scriptor{
298 Prefix: "tes t", 293 Prefix: "tes t",
299 Name: "a", 294 Name: "a",
300 StreamType: logp b.StreamType_TEXT, 295 StreamType: logp b.StreamType_TEXT,
301 }, 296 },
302 Logs: []*logpb.LogEntry{ 297 Logs: []*logpb.LogEntry{
303 genLog(1337, "kt hxbye"), 298 genLog(1337, "kt hxbye"),
304 }, 299 },
305 }, nil 300 }, nil
(...skipping 13 matching lines...) Expand all
319 So(l, ShouldResemble, genLog(1337, "kthx bye")) 314 So(l, ShouldResemble, genLog(1337, "kthx bye"))
320 So(ls, ShouldResemble, LogStream{ 315 So(ls, ShouldResemble, LogStream{
321 Path: "test/+/a", 316 Path: "test/+/a",
322 Desc: &logpb.LogStreamDescriptor { 317 Desc: &logpb.LogStreamDescriptor {
323 Prefix: "test", 318 Prefix: "test",
324 Name: "a", 319 Name: "a",
325 StreamType: logpb.Stream Type_TEXT, 320 StreamType: logpb.Stream Type_TEXT,
326 }, 321 },
327 State: &StreamState{ 322 State: &StreamState{
328 Created: now, 323 Created: now,
329 Updated: now,
330 }, 324 },
331 }) 325 })
332 }) 326 })
333 327
334 Convey(`Will return nil with state if no logs ar e returned from the endpoint.`, func() { 328 Convey(`Will return nil with state if no logs ar e returned from the endpoint.`, func() {
335 svc.TH = func(*logdog.TailRequest) (*log dog.GetResponse, error) { 329 svc.TH = func(*logdog.TailRequest) (*log dog.GetResponse, error) {
336 return &logdog.GetResponse{ 330 return &logdog.GetResponse{
337 State: &logdog.LogStream State{ 331 State: &logdog.LogStream State{
338 Created: google. NewTimestamp(now), 332 Created: google. NewTimestamp(now),
339 Updated: google. NewTimestamp(now),
340 }, 333 },
341 Desc: &logpb.LogStreamDe scriptor{ 334 Desc: &logpb.LogStreamDe scriptor{
342 Prefix: "tes t", 335 Prefix: "tes t",
343 Name: "a", 336 Name: "a",
344 StreamType: logp b.StreamType_TEXT, 337 StreamType: logp b.StreamType_TEXT,
345 }, 338 },
346 }, nil 339 }, nil
347 } 340 }
348 341
349 var ls LogStream 342 var ls LogStream
350 l, err := s.Tail(c, &ls) 343 l, err := s.Tail(c, &ls)
351 So(err, ShouldBeNil) 344 So(err, ShouldBeNil)
352 So(l, ShouldBeNil) 345 So(l, ShouldBeNil)
353 So(ls, ShouldResemble, LogStream{ 346 So(ls, ShouldResemble, LogStream{
354 Path: "test/+/a", 347 Path: "test/+/a",
355 Desc: &logpb.LogStreamDescriptor { 348 Desc: &logpb.LogStreamDescriptor {
356 Prefix: "test", 349 Prefix: "test",
357 Name: "a", 350 Name: "a",
358 StreamType: logpb.Stream Type_TEXT, 351 StreamType: logpb.Stream Type_TEXT,
359 }, 352 },
360 State: &StreamState{ 353 State: &StreamState{
361 Created: now, 354 Created: now,
362 Updated: now,
363 }, 355 },
364 }) 356 })
365 }) 357 })
366 358
367 Convey(`Will error if multiple logs are returned from the endpoint.`, func() { 359 Convey(`Will error if multiple logs are returned from the endpoint.`, func() {
368 svc.TH = func(*logdog.TailRequest) (*log dog.GetResponse, error) { 360 svc.TH = func(*logdog.TailRequest) (*log dog.GetResponse, error) {
369 return &logdog.GetResponse{ 361 return &logdog.GetResponse{
370 State: &logdog.LogStream State{ 362 State: &logdog.LogStream State{
371 Created: google. NewTimestamp(now), 363 Created: google. NewTimestamp(now),
372 Updated: google. NewTimestamp(now),
373 }, 364 },
374 Logs: []*logpb.LogEntry{ 365 Logs: []*logpb.LogEntry{
375 genLog(1337, "oh ai"), 366 genLog(1337, "oh ai"),
376 genLog(1338, "kt hxbye"), 367 genLog(1338, "kt hxbye"),
377 }, 368 },
378 }, nil 369 }, nil
379 } 370 }
380 371
381 _, err := s.Tail(c, nil) 372 _, err := s.Tail(c, nil)
382 So(err, ShouldErrLike, "tail call return ed 2 logs") 373 So(err, ShouldErrLike, "tail call return ed 2 logs")
(...skipping 22 matching lines...) Expand all
405 return nil, grpcutil.PermissionD enied 396 return nil, grpcutil.PermissionD enied
406 } 397 }
407 398
408 _, err := s.Tail(c, nil) 399 _, err := s.Tail(c, nil)
409 So(err, ShouldEqual, ErrNoAccess) 400 So(err, ShouldEqual, ErrNoAccess)
410 }) 401 })
411 }) 402 })
412 }) 403 })
413 }) 404 })
414 } 405 }
OLDNEW
« no previous file with comments | « common/logdog/coordinator/stream.go ('k') | common/proto/logdog/svcconfig/config.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698