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

Side by Side Diff: appengine/tsmon/middleware_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 | « appengine/tsmon/grpc.go ('k') | appengine/tsmon/standardmetrics.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 tsmon 5 package tsmon
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 "net/http/httptest" 9 "net/http/httptest"
10 "testing" 10 "testing"
11 "time" 11 "time"
12 12
13 "github.com/golang/protobuf/proto" 13 "github.com/golang/protobuf/proto"
14 "github.com/luci/gae/service/datastore" 14 "github.com/luci/gae/service/datastore"
15 "github.com/luci/luci-go/common/tsmon" 15 "github.com/luci/luci-go/common/tsmon"
16 "github.com/luci/luci-go/common/tsmon/field" 16 "github.com/luci/luci-go/common/tsmon/field"
17 "github.com/luci/luci-go/common/tsmon/store" 17 "github.com/luci/luci-go/common/tsmon/store"
18 "github.com/luci/luci-go/common/tsmon/store/storetest" 18 "github.com/luci/luci-go/common/tsmon/store/storetest"
19 "github.com/luci/luci-go/common/tsmon/target" 19 "github.com/luci/luci-go/common/tsmon/target"
20 "github.com/luci/luci-go/common/tsmon/types" 20 "github.com/luci/luci-go/common/tsmon/types"
21 "github.com/luci/luci-go/server/router" 21 "github.com/luci/luci-go/server/router"
22 22
23 . "github.com/smartystreets/goconvey/convey" 23 . "github.com/smartystreets/goconvey/convey"
24 ) 24 )
25 25
26 func TestMiddleware(t *testing.T) { 26 func TestMiddleware(t *testing.T) {
27 t.Parallel() 27 t.Parallel()
28 » metric := &storetest.FakeMetric{"m", "", []field.Field{}, types.Cumulati veIntType} 28 » metric := &storetest.FakeMetric{
29 » » types.MetricInfo{"m", "", []field.Field{}, types.CumulativeIntTy pe},
30 » » types.MetricMetadata{}}
29 31
30 f := func(c *router.Context) { 32 f := func(c *router.Context) {
31 So(store.IsNilStore(tsmon.Store(c.Context)), ShouldBeFalse) 33 So(store.IsNilStore(tsmon.Store(c.Context)), ShouldBeFalse)
32 tsmon.Register(c.Context, metric) 34 tsmon.Register(c.Context, metric)
33 So(tsmon.Store(c.Context).Incr(c.Context, metric, time.Time{}, [ ]interface{}{}, int64(1)), ShouldBeNil) 35 So(tsmon.Store(c.Context).Incr(c.Context, metric, time.Time{}, [ ]interface{}{}, int64(1)), ShouldBeNil)
34 } 36 }
35 37
36 Convey("Creates instance entity", t, func() { 38 Convey("Creates instance entity", t, func() {
37 c, _ := buildGAETestContext() 39 c, _ := buildGAETestContext()
38 state, monitor := buildTestState() 40 state, monitor := buildTestState()
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 router.RunMiddleware( 148 router.RunMiddleware(
147 &router.Context{Context: c, Writer: rec, Request: &http. Request{}}, 149 &router.Context{Context: c, Writer: rec, Request: &http. Request{}},
148 router.NewMiddlewareChain(state.Middleware), 150 router.NewMiddlewareChain(state.Middleware),
149 func(c *router.Context) { 151 func(c *router.Context) {
150 So(store.IsNilStore(tsmon.Store(c.Context)), Sho uldBeTrue) 152 So(store.IsNilStore(tsmon.Store(c.Context)), Sho uldBeTrue)
151 }, 153 },
152 ) 154 )
153 So(rec.Code, ShouldEqual, http.StatusOK) 155 So(rec.Code, ShouldEqual, http.StatusOK)
154 }) 156 })
155 } 157 }
OLDNEW
« no previous file with comments | « appengine/tsmon/grpc.go ('k') | appengine/tsmon/standardmetrics.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698