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

Side by Side Diff: dm/appengine/deps/walk_graph_test.go

Issue 2344893010: Fix walk graph to recurse correctly. (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 unified diff | Download patch
« no previous file with comments | « dm/appengine/deps/walk_graph.go ('k') | no next file » | 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 LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package deps 5 package deps
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 "time" 10 "time"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 func TestWalkGraph(t *testing.T) { 47 func TestWalkGraph(t *testing.T) {
48 t.Parallel() 48 t.Parallel()
49 49
50 Convey("WalkGraph", t, func() { 50 Convey("WalkGraph", t, func() {
51 ttest, c, dist, s := testSetup() 51 ttest, c, dist, s := testSetup()
52 52
53 ds := datastore.Get(c) 53 ds := datastore.Get(c)
54 54
55 req := &dm.WalkGraphReq{ 55 req := &dm.WalkGraphReq{
56 Query: dm.AttemptListQueryL(map[string][]uint32{"quest": {1}}), 56 Query: dm.AttemptListQueryL(map[string][]uint32{"quest": {1}}),
57 Limit: &dm.WalkGraphReq_Limit{MaxDepth: 1},
58 } 57 }
59 So(req.Normalize(), ShouldBeNil) 58 So(req.Normalize(), ShouldBeNil)
60 59
61 Convey("no read access", func() { 60 Convey("no read access", func() {
62 _, err := s.WalkGraph(c, req) 61 _, err := s.WalkGraph(c, req)
63 So(err, ShouldBeRPCPermissionDenied, "not authorized") 62 So(err, ShouldBeRPCPermissionDenied, "not authorized")
64 }) 63 })
65 64
66 c = reader(c) 65 c = reader(c)
67 66
(...skipping 22 matching lines...) Expand all
90 Quests: map[string]*dm.Quest{ 89 Quests: map[string]*dm.Quest{
91 w: { 90 w: {
92 Attempts: map[uint32]*dm .Attempt{1: {}}, 91 Attempts: map[uint32]*dm .Attempt{1: {}},
93 }, 92 },
94 }, 93 },
95 }) 94 })
96 }) 95 })
97 96
98 Convey("quest dne", func() { 97 Convey("quest dne", func() {
99 req.Include.Quest.Data = true 98 req.Include.Quest.Data = true
100 req.Limit.MaxDepth = 1
101 req.Query.AttemptList = dm.NewAttemptList( 99 req.Query.AttemptList = dm.NewAttemptList(
102 map[string][]uint32{"noex": {1}}) 100 map[string][]uint32{"noex": {1}})
103 So(req, fake.WalkShouldReturn(c, s), &dm.GraphDa ta{ 101 So(req, fake.WalkShouldReturn(c, s), &dm.GraphDa ta{
104 Quests: map[string]*dm.Quest{ 102 Quests: map[string]*dm.Quest{
105 "noex": { 103 "noex": {
106 DNE: true, 104 DNE: true,
107 Attempts: map[uint32]*dm .Attempt{1: {DNE: true}}, 105 Attempts: map[uint32]*dm .Attempt{1: {DNE: true}},
108 }, 106 },
109 }, 107 },
110 }) 108 })
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 191
194 wEx := dm.NewExecutionID(w, 1, 1) 192 wEx := dm.NewExecutionID(w, 1, 1)
195 dist.RunTask(c, wEx, func(tsk *fake.Task) error { 193 dist.RunTask(c, wEx, func(tsk *fake.Task) error {
196 tsk.MustActivate(c, s).DepOn( 194 tsk.MustActivate(c, s).DepOn(
197 dm.NewAttemptID(x, 1), dm.NewAtt emptID(x, 2), dm.NewAttemptID(x, 3), 195 dm.NewAttemptID(x, 1), dm.NewAtt emptID(x, 2), dm.NewAttemptID(x, 3),
198 dm.NewAttemptID(x, 4)) 196 dm.NewAttemptID(x, 4))
199 return nil 197 return nil
200 }) 198 })
201 ttest.Drain(c) 199 ttest.Drain(c)
202 200
203 req.Limit.MaxDepth = 1
204 Convey("normal", func() { 201 Convey("normal", func() {
205 req.Query = dm.AttemptRangeQuery(x, 2, 4 ) 202 req.Query = dm.AttemptRangeQuery(x, 2, 4 )
206 So(req, fake.WalkShouldReturn(c, s), &dm .GraphData{ 203 So(req, fake.WalkShouldReturn(c, s), &dm .GraphData{
207 Quests: map[string]*dm.Quest{ 204 Quests: map[string]*dm.Quest{
208 x: {Attempts: map[uint32 ]*dm.Attempt{2: {}, 3: {}}}, 205 x: {Attempts: map[uint32 ]*dm.Attempt{2: {}, 3: {}}},
209 }, 206 },
210 }) 207 })
211 }) 208 })
212 209
213 Convey("oob range", func() { 210 Convey("oob range", func() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 ttest.Drain(c) 252 ttest.Drain(c)
256 253
257 wEID := dm.NewExecutionID(w, 1, 2) 254 wEID := dm.NewExecutionID(w, 1, 2)
258 wEx := model.ExecutionFromID(c, wEID) 255 wEx := model.ExecutionFromID(c, wEID)
259 So(ds.Get(wEx), ShouldBeNil) 256 So(ds.Get(wEx), ShouldBeNil)
260 257
261 dist.RunTask(c, wEID, func(tsk *fake.Task) error { 258 dist.RunTask(c, wEID, func(tsk *fake.Task) error {
262 So(tsk.State, ShouldResemble, dm.NewJson Result(`{"originalState":true}`)) 259 So(tsk.State, ShouldResemble, dm.NewJson Result(`{"originalState":true}`))
263 260
264 act := tsk.MustActivate(c, s) 261 act := tsk.MustActivate(c, s)
265 » » » » » req.Limit.MaxDepth = 2 262 » » » » » req.Limit.MaxDepth = 1
266 req.Include.Attempt.Result = true 263 req.Include.Attempt.Result = true
267 req.Include.NumExecutions = 1 264 req.Include.NumExecutions = 1
268 req.Query = dm.AttemptListQueryL(map[str ing][]uint32{x: nil}) 265 req.Query = dm.AttemptListQueryL(map[str ing][]uint32{x: nil})
269 266
270 x1Expect := dm.NewAttemptFinished(dm.New JsonResult(x1data)) 267 x1Expect := dm.NewAttemptFinished(dm.New JsonResult(x1data))
271 x1Expect.Data.NumExecutions = 1 268 x1Expect.Data.NumExecutions = 1
272 x1Expect.Executions = map[uint32]*dm.Exe cution{ 269 x1Expect.Executions = map[uint32]*dm.Exe cution{
273 1: addDistributorInfo( 270 1: addDistributorInfo(
274 dm.NewExecutionID(x, 1, 1), 271 dm.NewExecutionID(x, 1, 1),
275 dm.NewExecutionFinished( dm.NewJsonResult(`{"atmpt1":true}`))), 272 dm.NewExecutionFinished( dm.NewJsonResult(`{"atmpt1":true}`))),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 x1data := `{"data":["I can see this"]}` 307 x1data := `{"data":["I can see this"]}`
311 dist.RunTask(c, dm.NewExecutionID(x, 1, 1), func (tsk *fake.Task) error { 308 dist.RunTask(c, dm.NewExecutionID(x, 1, 1), func (tsk *fake.Task) error {
312 tsk.MustActivate(c, s).Finish(x1data, ex p) 309 tsk.MustActivate(c, s).Finish(x1data, ex p)
313 tsk.State = dm.NewJsonResult(`{"state": true}`) 310 tsk.State = dm.NewJsonResult(`{"state": true}`)
314 return nil 311 return nil
315 }) 312 })
316 ttest.Drain(c) 313 ttest.Drain(c)
317 314
318 dist.RunTask(c, dm.NewExecutionID(w, 1, 2), func (tsk *fake.Task) error { 315 dist.RunTask(c, dm.NewExecutionID(w, 1, 2), func (tsk *fake.Task) error {
319 act := tsk.MustActivate(c, s) 316 act := tsk.MustActivate(c, s)
320 » » » » » req.Limit.MaxDepth = 2 317 » » » » » req.Limit.MaxDepth = 1
321 req.Include.Attempt.Result = true 318 req.Include.Attempt.Result = true
322 req.Include.NumExecutions = 1 319 req.Include.NumExecutions = 1
323 req.Query = dm.AttemptListQueryL(map[str ing][]uint32{w: {1}}) 320 req.Query = dm.AttemptListQueryL(map[str ing][]uint32{w: {1}})
324 321
325 x1Expect := dm.NewAttemptFinished(dm.New JsonResult(x1data)) 322 x1Expect := dm.NewAttemptFinished(dm.New JsonResult(x1data))
326 x1Expect.Data.NumExecutions = 1 323 x1Expect.Data.NumExecutions = 1
327 x1Expect.Executions = map[uint32]*dm.Exe cution{ 324 x1Expect.Executions = map[uint32]*dm.Exe cution{
328 1: addDistributorInfo( 325 1: addDistributorInfo(
329 dm.NewExecutionID(x, 1, 1), 326 dm.NewExecutionID(x, 1, 1),
330 dm.NewExecutionFinished( dm.NewJsonResult(`{"state":true}`))), 327 dm.NewExecutionFinished( dm.NewJsonResult(`{"state":true}`))),
(...skipping 15 matching lines...) Expand all
346 Quests: map[string]*dm.Quest{ 343 Quests: map[string]*dm.Quest{
347 w: {Attempts: map[uint32 ]*dm.Attempt{1: w1Exepct}}, 344 w: {Attempts: map[uint32 ]*dm.Attempt{1: w1Exepct}},
348 x: {Attempts: map[uint32 ]*dm.Attempt{1: x1Expect}}, 345 x: {Attempts: map[uint32 ]*dm.Attempt{1: x1Expect}},
349 }, 346 },
350 }) 347 })
351 return nil 348 return nil
352 }) 349 })
353 }) 350 })
354 351
355 Convey("deps (no dest attempts)", func() { 352 Convey("deps (no dest attempts)", func() {
356 » » » » req.Limit.MaxDepth = 3 353 » » » » req.Limit.MaxDepth = 2
357 354
358 x := s.ensureQuest(c, "x", 1) 355 x := s.ensureQuest(c, "x", 1)
359 ttest.Drain(c) 356 ttest.Drain(c)
360 357
361 dist.RunTask(c, dm.NewExecutionID(w, 1, 1), func (tsk *fake.Task) error { 358 dist.RunTask(c, dm.NewExecutionID(w, 1, 1), func (tsk *fake.Task) error {
362 tsk.MustActivate(c, s).DepOn(dm.NewAttem ptID(x, 1), dm.NewAttemptID(x, 2)) 359 tsk.MustActivate(c, s).DepOn(dm.NewAttem ptID(x, 1), dm.NewAttemptID(x, 2))
363 360
364 Convey("before tumble", func() { 361 Convey("before tumble", func() {
365 req.Include.FwdDeps = true 362 req.Include.FwdDeps = true
366 // didn't run tumble, so that x| 1 and x|2 don't get created. 363 // didn't run tumble, so that x| 1 and x|2 don't get created.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 w: {Atte mpts: map[uint32]*dm.Attempt{1: {}}}, 434 w: {Atte mpts: map[uint32]*dm.Attempt{1: {}}},
438 x: {Atte mpts: map[uint32]*dm.Attempt{1: {}, 2: {}}}, 435 x: {Atte mpts: map[uint32]*dm.Attempt{1: {}, 2: {}}},
439 z: {Atte mpts: map[uint32]*dm.Attempt{1: {}}}, 436 z: {Atte mpts: map[uint32]*dm.Attempt{1: {}}},
440 }, 437 },
441 }) 438 })
442 }) 439 })
443 440
444 }) 441 })
445 442
446 Convey("attemptlist", func() { 443 Convey("attemptlist", func() {
447 req.Limit.MaxDepth = 1
448 req.Include.Quest.Ids = true 444 req.Include.Quest.Ids = true
449 req.Include.Attempt.Ids = true 445 req.Include.Attempt.Ids = true
450 req.Query = dm.AttemptListQueryL (map[string][]uint32{x: nil}) 446 req.Query = dm.AttemptListQueryL (map[string][]uint32{x: nil})
451 So(req, fake.WalkShouldReturn(c, s), &dm.GraphData{ 447 So(req, fake.WalkShouldReturn(c, s), &dm.GraphData{
452 Quests: map[string]*dm.Q uest{ 448 Quests: map[string]*dm.Q uest{
453 x: { 449 x: {
454 Id: dm.N ewQuestID(x), 450 Id: dm.N ewQuestID(x),
455 Attempts : map[uint32]*dm.Attempt{ 451 Attempts : map[uint32]*dm.Attempt{
456 1: {Id: dm.NewAttemptID(x, 1)}, 452 1: {Id: dm.NewAttemptID(x, 1)},
457 2: {Id: dm.NewAttemptID(x, 2)}, 453 2: {Id: dm.NewAttemptID(x, 2)},
(...skipping 16 matching lines...) Expand all
474 }) 470 })
475 ret, err := s.WalkGraph(c, req) 471 ret, err := s.WalkGraph(c, req)
476 So(err, ShouldBeNil) 472 So(err, ShouldBeNil)
477 So(ret.HadMore, ShouldBeTrue) 473 So(ret.HadMore, ShouldBeTrue)
478 }) 474 })
479 475
480 }) 476 })
481 }) 477 })
482 }) 478 })
483 } 479 }
OLDNEW
« no previous file with comments | « dm/appengine/deps/walk_graph.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698