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

Side by Side Diff: impl/memory/taskqueue_test.go

Issue 2547793002: impl/memory: Use random int as auto generated task name in Task Queues. (Closed)
Patch Set: Created 4 years 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 | « impl/memory/taskqueue_data.go ('k') | no next file » | 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 memory 5 package memory
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "math/rand" 9 "math/rand"
10 "net/http" 10 "net/http"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 t := &tq.Task{Path: "/hello/world"} 44 t := &tq.Task{Path: "/hello/world"}
45 45
46 Convey("works", func() { 46 Convey("works", func() {
47 t.Delay = 4 * time.Second 47 t.Delay = 4 * time.Second
48 t.Header = http.Header{} 48 t.Header = http.Header{}
49 t.Header.Add("Cat", "tabby") 49 t.Header.Add("Cat", "tabby")
50 t.Payload = []byte("watwatwat") 50 t.Payload = []byte("watwatwat")
51 t.RetryOptions = &tq.RetryOptions{AgeLim it: 7 * time.Second} 51 t.RetryOptions = &tq.RetryOptions{AgeLim it: 7 * time.Second}
52 So(tq.Add(c, "", t), ShouldBeNil) 52 So(tq.Add(c, "", t), ShouldBeNil)
53 53
54 » » » » » name := "Z_UjshxM9ecyMQfGbZmUGOEcgxWU0_5 CGLl_-RntudwAw2DqQ5-58bzJiWQN4OKzeuUb9O4JrPkUw2rOvk2Ax46THojnQ6avBQgZdrKcJmrwQ6o 4qKfJdiyUbGXvy691yRfzLeQhs6cBhWrgf3wH-VPMcA4SC-zlbJ2U8An7I0zJQA5nBFnMNoMgT-2peGo ay3rCSbj4z9VFFm9kS_i6JCaQH518ujLDSNCYdjTq6B6lcWrZAh0U_q3a1S2nXEwrKiw_t9MTNQFgAQZ WyGBbvZQPmeRYtu8SPaWzTfd25v_YWgBuVL2rRSPSMvlDwE04nNdtvVzE8vNNiA1zRimmdzKeqATQF9_ ReUvj4D7U8dcS703DZWfKMBLgBffY9jqCassOOOw77V72Oq5EVauUw3Qw0L6bBsfM9FtahTKUdabzRZj XUoze3EK4KXPt3-wdidau-8JrVf2XFocjjZbwHoxcGvbtT3b4nGLDlgwdC00bwaFBZWff" 54 » » » » » var scheduled *tq.Task
55 » » » » » So(tqt.GetScheduledTasks()["default"][na me], ShouldResemble, &tq.Task{ 55 » » » » » for _, t := range tqt.GetScheduledTasks( )["default"] {
56 » » » » » » scheduled = t
57 » » » » » » break
58 » » » » » }
59 » » » » » So(scheduled, ShouldResemble, &tq.Task{
56 ETA: now.Add(4 * time.S econd), 60 ETA: now.Add(4 * time.S econd),
57 Header: http.Header{"Cat": []string{"tabby"}}, 61 Header: http.Header{"Cat": []string{"tabby"}},
58 Method: "POST", 62 Method: "POST",
59 » » » » » » Name: name, 63 » » » » » » Name: "75693937275487273 34",
60 Path: "/hello/world", 64 Path: "/hello/world",
61 Payload: []byte("watwatwat" ), 65 Payload: []byte("watwatwat" ),
62 RetryOptions: &tq.RetryOptions{A geLimit: 7 * time.Second}, 66 RetryOptions: &tq.RetryOptions{A geLimit: 7 * time.Second},
63 }) 67 })
64 }) 68 })
65 69
66 Convey("picks up namespace", func() { 70 Convey("picks up namespace", func() {
67 c, err := info.Namespace(c, "coolNamespa ce") 71 c, err := info.Namespace(c, "coolNamespa ce")
68 So(err, ShouldBeNil) 72 So(err, ShouldBeNil)
69 73
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 expect := []*tq.Task{t, t2} 149 expect := []*tq.Task{t, t2}
146 150
147 So(tq.Add(c, "default", expect...), Shou ldBeNil) 151 So(tq.Add(c, "default", expect...), Shou ldBeNil)
148 So(len(expect), ShouldEqual, 2) 152 So(len(expect), ShouldEqual, 2)
149 So(len(tqt.GetScheduledTasks()["default" ]), ShouldEqual, 2) 153 So(len(tqt.GetScheduledTasks()["default" ]), ShouldEqual, 2)
150 154
151 for i := range expect { 155 for i := range expect {
152 Convey(fmt.Sprintf("task %d: %s" , i, expect[i].Path), func() { 156 Convey(fmt.Sprintf("task %d: %s" , i, expect[i].Path), func() {
153 So(expect[i].Method, Sho uldEqual, "POST") 157 So(expect[i].Method, Sho uldEqual, "POST")
154 So(expect[i].ETA, Should HappenOnOrBefore, now) 158 So(expect[i].ETA, Should HappenOnOrBefore, now)
155 » » » » » » » So(len(expect[i].Name), ShouldEqual, 500) 159 » » » » » » » So(len(expect[i].Name), ShouldEqual, 19)
156 }) 160 })
157 } 161 }
158 162
159 Convey("stats work too", func() { 163 Convey("stats work too", func() {
160 delay := -time.Second * 400 164 delay := -time.Second * 400
161 165
162 t := &tq.Task{Path: "/somewhere" } 166 t := &tq.Task{Path: "/somewhere" }
163 t.Delay = delay 167 t.Delay = delay
164 So(tq.Add(c, "", t), ShouldBeNil ) 168 So(tq.Add(c, "", t), ShouldBeNil )
165 169
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 leased, err := tq.LeaseByTag(c, 100, "pull", tim e.Minute, "") 949 leased, err := tq.LeaseByTag(c, 100, "pull", tim e.Minute, "")
946 So(err, ShouldBeNil) 950 So(err, ShouldBeNil)
947 So(len(leased), ShouldEqual, 5) 951 So(len(leased), ShouldEqual, 5)
948 for i := 0; i < 5; i++ { 952 for i := 0; i < 5; i++ {
949 So(leased[i].Name, ShouldEqual, fmt.Spri ntf("task-%d", i)) 953 So(leased[i].Name, ShouldEqual, fmt.Spri ntf("task-%d", i))
950 } 954 }
951 }) 955 })
952 }) 956 })
953 }) 957 })
954 } 958 }
OLDNEW
« no previous file with comments | « impl/memory/taskqueue_data.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698