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

Side by Side Diff: common/tsmon/metric/standard_metrics_test.go

Issue 2290993002: Always set presence/up from go tsmon apps. (Closed)
Patch Set: 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 | « common/tsmon/metric/standard_metrics.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 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 metric 5 package metric
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 "time" 9 "time"
10 10
11 "github.com/luci/luci-go/common/tsmon"
12 "golang.org/x/net/context"
13
11 . "github.com/smartystreets/goconvey/convey" 14 . "github.com/smartystreets/goconvey/convey"
12 ) 15 )
13 16
14 func TestStandardMetrics(t *testing.T) { 17 func TestStandardMetrics(t *testing.T) {
15 t.Parallel() 18 t.Parallel()
16 19
17 durMillis := 5.0 20 durMillis := 5.0
18 dur := time.Duration(durMillis * float64(time.Millisecond)) 21 dur := time.Duration(durMillis * float64(time.Millisecond))
19 22
20 Convey("UpdatePresenceMetrics updates presenceMetric", t, func() { 23 Convey("UpdatePresenceMetrics updates presenceMetric", t, func() {
21 » » c := makeContext() // Defined in metrics_test.go 24 » » c, m := tsmon.WithDummyInMemory(context.Background())
22 » » v, err := presenceMetric.Get(c) 25 » » registerCallbacks(c)
23 » » So(v, ShouldEqual, false)
24 » » So(err, ShouldBeNil)
25 26
26 » » UpdatePresenceMetrics(c) 27 » » So(tsmon.Flush(c), ShouldBeNil)
27 » » v, err = presenceMetric.Get(c) 28
28 » » So(v, ShouldEqual, true) 29 » » So(len(m.Cells), ShouldEqual, 1)
29 » » So(err, ShouldBeNil) 30 » » So(len(m.Cells[0]), ShouldEqual, 1)
31 » » So(m.Cells[0][0].Name, ShouldEqual, "presence/up")
32 » » So(m.Cells[0][0].Value, ShouldEqual, true)
30 }) 33 })
31 34
32 Convey("UpdateHTTPMetrics updates client metrics", t, func() { 35 Convey("UpdateHTTPMetrics updates client metrics", t, func() {
33 c := makeContext() 36 c := makeContext()
34 name, client := "test_name", "test_client" 37 name, client := "test_name", "test_client"
35 d, err := requestBytesMetric.Get(c, name, client) 38 d, err := requestBytesMetric.Get(c, name, client)
36 So(d, ShouldBeNil) 39 So(d, ShouldBeNil)
37 So(err, ShouldBeNil) 40 So(err, ShouldBeNil)
38 d, err = responseBytesMetric.Get(c, name, client) 41 d, err = responseBytesMetric.Get(c, name, client)
39 So(d, ShouldBeNil) 42 So(d, ShouldBeNil)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 So(err, ShouldBeNil) 115 So(err, ShouldBeNil)
113 d, err = serverResponseBytesMetric.Get(c, code, name, is Robot) 116 d, err = serverResponseBytesMetric.Get(c, code, name, is Robot)
114 So(d.Sum(), ShouldEqual, 321) 117 So(d.Sum(), ShouldEqual, 321)
115 So(err, ShouldBeNil) 118 So(err, ShouldBeNil)
116 v, errV = serverResponseStatusMetric.Get(c, code, name, isRobot) 119 v, errV = serverResponseStatusMetric.Get(c, code, name, isRobot)
117 So(v, ShouldEqual, 1) 120 So(v, ShouldEqual, 1)
118 So(err, ShouldBeNil) 121 So(err, ShouldBeNil)
119 }) 122 })
120 }) 123 })
121 } 124 }
OLDNEW
« no previous file with comments | « common/tsmon/metric/standard_metrics.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698