forked from rewardStyle/kinetic
-
Notifications
You must be signed in to change notification settings - Fork 1
/
producer_stats_test.go
173 lines (138 loc) · 5.45 KB
/
producer_stats_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package kinetic
import (
"math/rand"
"testing"
"time"
metrics "github.com/rcrowley/go-metrics"
. "github.com/smartystreets/goconvey/convey"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
func TestProducerStatsCollector(t *testing.T) {
Convey("given a NilProducerStatsCollector", t, func() {
var sc ProducerStatsCollector = &NilProducerStatsCollector{}
So(sc, ShouldNotBeNil)
Convey("check that AddSentTotal does not error", func() {
sc.AddSentTotal(1)
})
Convey("check that AddSentSuccess does not error", func() {
sc.AddSentSuccess(1)
})
Convey("check that AddSentFailed does not error", func() {
sc.AddSentFailed(1)
})
Convey("check that AddSentRetried does not error", func() {
sc.AddSentRetried(1)
})
Convey("check that AddDroppedTotal does not error", func() {
sc.AddDroppedTotal(1)
})
Convey("check that AddDroppedCapacity does not error", func() {
sc.AddDroppedCapacity(1)
})
Convey("check that AddDroppedRetries does not error", func() {
sc.AddDroppedRetries(1)
})
Convey("check that WriteProvisionedThroughputExceeded does not error", func() {
sc.AddWriteProvisionedThroughputExceeded(1)
})
Convey("check that AddPutRecordsCalled does not eroror", func() {
sc.AddPutRecordsCalled(1)
})
Convey("check that AddProvisionedThroughputExceeded does not erro", func() {
sc.AddWriteProvisionedThroughputExceeded(1)
})
Convey("check that AddPutRecordsTimeout does not error", func() {
sc.AddPutRecordsTimeout(1)
})
Convey("check that UpdatePutRecordsDuration does not error", func() {
sc.UpdatePutRecordsDuration(time.Second)
})
Convey("check that UpdatePutRecordsBuildDuration does not error", func() {
sc.UpdatePutRecordsBuildDuration(time.Second)
})
Convey("check that UpdatePutRecordsSendDuration does not error", func() {
sc.UpdatePutRecordsSendDuration(time.Second)
})
Convey("check that UpdateProducerConcurrency does not error", func() {
sc.UpdateProducerConcurrency(5)
})
})
Convey("given a DefaultProdcuerStatsCollector", t, func() {
r := metrics.NewRegistry()
var sc ProducerStatsCollector = NewDefaultProducerStatsCollector(r)
So(sc, ShouldNotBeNil)
Convey("check that AddSentTotal does not error", func() {
count := rand.Int()
sc.AddSentTotal(count)
So(sc.(*DefaultProducerStatsCollector).SentTotal.Count(), ShouldEqual, int64(count))
})
Convey("check that AddSentSuccess does not error", func() {
count := rand.Int()
sc.AddSentSuccess(count)
So(sc.(*DefaultProducerStatsCollector).SentSuccess.Count(), ShouldEqual, int64(count))
})
Convey("check that AddSentFailed does not error", func() {
count := rand.Int()
sc.AddSentFailed(count)
So(sc.(*DefaultProducerStatsCollector).SentFailed.Count(), ShouldEqual, int64(count))
})
Convey("check that AddSentRetried does not error", func() {
count := rand.Int()
sc.AddSentRetried(count)
So(sc.(*DefaultProducerStatsCollector).SentRetried.Count(), ShouldEqual, int64(count))
})
Convey("check that AddDroppedTotal does not error", func() {
count := rand.Int()
sc.AddDroppedTotal(count)
So(sc.(*DefaultProducerStatsCollector).DroppedTotal.Count(), ShouldEqual, int64(count))
})
Convey("check that AddDroppedCapacity does not error", func() {
count := rand.Int()
sc.AddDroppedCapacity(count)
So(sc.(*DefaultProducerStatsCollector).DroppedCapacity.Count(), ShouldEqual, int64(count))
})
Convey("check that AddDroppedRetries does not error", func() {
count := rand.Int()
sc.AddDroppedRetries(count)
So(sc.(*DefaultProducerStatsCollector).DroppedRetries.Count(), ShouldEqual, int64(count))
})
Convey("check that WriteProvisionedThroughputExceeded does not error", func() {
count := rand.Int()
sc.AddWriteProvisionedThroughputExceeded(count)
So(sc.(*DefaultProducerStatsCollector).PutRecordsProvisionedThroughputExceeded.Count(), ShouldEqual, int64(count))
})
Convey("check that AddPutRecordsCalled does not eroror", func() {
count := rand.Int()
sc.AddPutRecordsCalled(count)
So(sc.(*DefaultProducerStatsCollector).PutRecordsCalled.Count(), ShouldEqual, int64(count))
})
Convey("check that WriteProvisionedThroughputExceeded does not erro", func() {
count := rand.Int()
sc.AddWriteProvisionedThroughputExceeded(count)
So(sc.(*DefaultProducerStatsCollector).PutRecordsProvisionedThroughputExceeded.Count(), ShouldEqual, int64(count))
})
Convey("check that AddPutRecordsTimeout does not error", func() {
count := rand.Int()
sc.AddPutRecordsTimeout(count)
So(sc.(*DefaultProducerStatsCollector).PutRecordsTimeout.Count(), ShouldEqual, int64(count))
})
Convey("check that UpdatePutRecordsDuration does not error", func() {
sc.UpdatePutRecordsDuration(time.Second)
So(sc.(*DefaultProducerStatsCollector).PutRecordsDuration.Value(), ShouldEqual, 1000000000)
})
Convey("check that UpdatePutRecordsBuildDuration does not error", func() {
sc.UpdatePutRecordsBuildDuration(time.Second)
So(sc.(*DefaultProducerStatsCollector).PutRecordsBuildDuration.Value(), ShouldEqual, 1000000000)
})
Convey("check that UpdatePutRecordsSendDuration does not error", func() {
sc.UpdatePutRecordsSendDuration(time.Second)
So(sc.(*DefaultProducerStatsCollector).PutRecordsSendDuration.Value(), ShouldEqual, 1000000000)
})
Convey("check that UpdateProducerConcurrency does not error", func() {
sc.UpdateProducerConcurrency(5)
So(sc.(*DefaultProducerStatsCollector).ProducerConcurrency.Value(), ShouldEqual, 5)
})
})
}