|
14 | 14 |
|
15 | 15 | )
|
16 | 16 | }
|
| 17 | + let(:frozen_time) { Time.utc(2020,4,20,4,20,45) } |
| 18 | + let(:ddog_time) { Time.utc(2020,4,20,4,16).to_i * 1000.0 } |
17 | 19 |
|
18 | 20 | before(:example) do
|
19 | 21 | ##
|
|
23 | 25 | [
|
24 | 26 | [
|
25 | 27 | 1,
|
26 |
| - Time.new(2020,04,20,04,19,45).to_i, |
| 28 | + Time.utc(2020,04,20,04,19,45).to_i, |
27 | 29 | 100000,
|
28 | 30 | [
|
29 | 31 | "eval",
|
|
35 | 37 | ],
|
36 | 38 | [
|
37 | 39 | 0,
|
38 |
| - Time.new(2020,04,20,04,19,15).to_i, |
| 40 | + Time.utc(2020,04,20,04,19,15).to_i, |
39 | 41 | 200000,
|
40 | 42 | [
|
41 | 43 | "eval",
|
|
73 | 75 | "query_index"=>0,
|
74 | 76 | "aggr"=>nil,
|
75 | 77 | "scope"=>"replication_group:replicationgroup",
|
76 |
| - "pointlist"=>[[1587381405000.0, 99994.0], [1587381404000.0, 99378.0]], |
| 78 | + "pointlist"=>[[ddog_time, 99994.0], [ddog_time - 5000, 99378.0]], |
77 | 79 | "expression"=>"rspec.redis.slowlog.micros.95percentile{replication_group:infraeng-dev-redis}",
|
78 | 80 | "unit"=>nil,
|
79 | 81 | "display_name"=>"rspec.redis.slowlog.micros.95percentile"
|
|
88 | 90 | }
|
89 | 91 |
|
90 | 92 | # Freeze time
|
91 |
| - Timecop.freeze(2020, 04, 20, 04, 20, 45) |
| 93 | + Timecop.freeze(frozen_time) |
92 | 94 |
|
93 | 95 | # Shhh...
|
94 | 96 | allow_any_instance_of(Logger).to receive(:info) {}
|
95 |
| - |
96 | 97 | end
|
97 | 98 |
|
98 | 99 |
|
|
135 | 136 | context 'first time' do
|
136 | 137 | it 'returns time an hour ago' do
|
137 | 138 | allow(ddog).to receive(:get_points) { ["", {"status" => "ok", "series" => [] }] }
|
138 |
| - expect(subject).to eq(Time.new(2020,4,20,3,20)) |
| 139 | + expect(subject).to eq(Time.utc(2020,4,20,3,20)) |
139 | 140 | end
|
140 | 141 | end
|
141 | 142 |
|
142 | 143 | context 'nth time' do
|
143 |
| - it { is_expected.to eq(Time.new(2020,4,20,4,16)) } |
| 144 | + it { is_expected.to eq(Time.utc(2020,4,20,4,16)) } |
144 | 145 | end
|
145 | 146 | end
|
146 | 147 |
|
147 | 148 | describe '#minute_precision' do
|
148 | 149 | subject { slowlog_check.minute_precision(Time.now) }
|
149 |
| - it { is_expected.to eq(Time.new(2020,4,20,4,20,0)) } |
| 150 | + it { is_expected.to eq(Time.utc(2020,4,20,4,20,0)) } |
150 | 151 | end
|
151 | 152 |
|
152 | 153 | describe '#reporting_interval' do
|
|
217 | 218 | }
|
218 | 219 | it { is_expected.to eq(
|
219 | 220 | {
|
220 |
| - Time.new(2020,04,20,04,17) => nil, |
221 |
| - Time.new(2020,04,20,04,18) => nil, |
222 |
| - Time.new(2020,04,20,04,19) => bucket, |
223 |
| - Time.new(2020,04,20,04,20) => nil |
| 221 | + 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, |
| 224 | + Time.utc(2020,04,20,04,20) => nil |
224 | 225 | }
|
225 | 226 | )
|
226 | 227 | }
|
|
249 | 250 |
|
250 | 251 | expect(ddog).to have_received(:emit_points).with(
|
251 | 252 | "rspec.redis.slowlog.micros.avg",
|
252 |
| - [[Time.new(2020,04,20,04,19), 150000]], |
| 253 | + [[Time.utc(2020,04,20,04,19), 150000]], |
253 | 254 | {
|
254 | 255 | :host=>"replicationgroup",
|
255 | 256 | :interval=>60,
|
|
0 commit comments