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

Side by Side Diff: scheduler/appengine/presentation/state_test.go

Issue 2945843002: scheduler WIP: add GetAllJobs api. (Closed)
Patch Set: meh Created 3 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 | « scheduler/appengine/presentation/state.go ('k') | scheduler/appengine/ui/presentation.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package presentation
6
7 import (
8 "testing"
9
10 "golang.org/x/net/context"
11
12 "github.com/golang/protobuf/proto"
13 "github.com/luci/luci-go/scheduler/appengine/catalog"
14 "github.com/luci/luci-go/scheduler/appengine/engine"
15 "github.com/luci/luci-go/scheduler/appengine/messages"
16 "github.com/luci/luci-go/scheduler/appengine/task"
17 "github.com/luci/luci-go/scheduler/appengine/task/urlfetch"
18 . "github.com/smartystreets/goconvey/convey"
19 )
20
21 func TestGetPublicStateKind(t *testing.T) {
22 t.Parallel()
23
24 Convey("works", t, func() {
25 So(GetPublicStateKind(&engine.Job{
26 State: engine.JobState{State: engine.JobStateOverrun},
27 }, task.Traits{}), ShouldEqual, PublicStateOverrun)
28
29 So(GetPublicStateKind(&engine.Job{
30 State: engine.JobState{State: engine.JobStateSlowQueue},
31 }, task.Traits{}), ShouldEqual, PublicStateStarting)
32
33 So(GetPublicStateKind(&engine.Job{
34 State: engine.JobState{State: engine.JobStateSlowQueue, InvocationRetryCount: 1},
35 }, task.Traits{}), ShouldEqual, PublicStateRetrying)
36
37 So(GetPublicStateKind(&engine.Job{
38 Paused: true,
39 State: engine.JobState{State: engine.JobStateSuspended} ,
40 }, task.Traits{}), ShouldEqual, PublicStatePaused)
41
42 So(GetPublicStateKind(&engine.Job{
43 State: engine.JobState{State: engine.JobStateQueued, Inv ocationID: 1},
44 }, task.Traits{Multistage: true}), ShouldEqual, PublicStateStart ing)
45
46 So(GetPublicStateKind(&engine.Job{
47 State: engine.JobState{State: engine.JobStateQueued, Inv ocationID: 1},
48 }, task.Traits{Multistage: false}), ShouldEqual, PublicStateRunn ing)
49 })
50 }
51
52 func TestGetJobTraits(t *testing.T) {
53 t.Parallel()
54 Convey("works", t, func() {
55 cat := catalog.New("scheduler.cfg")
56 So(cat.RegisterTaskManager(&urlfetch.TaskManager{}), ShouldBeNil )
57 ctx := context.Background()
58
59 Convey("bad task", func() {
60 taskBlob, err := proto.Marshal(&messages.TaskDefWrapper{
61 Noop: &messages.NoopTask{},
62 })
63 So(err, ShouldBeNil)
64 traits, err := GetJobTraits(ctx, cat, &engine.Job{
65 Task: taskBlob,
66 })
67 So(err, ShouldNotBeNil)
68 So(traits, ShouldResemble, task.Traits{})
69 })
70
71 Convey("OK task", func() {
72 taskBlob, err := proto.Marshal(&messages.TaskDefWrapper{
73 UrlFetch: &messages.UrlFetchTask{Url: "http://ex ample.com/path"},
74 })
75 So(err, ShouldBeNil)
76 traits, err := GetJobTraits(ctx, cat, &engine.Job{
77 Task: taskBlob,
78 })
79 So(err, ShouldBeNil)
80 So(traits, ShouldResemble, task.Traits{})
81 })
82 })
83 }
OLDNEW
« no previous file with comments | « scheduler/appengine/presentation/state.go ('k') | scheduler/appengine/ui/presentation.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698