| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // 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 |
| 11 "github.com/golang/protobuf/proto" |
| 11 "golang.org/x/net/context" | 12 "golang.org/x/net/context" |
| 12 | 13 |
| 13 "github.com/luci/luci-go/common/clock" | 14 "github.com/luci/luci-go/common/clock" |
| 14 "github.com/luci/luci-go/common/clock/testclock" | 15 "github.com/luci/luci-go/common/clock/testclock" |
| 15 "github.com/luci/luci-go/common/tsmon/field" | 16 "github.com/luci/luci-go/common/tsmon/field" |
| 16 "github.com/luci/luci-go/common/tsmon/target" | 17 "github.com/luci/luci-go/common/tsmon/target" |
| 17 "github.com/luci/luci-go/common/tsmon/types" | 18 "github.com/luci/luci-go/common/tsmon/types" |
| 18 | 19 |
| 19 pb "github.com/luci/luci-go/common/tsmon/ts_mon_proto" | 20 pb "github.com/luci/luci-go/common/tsmon/ts_mon_proto" |
| 20 | 21 |
| 21 . "github.com/smartystreets/goconvey/convey" | 22 . "github.com/smartystreets/goconvey/convey" |
| 22 ) | 23 ) |
| 23 | 24 |
| 24 func TestFlush(t *testing.T) { | 25 func TestFlush(t *testing.T) { |
| 25 c := context.Background() | 26 c := context.Background() |
| 26 | 27 |
| 27 » defaultTarget := (*target.Task)(&pb.Task{ServiceName: "test"}) | 28 » defaultTarget := (*target.Task)(&pb.Task{ |
| 29 » » ServiceName: proto.String("test"), |
| 30 » }) |
| 28 | 31 |
| 29 Convey("Sends a metric", t, func() { | 32 Convey("Sends a metric", t, func() { |
| 30 c, s, m := WithFakes(c) | 33 c, s, m := WithFakes(c) |
| 31 s.Cells = []types.Cell{ | 34 s.Cells = []types.Cell{ |
| 32 { | 35 { |
| 33 types.MetricInfo{ | 36 types.MetricInfo{ |
| 34 Name: "foo", | 37 Name: "foo", |
| 35 Fields: []field.Field{}, | 38 Fields: []field.Field{}, |
| 36 ValueType: types.StringType, | 39 ValueType: types.StringType, |
| 37 }, | 40 }, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // Each 'flush' gets blocked on sending into 'moments'. Once unb
locked, it | 152 // Each 'flush' gets blocked on sending into 'moments'. Once unb
locked, it |
| 150 // advances timer by 'interval' sec (1 sec in the test). | 153 // advances timer by 'interval' sec (1 sec in the test). |
| 151 So(<-moments, ShouldEqual, 1) | 154 So(<-moments, ShouldEqual, 1) |
| 152 So(<-moments, ShouldEqual, 2) | 155 So(<-moments, ShouldEqual, 2) |
| 153 // and so on ... | 156 // and so on ... |
| 154 | 157 |
| 155 // Doesn't timeout => works. | 158 // Doesn't timeout => works. |
| 156 flusher.stop() | 159 flusher.stop() |
| 157 }) | 160 }) |
| 158 } | 161 } |
| OLD | NEW |