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

Side by Side Diff: common/tsmon/flush_test.go

Issue 2123853002: Added unit annotation supports onto tsmon in go. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Specify the unit of logdog/collector/subscription/processing_time_ms with types.Milliseconds Created 4 years, 5 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 | « common/tsmon/callback_test.go ('k') | common/tsmon/metric/metric.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 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 tsmon 5 package tsmon
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 "time" 9 "time"
10 10
(...skipping 20 matching lines...) Expand all
31 31
32 Convey("Sends a metric", t, func() { 32 Convey("Sends a metric", t, func() {
33 c, s, m := WithFakes(c) 33 c, s, m := WithFakes(c)
34 s.Cells = []types.Cell{ 34 s.Cells = []types.Cell{
35 { 35 {
36 types.MetricInfo{ 36 types.MetricInfo{
37 Name: "foo", 37 Name: "foo",
38 Fields: []field.Field{}, 38 Fields: []field.Field{},
39 ValueType: types.StringType, 39 ValueType: types.StringType,
40 }, 40 },
41 types.MetricMetadata{},
41 types.CellData{ 42 types.CellData{
42 FieldVals: []interface{}{}, 43 FieldVals: []interface{}{},
43 ResetTime: time.Unix(1234, 1000), 44 ResetTime: time.Unix(1234, 1000),
44 Value: "bar", 45 Value: "bar",
45 }, 46 },
46 }, 47 },
47 } 48 }
48 s.DT = defaultTarget 49 s.DT = defaultTarget
49 m.CS = 42 50 m.CS = 42
50 51
51 So(Flush(c), ShouldBeNil) 52 So(Flush(c), ShouldBeNil)
52 53
53 So(len(m.Cells), ShouldEqual, 1) 54 So(len(m.Cells), ShouldEqual, 1)
54 So(len(m.Cells[0]), ShouldEqual, 1) 55 So(len(m.Cells[0]), ShouldEqual, 1)
55 So(m.Cells[0][0], ShouldResemble, types.Cell{ 56 So(m.Cells[0][0], ShouldResemble, types.Cell{
56 types.MetricInfo{ 57 types.MetricInfo{
57 Name: "foo", 58 Name: "foo",
58 Fields: []field.Field{}, 59 Fields: []field.Field{},
59 ValueType: types.StringType, 60 ValueType: types.StringType,
60 }, 61 },
62 types.MetricMetadata{},
61 types.CellData{ 63 types.CellData{
62 FieldVals: []interface{}{}, 64 FieldVals: []interface{}{},
63 ResetTime: time.Unix(1234, 1000), 65 ResetTime: time.Unix(1234, 1000),
64 Value: "bar", 66 Value: "bar",
65 }, 67 },
66 }) 68 })
67 }) 69 })
68 70
69 Convey("Splits up ChunkSize metrics", t, func() { 71 Convey("Splits up ChunkSize metrics", t, func() {
70 c, s, m := WithFakes(c) 72 c, s, m := WithFakes(c)
71 s.Cells = make([]types.Cell, 43) 73 s.Cells = make([]types.Cell, 43)
72 s.DT = defaultTarget 74 s.DT = defaultTarget
73 m.CS = 42 75 m.CS = 42
74 76
75 for i := 0; i < 43; i++ { 77 for i := 0; i < 43; i++ {
76 s.Cells[i] = types.Cell{ 78 s.Cells[i] = types.Cell{
77 types.MetricInfo{ 79 types.MetricInfo{
78 Name: "foo", 80 Name: "foo",
79 Fields: []field.Field{}, 81 Fields: []field.Field{},
80 ValueType: types.StringType, 82 ValueType: types.StringType,
81 }, 83 },
84 types.MetricMetadata{},
82 types.CellData{ 85 types.CellData{
83 FieldVals: []interface{}{}, 86 FieldVals: []interface{}{},
84 ResetTime: time.Unix(1234, 1000), 87 ResetTime: time.Unix(1234, 1000),
85 Value: "bar", 88 Value: "bar",
86 }, 89 },
87 } 90 }
88 } 91 }
89 92
90 So(Flush(c), ShouldBeNil) 93 So(Flush(c), ShouldBeNil)
91 94
92 So(len(m.Cells), ShouldEqual, 2) 95 So(len(m.Cells), ShouldEqual, 2)
93 So(len(m.Cells[0]), ShouldEqual, 42) 96 So(len(m.Cells[0]), ShouldEqual, 42)
94 So(len(m.Cells[1]), ShouldEqual, 1) 97 So(len(m.Cells[1]), ShouldEqual, 1)
95 }) 98 })
96 99
97 Convey("Doesn't split metrics when ChunkSize is 0", t, func() { 100 Convey("Doesn't split metrics when ChunkSize is 0", t, func() {
98 c, s, m := WithFakes(c) 101 c, s, m := WithFakes(c)
99 s.Cells = make([]types.Cell, 43) 102 s.Cells = make([]types.Cell, 43)
100 s.DT = defaultTarget 103 s.DT = defaultTarget
101 m.CS = 0 104 m.CS = 0
102 105
103 for i := 0; i < 43; i++ { 106 for i := 0; i < 43; i++ {
104 s.Cells[i] = types.Cell{ 107 s.Cells[i] = types.Cell{
105 types.MetricInfo{ 108 types.MetricInfo{
106 Name: "foo", 109 Name: "foo",
107 Fields: []field.Field{}, 110 Fields: []field.Field{},
108 ValueType: types.StringType, 111 ValueType: types.StringType,
109 }, 112 },
113 types.MetricMetadata{},
110 types.CellData{ 114 types.CellData{
111 FieldVals: []interface{}{}, 115 FieldVals: []interface{}{},
112 ResetTime: time.Unix(1234, 1000), 116 ResetTime: time.Unix(1234, 1000),
113 Value: "bar", 117 Value: "bar",
114 }, 118 },
115 } 119 }
116 } 120 }
117 121
118 So(Flush(c), ShouldBeNil) 122 So(Flush(c), ShouldBeNil)
119 123
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // Each 'flush' gets blocked on sending into 'moments'. Once unb locked, it 156 // Each 'flush' gets blocked on sending into 'moments'. Once unb locked, it
153 // advances timer by 'interval' sec (1 sec in the test). 157 // advances timer by 'interval' sec (1 sec in the test).
154 So(<-moments, ShouldEqual, 1) 158 So(<-moments, ShouldEqual, 1)
155 So(<-moments, ShouldEqual, 2) 159 So(<-moments, ShouldEqual, 2)
156 // and so on ... 160 // and so on ...
157 161
158 // Doesn't timeout => works. 162 // Doesn't timeout => works.
159 flusher.stop() 163 flusher.stop()
160 }) 164 })
161 } 165 }
OLDNEW
« no previous file with comments | « common/tsmon/callback_test.go ('k') | common/tsmon/metric/metric.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698