| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 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 apiservers | 5 package apiservers |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "testing" | 9 "testing" |
| 10 "time" | 10 "time" |
| 11 | 11 |
| 12 "google.golang.org/grpc/codes" | 12 "google.golang.org/grpc/codes" |
| 13 "google.golang.org/grpc/status" | 13 "google.golang.org/grpc/status" |
| 14 | 14 |
| 15 "golang.org/x/net/context" | 15 "golang.org/x/net/context" |
| 16 | 16 |
| 17 "github.com/golang/protobuf/proto" | 17 "github.com/golang/protobuf/proto" |
| 18 "github.com/golang/protobuf/ptypes/empty" |
| 18 "github.com/luci/luci-go/appengine/gaetesting" | 19 "github.com/luci/luci-go/appengine/gaetesting" |
| 20 "github.com/luci/luci-go/server/auth" |
| 21 "github.com/luci/luci-go/server/auth/authtest" |
| 19 "github.com/luci/luci-go/server/auth/identity" | 22 "github.com/luci/luci-go/server/auth/identity" |
| 20 | 23 |
| 21 » scheduler "github.com/luci/luci-go/scheduler/api/scheduler/v1" | 24 » "github.com/luci/luci-go/scheduler/api/scheduler/v1" |
| 22 "github.com/luci/luci-go/scheduler/appengine/catalog" | 25 "github.com/luci/luci-go/scheduler/appengine/catalog" |
| 23 "github.com/luci/luci-go/scheduler/appengine/engine" | 26 "github.com/luci/luci-go/scheduler/appengine/engine" |
| 24 "github.com/luci/luci-go/scheduler/appengine/messages" | 27 "github.com/luci/luci-go/scheduler/appengine/messages" |
| 25 "github.com/luci/luci-go/scheduler/appengine/task" | 28 "github.com/luci/luci-go/scheduler/appengine/task" |
| 26 "github.com/luci/luci-go/scheduler/appengine/task/urlfetch" | 29 "github.com/luci/luci-go/scheduler/appengine/task/urlfetch" |
| 27 | 30 |
| 28 . "github.com/smartystreets/goconvey/convey" | 31 . "github.com/smartystreets/goconvey/convey" |
| 29 ) | 32 ) |
| 30 | 33 |
| 31 func TestGetJobsApi(t *testing.T) { | 34 func TestGetJobsApi(t *testing.T) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 62 Schedule: "with 1m interval", | 65 Schedule: "with 1m interval", |
| 63 State: engine.JobState{State
: engine.JobStateSuspended}, | 66 State: engine.JobState{State
: engine.JobStateSuspended}, |
| 64 Task: fakeTaskBlob, | 67 Task: fakeTaskBlob, |
| 65 }, | 68 }, |
| 66 }, nil | 69 }, nil |
| 67 } | 70 } |
| 68 reply, err := ss.GetJobs(ctx, nil) | 71 reply, err := ss.GetJobs(ctx, nil) |
| 69 So(err, ShouldBeNil) | 72 So(err, ShouldBeNil) |
| 70 So(reply.GetJobs(), ShouldResemble, []*scheduler.Job{ | 73 So(reply.GetJobs(), ShouldResemble, []*scheduler.Job{ |
| 71 { | 74 { |
| 72 » » » » » Name: "foo", | 75 » » » » » JobRef: &scheduler.JobRef{Job: "foo",
Project: "bar"}, |
| 73 » » » » » Project: "bar", | |
| 74 Schedule: "0 * * * * * *", | 76 Schedule: "0 * * * * * *", |
| 75 State: &scheduler.JobState{UiStatus:
"RUNNING"}, | 77 State: &scheduler.JobState{UiStatus:
"RUNNING"}, |
| 76 }, | 78 }, |
| 77 { | 79 { |
| 78 » » » » » Name: "faz", | 80 » » » » » JobRef: &scheduler.JobRef{Job: "faz",
Project: "baz"}, |
| 79 » » » » » Project: "baz", | |
| 80 Schedule: "with 1m interval", | 81 Schedule: "with 1m interval", |
| 81 State: &scheduler.JobState{UiStatus:
"PAUSED"}, | 82 State: &scheduler.JobState{UiStatus:
"PAUSED"}, |
| 82 }, | 83 }, |
| 83 }) | 84 }) |
| 84 }) | 85 }) |
| 85 | 86 |
| 86 Convey("One Project", func() { | 87 Convey("One Project", func() { |
| 87 fakeEng.getProjectJobs = func(projectID string) ([]*engi
ne.Job, error) { | 88 fakeEng.getProjectJobs = func(projectID string) ([]*engi
ne.Job, error) { |
| 88 So(projectID, ShouldEqual, "bar") | 89 So(projectID, ShouldEqual, "bar") |
| 89 return []*engine.Job{ | 90 return []*engine.Job{ |
| 90 { | 91 { |
| 91 JobID: "bar/foo", | 92 JobID: "bar/foo", |
| 92 ProjectID: "bar", | 93 ProjectID: "bar", |
| 93 Schedule: "0 * * * * * *", | 94 Schedule: "0 * * * * * *", |
| 94 State: engine.JobState{State
: engine.JobStateRunning}, | 95 State: engine.JobState{State
: engine.JobStateRunning}, |
| 95 Task: fakeTaskBlob, | 96 Task: fakeTaskBlob, |
| 96 }, | 97 }, |
| 97 }, nil | 98 }, nil |
| 98 } | 99 } |
| 99 reply, err := ss.GetJobs(ctx, &scheduler.JobsRequest{Pro
ject: "bar"}) | 100 reply, err := ss.GetJobs(ctx, &scheduler.JobsRequest{Pro
ject: "bar"}) |
| 100 So(err, ShouldBeNil) | 101 So(err, ShouldBeNil) |
| 101 So(reply.GetJobs(), ShouldResemble, []*scheduler.Job{ | 102 So(reply.GetJobs(), ShouldResemble, []*scheduler.Job{ |
| 102 { | 103 { |
| 103 » » » » » Name: "foo", | 104 » » » » » JobRef: &scheduler.JobRef{Job: "foo",
Project: "bar"}, |
| 104 » » » » » Project: "bar", | |
| 105 Schedule: "0 * * * * * *", | 105 Schedule: "0 * * * * * *", |
| 106 State: &scheduler.JobState{UiStatus:
"RUNNING"}, | 106 State: &scheduler.JobState{UiStatus:
"RUNNING"}, |
| 107 }, | 107 }, |
| 108 }) | 108 }) |
| 109 }) | 109 }) |
| 110 }) | 110 }) |
| 111 } | 111 } |
| 112 | 112 |
| 113 func TestGetInvocationsApi(t *testing.T) { | 113 func TestGetInvocationsApi(t *testing.T) { |
| 114 t.Parallel() | 114 t.Parallel() |
| 115 | 115 |
| 116 Convey("Scheduler GetInvocations API works", t, func() { | 116 Convey("Scheduler GetInvocations API works", t, func() { |
| 117 ctx := gaetesting.TestingContext() | 117 ctx := gaetesting.TestingContext() |
| 118 fakeEng, catalog := newTestEngine() | 118 fakeEng, catalog := newTestEngine() |
| 119 _, err := registerUrlFetcher(catalog) | 119 _, err := registerUrlFetcher(catalog) |
| 120 So(err, ShouldBeNil) | 120 So(err, ShouldBeNil) |
| 121 ss := SchedulerServer{fakeEng, catalog} | 121 ss := SchedulerServer{fakeEng, catalog} |
| 122 | 122 |
| 123 Convey("Job not found", func() { | 123 Convey("Job not found", func() { |
| 124 fakeEng.getJob = func(JobID string) (*engine.Job, error)
{ return nil, nil } | 124 fakeEng.getJob = func(JobID string) (*engine.Job, error)
{ return nil, nil } |
| 125 » » » _, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{Project: "not", Job: "exists"}) | 125 » » » _, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{ |
| 126 » » » » JobRef: &scheduler.JobRef{Project: "not", Job: "
exists"}, |
| 127 » » » }) |
| 126 s, ok := status.FromError(err) | 128 s, ok := status.FromError(err) |
| 127 So(ok, ShouldBeTrue) | 129 So(ok, ShouldBeTrue) |
| 128 So(s.Code(), ShouldEqual, codes.NotFound) | 130 So(s.Code(), ShouldEqual, codes.NotFound) |
| 129 }) | 131 }) |
| 130 | 132 |
| 131 Convey("DS error", func() { | 133 Convey("DS error", func() { |
| 132 fakeEng.getJob = func(JobID string) (*engine.Job, error)
{ return nil, fmt.Errorf("ds error") } | 134 fakeEng.getJob = func(JobID string) (*engine.Job, error)
{ return nil, fmt.Errorf("ds error") } |
| 133 » » » _, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{Project: "proj", Job: "job"}) | 135 » » » _, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{ |
| 136 » » » » JobRef: &scheduler.JobRef{Project: "proj", Job:
"job"}, |
| 137 » » » }) |
| 134 s, ok := status.FromError(err) | 138 s, ok := status.FromError(err) |
| 135 So(ok, ShouldBeTrue) | 139 So(ok, ShouldBeTrue) |
| 136 So(s.Code(), ShouldEqual, codes.Internal) | 140 So(s.Code(), ShouldEqual, codes.Internal) |
| 137 }) | 141 }) |
| 138 | 142 |
| 139 fakeEng.getJob = func(JobID string) (*engine.Job, error) { | 143 fakeEng.getJob = func(JobID string) (*engine.Job, error) { |
| 140 return &engine.Job{JobID: "proj/job", ProjectID: "proj"}
, nil | 144 return &engine.Job{JobID: "proj/job", ProjectID: "proj"}
, nil |
| 141 } | 145 } |
| 142 | 146 |
| 143 Convey("Emtpy with huge pagesize", func() { | 147 Convey("Emtpy with huge pagesize", func() { |
| 144 fakeEng.listInvocations = func(pageSize int, cursor stri
ng) ([]*engine.Invocation, string, error) { | 148 fakeEng.listInvocations = func(pageSize int, cursor stri
ng) ([]*engine.Invocation, string, error) { |
| 145 So(pageSize, ShouldEqual, 50) | 149 So(pageSize, ShouldEqual, 50) |
| 146 So(cursor, ShouldEqual, "") | 150 So(cursor, ShouldEqual, "") |
| 147 return nil, "", nil | 151 return nil, "", nil |
| 148 } | 152 } |
| 149 » » » r, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{Project: "proj", Job: "job", PageSize: 1e9}) | 153 » » » r, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{ |
| 154 » » » » JobRef: &scheduler.JobRef{Project: "proj", Job
: "job"}, |
| 155 » » » » PageSize: 1e9, |
| 156 » » » }) |
| 150 So(err, ShouldBeNil) | 157 So(err, ShouldBeNil) |
| 151 So(r.GetNextCursor(), ShouldEqual, "") | 158 So(r.GetNextCursor(), ShouldEqual, "") |
| 152 So(r.GetInvocations(), ShouldBeEmpty) | 159 So(r.GetInvocations(), ShouldBeEmpty) |
| 153 }) | 160 }) |
| 154 | 161 |
| 155 Convey("Some with custom pagesize and cursor", func() { | 162 Convey("Some with custom pagesize and cursor", func() { |
| 156 started := time.Unix(123123123, 0).UTC() | 163 started := time.Unix(123123123, 0).UTC() |
| 157 finished := time.Unix(321321321, 0).UTC() | 164 finished := time.Unix(321321321, 0).UTC() |
| 158 fakeEng.listInvocations = func(pageSize int, cursor stri
ng) ([]*engine.Invocation, string, error) { | 165 fakeEng.listInvocations = func(pageSize int, cursor stri
ng) ([]*engine.Invocation, string, error) { |
| 159 So(pageSize, ShouldEqual, 5) | 166 So(pageSize, ShouldEqual, 5) |
| 160 So(cursor, ShouldEqual, "cursor") | 167 So(cursor, ShouldEqual, "cursor") |
| 161 return []*engine.Invocation{ | 168 return []*engine.Invocation{ |
| 162 {ID: 12, Revision: "deadbeef", Status: t
ask.StatusRunning, Started: started, | 169 {ID: 12, Revision: "deadbeef", Status: t
ask.StatusRunning, Started: started, |
| 163 TriggeredBy: identity.Identity("
user:bot@example.com")}, | 170 TriggeredBy: identity.Identity("
user:bot@example.com")}, |
| 164 {ID: 13, Revision: "deadbeef", Status: t
ask.StatusAborted, Started: started, Finished: finished, | 171 {ID: 13, Revision: "deadbeef", Status: t
ask.StatusAborted, Started: started, Finished: finished, |
| 165 ViewURL: "https://example.com/13
"}, | 172 ViewURL: "https://example.com/13
"}, |
| 166 }, "next", nil | 173 }, "next", nil |
| 167 } | 174 } |
| 168 r, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{ | 175 r, err := ss.GetInvocations(ctx, &scheduler.InvocationsR
equest{ |
| 169 » » » » Project: "proj", Job: "job", PageSize: 5, Cursor
: "cursor"}) | 176 » » » » JobRef: &scheduler.JobRef{Project: "proj", Job
: "job"}, |
| 177 » » » » PageSize: 5, |
| 178 » » » » Cursor: "cursor", |
| 179 » » » }) |
| 170 So(err, ShouldBeNil) | 180 So(err, ShouldBeNil) |
| 171 So(r.GetNextCursor(), ShouldEqual, "next") | 181 So(r.GetNextCursor(), ShouldEqual, "next") |
| 172 So(r.GetInvocations(), ShouldResemble, []*scheduler.Invo
cation{ | 182 So(r.GetInvocations(), ShouldResemble, []*scheduler.Invo
cation{ |
| 173 { | 183 { |
| 174 » » » » » Project: "proj", Job: "job", ConfigRevis
ion: "deadbeef", | 184 » » » » » InvocationRef: &scheduler.InvocationRef{ |
| 175 » » » » » Id: 12, Final: false, Status: "RUNNING", | 185 » » » » » » JobRef: &scheduler.JobRef{
Project: "proj", Job: "job"}, |
| 176 » » » » » StartedTs: started.UnixNano() / 1000, | 186 » » » » » » InvocationId: 12, |
| 177 » » » » » TriggeredBy: "user:bot@example.com", | 187 » » » » » }, |
| 188 » » » » » ConfigRevision: "deadbeef", |
| 189 » » » » » Final: false, |
| 190 » » » » » Status: "RUNNING", |
| 191 » » » » » StartedTs: started.UnixNano() / 100
0, |
| 192 » » » » » TriggeredBy: "user:bot@example.com", |
| 178 }, | 193 }, |
| 179 { | 194 { |
| 180 » » » » » Project: "proj", Job: "job", ConfigRevis
ion: "deadbeef", | 195 » » » » » InvocationRef: &scheduler.InvocationRef{ |
| 181 » » » » » Id: 13, Final: true, Status: "ABORTED", | 196 » » » » » » JobRef: &scheduler.JobRef{
Project: "proj", Job: "job"}, |
| 182 » » » » » StartedTs: started.UnixNano() / 1000, Fi
nishedTs: finished.UnixNano() / 1000, | 197 » » » » » » InvocationId: 13, |
| 183 » » » » » ViewUrl: "https://example.com/13", | 198 » » » » » }, |
| 199 » » » » » ConfigRevision: "deadbeef", |
| 200 » » » » » Final: true, |
| 201 » » » » » Status: "ABORTED", |
| 202 » » » » » StartedTs: started.UnixNano() / 100
0, |
| 203 » » » » » FinishedTs: finished.UnixNano() / 10
00, |
| 204 » » » » » ViewUrl: "https://example.com/13"
, |
| 184 }, | 205 }, |
| 185 }) | 206 }) |
| 186 }) | 207 }) |
| 187 | |
| 188 }) | 208 }) |
| 189 } | 209 } |
| 190 | 210 |
| 211 func TestJobActionsApi(t *testing.T) { |
| 212 t.Parallel() |
| 213 |
| 214 Convey("works", t, func() { |
| 215 ctx := gaetesting.TestingContext() |
| 216 fakeEng, catalog := newTestEngine() |
| 217 ss := SchedulerServer{fakeEng, catalog} |
| 218 |
| 219 Convey("PermissionDenied", func() { |
| 220 ctx = auth.WithState(ctx, &authtest.FakeState{ |
| 221 Identity: "user:dog@example.com", |
| 222 IdentityGroups: []string{"dogs"}, |
| 223 }) |
| 224 |
| 225 Convey("Pause", func() { |
| 226 _, err := ss.PauseJob(ctx, &scheduler.JobRef{Pro
ject: "proj", Job: "job"}) |
| 227 s, ok := status.FromError(err) |
| 228 So(ok, ShouldBeTrue) |
| 229 So(s.Code(), ShouldEqual, codes.PermissionDenied
) |
| 230 }) |
| 231 |
| 232 Convey("Abort", func() { |
| 233 _, err := ss.AbortJob(ctx, &scheduler.JobRef{Pro
ject: "proj", Job: "job"}) |
| 234 s, ok := status.FromError(err) |
| 235 So(ok, ShouldBeTrue) |
| 236 So(s.Code(), ShouldEqual, codes.PermissionDenied
) |
| 237 }) |
| 238 }) |
| 239 |
| 240 ctx = auth.WithState(ctx, &authtest.FakeState{ |
| 241 Identity: "user:admin@example.com", |
| 242 IdentityGroups: []string{"administrators"}, |
| 243 }) |
| 244 |
| 245 Convey("OK", func() { |
| 246 onAction := func(jobID string, who identity.Identity) er
ror { |
| 247 So(jobID, ShouldEqual, "proj/job") |
| 248 So(who.Email(), ShouldEqual, "admin@example.com"
) |
| 249 return nil |
| 250 } |
| 251 |
| 252 Convey("Pause", func() { |
| 253 fakeEng.pauseJob = onAction |
| 254 r, err := ss.PauseJob(ctx, &scheduler.JobRef{Pro
ject: "proj", Job: "job"}) |
| 255 So(err, ShouldBeNil) |
| 256 So(r, ShouldResemble, &empty.Empty{}) |
| 257 }) |
| 258 |
| 259 Convey("Resume", func() { |
| 260 fakeEng.resumeJob = onAction |
| 261 r, err := ss.ResumeJob(ctx, &scheduler.JobRef{Pr
oject: "proj", Job: "job"}) |
| 262 So(err, ShouldBeNil) |
| 263 So(r, ShouldResemble, &empty.Empty{}) |
| 264 }) |
| 265 |
| 266 Convey("Abort", func() { |
| 267 fakeEng.abortJob = onAction |
| 268 r, err := ss.AbortJob(ctx, &scheduler.JobRef{Pro
ject: "proj", Job: "job"}) |
| 269 So(err, ShouldBeNil) |
| 270 So(r, ShouldResemble, &empty.Empty{}) |
| 271 }) |
| 272 }) |
| 273 |
| 274 Convey("NotFound", func() { |
| 275 fakeEng.pauseJob = func(jobID string, who identity.Ident
ity) error { |
| 276 return engine.ErrNoSuchJob |
| 277 } |
| 278 _, err := ss.PauseJob(ctx, &scheduler.JobRef{Project: "p
roj", Job: "job"}) |
| 279 s, ok := status.FromError(err) |
| 280 So(ok, ShouldBeTrue) |
| 281 So(s.Code(), ShouldEqual, codes.NotFound) |
| 282 }) |
| 283 }) |
| 284 } |
| 285 |
| 286 func TestAbortInvocationApi(t *testing.T) { |
| 287 t.Parallel() |
| 288 |
| 289 Convey("works", t, func() { |
| 290 ctx := gaetesting.TestingContext() |
| 291 fakeEng, catalog := newTestEngine() |
| 292 ss := SchedulerServer{fakeEng, catalog} |
| 293 |
| 294 Convey("PermissionDenied", func() { |
| 295 ctx = auth.WithState(ctx, &authtest.FakeState{ |
| 296 Identity: "user:dog@example.com", |
| 297 IdentityGroups: []string{"dogs"}, |
| 298 }) |
| 299 _, err := ss.AbortInvocation(ctx, &scheduler.InvocationR
ef{ |
| 300 JobRef: &scheduler.JobRef{Project: "proj",
Job: "job"}, |
| 301 InvocationId: 12, |
| 302 }) |
| 303 s, ok := status.FromError(err) |
| 304 So(ok, ShouldBeTrue) |
| 305 So(s.Code(), ShouldEqual, codes.PermissionDenied) |
| 306 }) |
| 307 |
| 308 ctx = auth.WithState(ctx, &authtest.FakeState{ |
| 309 Identity: "user:admin@example.com", |
| 310 IdentityGroups: []string{"administrators"}, |
| 311 }) |
| 312 |
| 313 Convey("OK", func() { |
| 314 fakeEng.abortInvocation = func(jobID string, invID int64
, who identity.Identity) error { |
| 315 So(jobID, ShouldEqual, "proj/job") |
| 316 So(who.Email(), ShouldEqual, "admin@example.com"
) |
| 317 So(invID, ShouldEqual, 12) |
| 318 return nil |
| 319 } |
| 320 r, err := ss.AbortInvocation(ctx, &scheduler.InvocationR
ef{ |
| 321 JobRef: &scheduler.JobRef{Project: "proj",
Job: "job"}, |
| 322 InvocationId: 12, |
| 323 }) |
| 324 So(err, ShouldBeNil) |
| 325 So(r, ShouldResemble, &empty.Empty{}) |
| 326 }) |
| 327 |
| 328 Convey("Error", func() { |
| 329 fakeEng.abortInvocation = func(jobID string, invID int64
, who identity.Identity) error { |
| 330 return engine.ErrNoSuchInvocation |
| 331 } |
| 332 _, err := ss.AbortInvocation(ctx, &scheduler.InvocationR
ef{ |
| 333 JobRef: &scheduler.JobRef{Project: "proj",
Job: "job"}, |
| 334 InvocationId: 12, |
| 335 }) |
| 336 s, ok := status.FromError(err) |
| 337 So(ok, ShouldBeTrue) |
| 338 So(s.Code(), ShouldEqual, codes.NotFound) |
| 339 }) |
| 340 }) |
| 341 } |
| 342 |
| 191 //// | 343 //// |
| 192 | 344 |
| 193 func registerUrlFetcher(cat catalog.Catalog) ([]byte, error) { | 345 func registerUrlFetcher(cat catalog.Catalog) ([]byte, error) { |
| 194 if err := cat.RegisterTaskManager(&urlfetch.TaskManager{}); err != nil { | 346 if err := cat.RegisterTaskManager(&urlfetch.TaskManager{}); err != nil { |
| 195 return nil, err | 347 return nil, err |
| 196 } | 348 } |
| 197 return proto.Marshal(&messages.TaskDefWrapper{ | 349 return proto.Marshal(&messages.TaskDefWrapper{ |
| 198 UrlFetch: &messages.UrlFetchTask{Url: "http://example.com/path"}
, | 350 UrlFetch: &messages.UrlFetchTask{Url: "http://example.com/path"}
, |
| 199 }) | 351 }) |
| 200 } | 352 } |
| 201 | 353 |
| 202 func newTestEngine() (*fakeEngine, catalog.Catalog) { | 354 func newTestEngine() (*fakeEngine, catalog.Catalog) { |
| 203 cat := catalog.New("scheduler.cfg") | 355 cat := catalog.New("scheduler.cfg") |
| 204 return &fakeEngine{}, cat | 356 return &fakeEngine{}, cat |
| 205 } | 357 } |
| 206 | 358 |
| 207 type fakeEngine struct { | 359 type fakeEngine struct { |
| 208 getAllJobs func() ([]*engine.Job, error) | 360 getAllJobs func() ([]*engine.Job, error) |
| 209 getProjectJobs func(projectID string) ([]*engine.Job, error) | 361 getProjectJobs func(projectID string) ([]*engine.Job, error) |
| 210 getJob func(jobID string) (*engine.Job, error) | 362 getJob func(jobID string) (*engine.Job, error) |
| 211 listInvocations func(pageSize int, cursor string) ([]*engine.Invocation,
string, error) | 363 listInvocations func(pageSize int, cursor string) ([]*engine.Invocation,
string, error) |
| 364 |
| 365 pauseJob func(jobID string, who identity.Identity) error |
| 366 resumeJob func(jobID string, who identity.Identity) error |
| 367 abortJob func(jobID string, who identity.Identity) error |
| 368 abortInvocation func(jobID string, invID int64, who identity.Identity) e
rror |
| 212 } | 369 } |
| 213 | 370 |
| 214 func (f *fakeEngine) GetAllProjects(c context.Context) ([]string, error) { | 371 func (f *fakeEngine) GetAllProjects(c context.Context) ([]string, error) { |
| 215 panic("not implemented") | 372 panic("not implemented") |
| 216 } | 373 } |
| 217 | 374 |
| 218 func (f *fakeEngine) GetAllJobs(c context.Context) ([]*engine.Job, error) { | 375 func (f *fakeEngine) GetAllJobs(c context.Context) ([]*engine.Job, error) { |
| 219 return f.getAllJobs() | 376 return f.getAllJobs() |
| 220 } | 377 } |
| 221 | 378 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 414 |
| 258 func (f *fakeEngine) PullPubSubOnDevServer(c context.Context, taskManagerName st
ring, publisher string) error { | 415 func (f *fakeEngine) PullPubSubOnDevServer(c context.Context, taskManagerName st
ring, publisher string) error { |
| 259 panic("not implemented") | 416 panic("not implemented") |
| 260 } | 417 } |
| 261 | 418 |
| 262 func (f *fakeEngine) TriggerInvocation(c context.Context, jobID string, triggere
dBy identity.Identity) (int64, error) { | 419 func (f *fakeEngine) TriggerInvocation(c context.Context, jobID string, triggere
dBy identity.Identity) (int64, error) { |
| 263 panic("not implemented") | 420 panic("not implemented") |
| 264 } | 421 } |
| 265 | 422 |
| 266 func (f *fakeEngine) PauseJob(c context.Context, jobID string, who identity.Iden
tity) error { | 423 func (f *fakeEngine) PauseJob(c context.Context, jobID string, who identity.Iden
tity) error { |
| 267 » panic("not implemented") | 424 » return f.pauseJob(jobID, who) |
| 268 } | 425 } |
| 269 | 426 |
| 270 func (f *fakeEngine) ResumeJob(c context.Context, jobID string, who identity.Ide
ntity) error { | 427 func (f *fakeEngine) ResumeJob(c context.Context, jobID string, who identity.Ide
ntity) error { |
| 271 » panic("not implemented") | 428 » return f.resumeJob(jobID, who) |
| 272 } | 429 } |
| 273 | 430 |
| 274 func (f *fakeEngine) AbortInvocation(c context.Context, jobID string, invID int6
4, who identity.Identity) error { | 431 func (f *fakeEngine) AbortInvocation(c context.Context, jobID string, invID int6
4, who identity.Identity) error { |
| 275 » panic("not implemented") | 432 » return f.abortInvocation(jobID, invID, who) |
| 276 } | 433 } |
| 277 | 434 |
| 278 func (f *fakeEngine) AbortJob(c context.Context, jobID string, who identity.Iden
tity) error { | 435 func (f *fakeEngine) AbortJob(c context.Context, jobID string, who identity.Iden
tity) error { |
| 279 » panic("not implemented") | 436 » return f.abortJob(jobID, who) |
| 280 } | 437 } |
| OLD | NEW |