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

Side by Side Diff: scheduler/appengine/engine/engine_test.go

Issue 2998623002: scheduler ACLs: fix ACLs saving upon job config change. (Closed)
Patch Set: fix import order Created 3 years, 4 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. 1 // Copyright 2015 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 Revision: "rev1", 97 Revision: "rev1",
98 Enabled: true, 98 Enabled: true,
99 Schedule: "*/5 * * * * * *", 99 Schedule: "*/5 * * * * * *",
100 State: JobState{ 100 State: JobState{
101 State: "SCHEDULED", 101 State: "SCHEDULED",
102 TickNonce: 6278013164014963328, 102 TickNonce: 6278013164014963328,
103 TickTime: epoch.Add(5 * time.Second), 103 TickTime: epoch.Add(5 * time.Second),
104 }, 104 },
105 }, 105 },
106 }) 106 })
107
108 // TODO(tandrii): delete and update above definition after no-AC L -> ACL transition.
109 // Simulate ACL version roll without change of project config.
110 So(e.UpdateProjectJobs(c, "abc", []catalog.Definition{
111 {
112 JobID: "abc/1",
113 Revision: "rev1",
114 Schedule: "*/5 * * * * * *",
115 Acls: acl.GrantsByRole{Readers: []string{"gr oup:r"}, Owners: []string{"groups:o"}},
116 }}), ShouldBeNil)
117 So(allJobs(c), ShouldResemble, []Job{
118 {
119 JobID: "abc/1",
120 ProjectID: "abc",
121 Revision: "rev1",
122 Enabled: true,
123 Acls: acl.GrantsByRole{Readers: []string{"g roup:r"}, Owners: []string{"groups:o"}},
124 Schedule: "*/5 * * * * * *",
125 State: JobState{
126 State: "SCHEDULED",
127 TickNonce: 6278013164014963328,
128 TickTime: epoch.Add(5 * time.Second),
129 },
130 },
131 })
132
107 // Enqueued timer task to launch it. 133 // Enqueued timer task to launch it.
108 task := ensureOneTask(c, "timers-q") 134 task := ensureOneTask(c, "timers-q")
109 So(task.Path, ShouldEqual, "/timers") 135 So(task.Path, ShouldEqual, "/timers")
110 So(task.ETA, ShouldResemble, epoch.Add(5*time.Second)) 136 So(task.ETA, ShouldResemble, epoch.Add(5*time.Second))
111 tq.GetTestable(c).ResetTasks() 137 tq.GetTestable(c).ResetTasks()
112 138
113 // Readding same job in with exact same config revision -> noop. 139 // Readding same job in with exact same config revision -> noop.
114 So(e.UpdateProjectJobs(c, "abc", []catalog.Definition{ 140 So(e.UpdateProjectJobs(c, "abc", []catalog.Definition{
115 { 141 {
116 JobID: "abc/1", 142 JobID: "abc/1",
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 1259
1234 func ensureOneTask(c context.Context, q string) *tq.Task { 1260 func ensureOneTask(c context.Context, q string) *tq.Task {
1235 tqt := tq.GetTestable(c) 1261 tqt := tq.GetTestable(c)
1236 tasks := tqt.GetScheduledTasks()[q] 1262 tasks := tqt.GetScheduledTasks()[q]
1237 So(len(tasks), ShouldEqual, 1) 1263 So(len(tasks), ShouldEqual, 1)
1238 for _, t := range tasks { 1264 for _, t := range tasks {
1239 return t 1265 return t
1240 } 1266 }
1241 return nil 1267 return nil
1242 } 1268 }
OLDNEW
« scheduler/appengine/engine/engine.go ('K') | « scheduler/appengine/engine/engine.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698