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

Side by Side Diff: appengine/cmd/dm/mutate/ack_fwd_dep_test.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: fix imports and make dummy.go a real file Created 4 years, 6 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 | « appengine/cmd/dm/mutate/ack_fwd_dep.go ('k') | appengine/cmd/dm/mutate/activate_execution.go » ('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 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 mutate 5 package mutate
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 9
10 "github.com/luci/gae/impl/memory" 10 "github.com/luci/gae/impl/memory"
(...skipping 23 matching lines...) Expand all
34 34
35 Convey("Root", func() { 35 Convey("Root", func() {
36 So(afd.Root(c), ShouldResemble, ds.MakeKey("Attempt", "q uest|fffffffe")) 36 So(afd.Root(c), ShouldResemble, ds.MakeKey("Attempt", "q uest|fffffffe"))
37 }) 37 })
38 38
39 Convey("RollForward", func() { 39 Convey("RollForward", func() {
40 a, fwd := afd.Dep.Fwd(c) 40 a, fwd := afd.Dep.Fwd(c)
41 41
42 Convey("AddingDeps", func() { 42 Convey("AddingDeps", func() {
43 Convey("good", func() { 43 Convey("good", func() {
44 » » » » » a.State = dm.Attempt_ADDING_DEPS 44 » » » » » a.State = dm.Attempt_WAITING
45 » » » » » a.AddingDepsBitmap = bf.Make(2) 45 » » » » » a.DepMap = bf.Make(2)
46 » » » » » a.WaitingDepBitmap = bf.Make(2)
47 So(ds.Put(a, fwd), ShouldBeNil) 46 So(ds.Put(a, fwd), ShouldBeNil)
48 47
49 » » » » » Convey("non-finished, not-last-adding", func() { 48 » » » » » Convey("not-last", func() {
50 muts, err := afd.RollForward(c) 49 muts, err := afd.RollForward(c)
51 So(err, ShouldBeNil) 50 So(err, ShouldBeNil)
52 So(muts, ShouldBeNil) 51 So(muts, ShouldBeNil)
53 52
54 So(ds.Get(a, fwd), ShouldBeNil) 53 So(ds.Get(a, fwd), ShouldBeNil)
55 » » » » » » So(a.State, ShouldEqual, dm.Atte mpt_ADDING_DEPS) 54 » » » » » » So(a.State, ShouldEqual, dm.Atte mpt_WAITING)
56 » » » » » » So(a.AddingDepsBitmap.CountSet() , ShouldEqual, 1) 55 » » » » » » So(a.DepMap.CountSet(), ShouldEq ual, 1)
57 » » » » » » So(a.WaitingDepBitmap.CountSet() , ShouldEqual, 0)
58 » » » » » })
59
60 » » » » » Convey("non-finished, last-adding", func () {
61 » » » » » » a.AddingDepsBitmap.Set(1)
62 » » » » » » So(ds.Put(a), ShouldBeNil)
63
64 » » » » » » muts, err := afd.RollForward(c)
65 » » » » » » So(err, ShouldBeNil)
66 » » » » » » So(muts, ShouldBeNil)
67
68 » » » » » » So(ds.Get(a, fwd), ShouldBeNil)
69 » » » » » » So(a.State, ShouldEqual, dm.Atte mpt_BLOCKED)
70 » » » » » » So(a.AddingDepsBitmap.CountSet() , ShouldEqual, 2)
71 » » » » » » So(a.WaitingDepBitmap.CountSet() , ShouldEqual, 0)
72
73 » » » » » » Convey("and then finished later" , func() {
74 » » » » » » » // happens when we depen d on an Attempt while it's not Finished,
75 » » » » » » » // but then it finishes later.
76
77 » » » » » » » afd.DepIsFinished = true
78
79 » » » » » » » muts, err := afd.RollFor ward(c)
80 » » » » » » » So(err, ShouldBeNil)
81 » » » » » » » So(muts, ShouldBeNil)
82
83 » » » » » » » So(ds.Get(a, fwd), Shoul dBeNil)
84 » » » » » » » So(a.State, ShouldEqual, dm.Attempt_BLOCKED)
85 » » » » » » » So(a.AddingDepsBitmap.Co untSet(), ShouldEqual, 2)
86 » » » » » » » So(a.WaitingDepBitmap.Co untSet(), ShouldEqual, 1)
87 » » » » » » })
88 » » » » » })
89
90 » » » » » Convey("finished, not-last-finished", fu nc() {
91 » » » » » » a.AddingDepsBitmap.Set(1)
92 » » » » » » So(ds.Put(a), ShouldBeNil)
93
94 » » » » » » afd.DepIsFinished = true
95
96 » » » » » » muts, err := afd.RollForward(c)
97 » » » » » » So(err, ShouldBeNil)
98 » » » » » » So(muts, ShouldBeNil)
99
100 » » » » » » So(ds.Get(a, fwd), ShouldBeNil)
101 » » » » » » So(a.State, ShouldEqual, dm.Atte mpt_BLOCKED)
102 » » » » » » So(a.AddingDepsBitmap.CountSet() , ShouldEqual, 2)
103 » » » » » » So(a.WaitingDepBitmap.CountSet() , ShouldEqual, 1)
104 }) 56 })
105 57
106 Convey("last-finished", func() { 58 Convey("last-finished", func() {
107 » » » » » » a.AddingDepsBitmap.Set(1) 59 » » » » » » a.DepMap.Set(1)
108 » » » » » » a.WaitingDepBitmap.Set(1)
109 So(ds.Put(a), ShouldBeNil) 60 So(ds.Put(a), ShouldBeNil)
110 61
111 afd.DepIsFinished = true
112
113 muts, err := afd.RollForward(c) 62 muts, err := afd.RollForward(c)
114 So(err, ShouldBeNil) 63 So(err, ShouldBeNil)
115 So(muts, ShouldResemble, []tumbl e.Mutation{ 64 So(muts, ShouldResemble, []tumbl e.Mutation{
116 &ScheduleExecution{&a.ID }}) 65 &ScheduleExecution{&a.ID }})
117 66
118 So(ds.Get(a, fwd), ShouldBeNil) 67 So(ds.Get(a, fwd), ShouldBeNil)
119 » » » » » » So(a.State, ShouldEqual, dm.Atte mpt_NEEDS_EXECUTION) 68 » » » » » » So(a.State, ShouldEqual, dm.Atte mpt_SCHEDULING)
120 » » » » » » So(a.AddingDepsBitmap.CountSet() , ShouldEqual, 2) 69 » » » » » » So(a.DepMap.CountSet(), ShouldEq ual, 0) // was reset
121 » » » » » » So(a.WaitingDepBitmap.CountSet() , ShouldEqual, 2)
122 }) 70 })
123 }) 71 })
124 72
125 Convey("bad", func() { 73 Convey("bad", func() {
126 » » » » » a.State = dm.Attempt_ADDING_DEPS 74 » » » » » a.State = dm.Attempt_WAITING
127 » » » » » a.AddingDepsBitmap = bf.Make(2) 75 » » » » » a.DepMap = bf.Make(2)
128 » » » » » a.WaitingDepBitmap = bf.Make(2)
129 a.CurExecution = 1 76 a.CurExecution = 1
130 So(ds.Put(a, fwd), ShouldBeNil) 77 So(ds.Put(a, fwd), ShouldBeNil)
131 78
132 Convey("CurExecution mismatch -> NOP", f unc() { 79 Convey("CurExecution mismatch -> NOP", f unc() {
133 muts, err := afd.RollForward(c) 80 muts, err := afd.RollForward(c)
134 So(err, ShouldBeNil) 81 So(err, ShouldBeNil)
135 So(muts, ShouldBeNil) 82 So(muts, ShouldBeNil)
136 83
137 So(ds.Get(a, fwd), ShouldBeNil) 84 So(ds.Get(a, fwd), ShouldBeNil)
138 » » » » » » So(a.State, ShouldEqual, dm.Atte mpt_ADDING_DEPS) 85 » » » » » » So(a.State, ShouldEqual, dm.Atte mpt_WAITING)
139 » » » » » » So(a.AddingDepsBitmap.CountSet() , ShouldEqual, 0) 86 » » » » » » So(a.DepMap.CountSet(), ShouldEq ual, 0)
140 » » » » » » So(a.WaitingDepBitmap.CountSet() , ShouldEqual, 0)
141 }) 87 })
142 88
143 Convey("Missing data", func() { 89 Convey("Missing data", func() {
144 So(ds.Delete(ds.KeyForObj(a)), S houldBeNil) 90 So(ds.Delete(ds.KeyForObj(a)), S houldBeNil)
145 91
146 _, err := afd.RollForward(c) 92 _, err := afd.RollForward(c)
147 So(err, ShouldErrLike, datastore .ErrNoSuchEntity) 93 So(err, ShouldErrLike, datastore .ErrNoSuchEntity)
148 }) 94 })
149 }) 95 })
150 96
151 }) 97 })
152 }) 98 })
153 }) 99 })
154 } 100 }
OLDNEW
« no previous file with comments | « appengine/cmd/dm/mutate/ack_fwd_dep.go ('k') | appengine/cmd/dm/mutate/activate_execution.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698