Skip to content

Commit 21a636d

Browse files
committed
test: include multiple minutes in spec
1 parent 38a7ecf commit 21a636d

File tree

1 file changed

+69
-21
lines changed

1 file changed

+69
-21
lines changed

spec/slowlog_check_spec.rb

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,32 @@
2424
allow(redis).to receive(:slowlog).with('get') {
2525
[
2626
[
27-
1,
27+
3,
2828
Time.utc(2020,04,20,04,19,45).to_i,
29+
400000,
30+
[
31+
"eval",
32+
"",
33+
"0"
34+
],
35+
"192.0.2.40:55700",
36+
""
37+
],
38+
[
39+
2,
40+
Time.utc(2020,04,20,04,19,15).to_i,
41+
100000,
42+
[
43+
"eval",
44+
"",
45+
"0"
46+
],
47+
"192.0.2.40:55700",
48+
""
49+
],
50+
[
51+
1,
52+
Time.utc(2020,04,20,04,18,45).to_i,
2953
100000,
3054
[
3155
"eval",
@@ -37,7 +61,7 @@
3761
],
3862
[
3963
0,
40-
Time.utc(2020,04,20,04,19,15).to_i,
64+
Time.utc(2020,04,20,04,18,15).to_i,
4165
200000,
4266
[
4367
"eval",
@@ -201,7 +225,7 @@
201225

202226
describe '#slowlogs_by_flush_interval' do
203227
subject { slowlog_check.slowlogs_by_flush_interval }
204-
let(:bucket) {
228+
let(:bucket18) {
205229
{
206230
"eval" =>
207231
{
@@ -216,11 +240,26 @@
216240
}
217241
}
218242
}
243+
let(:bucket19) {
244+
{
245+
"eval" =>
246+
{
247+
_95percentile: 100000,
248+
avg: 250000,
249+
count: 2,
250+
max: 400000,
251+
median: 100000,
252+
min: 100000,
253+
sum: 500000,
254+
values: [400000, 100000]
255+
}
256+
}
257+
}
219258
it { is_expected.to eq(
220259
{
221260
Time.utc(2020,04,20,04,17) => nil,
222-
Time.utc(2020,04,20,04,18) => nil,
223-
Time.utc(2020,04,20,04,19) => bucket,
261+
Time.utc(2020,04,20,04,18) => bucket18,
262+
Time.utc(2020,04,20,04,19) => bucket19,
224263
Time.utc(2020,04,20,04,20) => nil
225264
}
226265
)
@@ -243,28 +282,37 @@
243282

244283
describe '#ship_slowlogs' do
245284
subject { slowlog_check.ship_slowlogs }
246-
let(:tags) { slowlog_check.default_tags.merge(command: 'eval') }
285+
let(:options) {
286+
{
287+
:host=>"replicationgroup",
288+
:interval=>60,
289+
:type=>"gauge",
290+
:tags=>
291+
{
292+
:aws=>"true",
293+
:command=>"eval",
294+
:env=>"test",
295+
:namespace=>"rspec",
296+
:replication_group=>"replicationgroup",
297+
:service=>"replicationgroup"
298+
}
299+
}
300+
}
301+
247302
it 'sends the right data to datadog' do
248303
allow(ddog).to receive(:emit_points) {["200", { "status" => "ok" }]}
249304
subject
250305

251306
expect(ddog).to have_received(:emit_points).with(
252307
"rspec.redis.slowlog.micros.avg",
253-
[[Time.utc(2020,04,20,04,19), 150000]],
254-
{
255-
:host=>"replicationgroup",
256-
:interval=>60,
257-
:type=>"gauge",
258-
:tags=>
259-
{
260-
:aws=>"true",
261-
:command=>"eval",
262-
:env=>"test",
263-
:namespace=>"rspec",
264-
:replication_group=>"replicationgroup",
265-
:service=>"replicationgroup"
266-
}
267-
}
308+
[[Time.utc(2020,04,20,04,18), 150000]],
309+
options
310+
)
311+
312+
expect(ddog).to have_received(:emit_points).with(
313+
"rspec.redis.slowlog.micros.avg",
314+
[[Time.utc(2020,04,20,04,19), 250000]],
315+
options
268316
)
269317
end
270318
end

0 commit comments

Comments
 (0)