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

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

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: self review 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
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"
11 "github.com/luci/gae/service/datastore" 11 "github.com/luci/gae/service/datastore"
12 "github.com/luci/luci-go/appengine/cmd/dm/distributor"
12 "github.com/luci/luci-go/appengine/cmd/dm/model" 13 "github.com/luci/luci-go/appengine/cmd/dm/model"
13 "github.com/luci/luci-go/common/api/dm/service/v1" 14 "github.com/luci/luci-go/common/api/dm/service/v1"
14 . "github.com/luci/luci-go/common/testing/assertions" 15 . "github.com/luci/luci-go/common/testing/assertions"
15 . "github.com/smartystreets/goconvey/convey" 16 . "github.com/smartystreets/goconvey/convey"
16 "golang.org/x/net/context" 17 "golang.org/x/net/context"
17 ) 18 )
18 19
19 func TestAddDeps(t *testing.T) { 20 func TestAddDeps(t *testing.T) {
20 t.Parallel() 21 t.Parallel()
21 22
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 Convey("None added already", func() { 78 Convey("None added already", func() {
78 muts, err := ad.RollForward(c) 79 muts, err := ad.RollForward(c)
79 So(err, ShouldBeNil) 80 So(err, ShouldBeNil)
80 So(len(muts), ShouldEqual, len(fds)) 81 So(len(muts), ShouldEqual, len(fds))
81 82
82 So(muts[0], ShouldResemble, &AddBackDep{ 83 So(muts[0], ShouldResemble, &AddBackDep{
83 Dep: fds[0].Edge(), NeedsAck: tr ue}) 84 Dep: fds[0].Edge(), NeedsAck: tr ue})
84 85
85 So(ds.Get(a), ShouldBeNil) 86 So(ds.Get(a), ShouldBeNil)
86 So(ds.GetMulti(fds), ShouldBeNil) 87 So(ds.GetMulti(fds), ShouldBeNil)
87 » » » » » So(a.AddingDepsBitmap.Size(), ShouldEqua l, len(fds)) 88 » » » » » So(a.DepMap.Size(), ShouldEqual, len(fds ))
88 » » » » » So(a.WaitingDepBitmap.Size(), ShouldEqua l, len(fds)) 89 » » » » » So(a.State, ShouldEqual, dm.Attempt_EXEC UTING)
89 » » » » » So(a.State, ShouldEqual, dm.Attempt_ADDI NG_DEPS)
90 So(fds[0].ForExecution, ShouldEqual, 1) 90 So(fds[0].ForExecution, ShouldEqual, 1)
91
92 muts, err = (&FinishExecution{
93 ad.Auth.Id, &distributor.TaskRes ult{PersistentState: "hi"},
94 }).RollForward(c)
95 So(err, ShouldBeNil)
96 So(muts, ShouldBeNil)
97
98 So(ds.Get(a), ShouldBeNil)
99 So(a.State, ShouldEqual, dm.Attempt_WAIT ING)
91 }) 100 })
92 101
93 Convey("adding new Attempts at the same time", f unc() { 102 Convey("adding new Attempts at the same time", f unc() {
94 » » » » » ad.Atmpts = dm.NewAttemptList(map[string ][]uint32{ 103 » » » » » ad.Attempts = dm.NewAttemptList(map[stri ng][]uint32{
95 "to": {2, 3}, 104 "to": {2, 3},
96 "tp": {1}, 105 "tp": {1},
97 }) 106 })
98 107
99 muts, err := ad.RollForward(c) 108 muts, err := ad.RollForward(c)
100 So(err, ShouldBeNil) 109 So(err, ShouldBeNil)
101 So(len(muts), ShouldEqual, len(fds)+3) 110 So(len(muts), ShouldEqual, len(fds)+3)
102 111
103 So(muts[0], ShouldResemble, &EnsureAttem pt{dm.NewAttemptID("to", 3)}) 112 So(muts[0], ShouldResemble, &EnsureAttem pt{dm.NewAttemptID("to", 3)})
104 So(muts[1], ShouldResemble, &AddBackDep{ 113 So(muts[1], ShouldResemble, &AddBackDep{
105 Dep: fds[0].Edge(), NeedsAck: tr ue}) 114 Dep: fds[0].Edge(), NeedsAck: tr ue})
106 115
107 So(ds.Get(a), ShouldBeNil) 116 So(ds.Get(a), ShouldBeNil)
108 So(ds.GetMulti(fds), ShouldBeNil) 117 So(ds.GetMulti(fds), ShouldBeNil)
109 » » » » » So(a.AddingDepsBitmap.Size(), ShouldEqua l, len(fds)) 118 » » » » » So(a.DepMap.Size(), ShouldEqual, len(fds ))
110 » » » » » So(a.WaitingDepBitmap.Size(), ShouldEqua l, len(fds)) 119 » » » » » So(a.State, ShouldEqual, dm.Attempt_EXEC UTING)
111 » » » » » So(a.State, ShouldEqual, dm.Attempt_ADDI NG_DEPS)
112 So(fds[0].ForExecution, ShouldEqual, 1) 120 So(fds[0].ForExecution, ShouldEqual, 1)
121
122 muts, err = (&FinishExecution{
123 ad.Auth.Id, &distributor.TaskRes ult{PersistentState: "hi"},
124 }).RollForward(c)
125 So(err, ShouldBeNil)
126 So(muts, ShouldBeNil)
127
128 So(ds.Get(a), ShouldBeNil)
129 So(a.State, ShouldEqual, dm.Attempt_WAIT ING)
113 }) 130 })
114 }) 131 })
115 }) 132 })
116 }) 133 })
117 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698