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

Side by Side Diff: filter/dsQueryBatch/filter_test.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: Lightning talk licenses. Created 4 years, 3 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 | « filter/count/user.go ('k') | filter/dscache/context.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 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 dsQueryBatch 5 package dsQueryBatch
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 10
(...skipping 12 matching lines...) Expand all
23 func TestRun(t *testing.T) { 23 func TestRun(t *testing.T) {
24 t.Parallel() 24 t.Parallel()
25 25
26 Convey("A memory with a counting filter and data set installed", t, func () { 26 Convey("A memory with a counting filter and data set installed", t, func () {
27 c, cf := count.FilterRDS(memory.Use(context.Background())) 27 c, cf := count.FilterRDS(memory.Use(context.Background()))
28 28
29 items := make([]*Item, 1024) 29 items := make([]*Item, 1024)
30 for i := range items { 30 for i := range items {
31 items[i] = &Item{int64(i + 1)} 31 items[i] = &Item{int64(i + 1)}
32 } 32 }
33 » » if err := ds.Get(c).PutMulti(items); err != nil { 33 » » if err := ds.Put(c, items); err != nil {
34 panic(err) 34 panic(err)
35 } 35 }
36 » » ds.Get(c).Testable().CatchupIndexes() 36 » » ds.GetTestable(c).CatchupIndexes()
37 37
38 for _, sizeBase := range []int{ 38 for _, sizeBase := range []int{
39 1, 39 1,
40 16, 40 16,
41 1024, 41 1024,
42 2048, 42 2048,
43 } { 43 } {
44 // Adjust to hit edge cases. 44 // Adjust to hit edge cases.
45 for _, delta := range []int{-1, 0, 1} { 45 for _, delta := range []int{-1, 0, 1} {
46 size := sizeBase + delta 46 size := sizeBase + delta
47 if size <= 0 { 47 if size <= 0 {
48 continue 48 continue
49 } 49 }
50 50
51 Convey(fmt.Sprintf(`With a batch filter size %d installed`, size), func() { 51 Convey(fmt.Sprintf(`With a batch filter size %d installed`, size), func() {
52 c = BatchQueries(c, int32(size)) 52 c = BatchQueries(c, int32(size))
53 q := ds.NewQuery("Item") 53 q := ds.NewQuery("Item")
54 54
55 Convey(`Can retrieve all of the items.`, func() { 55 Convey(`Can retrieve all of the items.`, func() {
56 var got []*Item 56 var got []*Item
57 » » » » » » So(ds.Get(c).GetAll(q, &got), Sh ouldBeNil) 57 » » » » » » So(ds.GetAll(c, q, &got), Should BeNil)
58 So(got, ShouldResemble, items) 58 So(got, ShouldResemble, items)
59 59
60 // One call for every sub-query, plus one to hit Stop. 60 // One call for every sub-query, plus one to hit Stop.
61 runCalls := (len(items) / size) + 1 61 runCalls := (len(items) / size) + 1
62 So(cf.Run.Successes(), ShouldEqu al, runCalls) 62 So(cf.Run.Successes(), ShouldEqu al, runCalls)
63 }) 63 })
64 64
65 Convey(`With a limit of 128, will retrie ve 128 items.`, func() { 65 Convey(`With a limit of 128, will retrie ve 128 items.`, func() {
66 const limit = 128 66 const limit = 128
67 q = q.Limit(int32(limit)) 67 q = q.Limit(int32(limit))
68 68
69 var got []*Item 69 var got []*Item
70 » » » » » » So(ds.Get(c).GetAll(q, &got), Sh ouldBeNil) 70 » » » » » » So(ds.GetAll(c, q, &got), Should BeNil)
71 So(got, ShouldResemble, items[:l imit]) 71 So(got, ShouldResemble, items[:l imit])
72 72
73 // One call for every sub-query, plus one to hit Stop. 73 // One call for every sub-query, plus one to hit Stop.
74 runCalls := (limit / size) 74 runCalls := (limit / size)
75 if (limit % size) != 0 { 75 if (limit % size) != 0 {
76 runCalls++ 76 runCalls++
77 } 77 }
78 So(cf.Run.Successes(), ShouldEqu al, runCalls) 78 So(cf.Run.Successes(), ShouldEqu al, runCalls)
79 }) 79 })
80 }) 80 })
81 } 81 }
82 } 82 }
83 }) 83 })
84 } 84 }
OLDNEW
« no previous file with comments | « filter/count/user.go ('k') | filter/dscache/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698