@@ -37,6 +37,8 @@ import (
37
37
"testing"
38
38
)
39
39
40
+ const defaultStepMs = 5 * 60 * 1000 // 5 minutes
41
+
40
42
func TestIngestData (t * testing.T ) {
41
43
v3ioConfig , err := tsdbtest .LoadV3ioConfig ()
42
44
if err != nil {
@@ -115,7 +117,7 @@ func testIngestDataCase(t *testing.T, v3ioConfig *config.V3ioConfig,
115
117
t .Fatalf ("Failed to wait for appender completion. reason: %s" , err )
116
118
}
117
119
118
- tsdbtest .ValidateCountOfSamples (t , adapter , metricsName , len (data ), from , to )
120
+ tsdbtest .ValidateCountOfSamples (t , adapter , metricsName , len (data ), from , to , - 1 )
119
121
}
120
122
121
123
func TestQueryData (t * testing.T ) {
@@ -133,52 +135,65 @@ func TestQueryData(t *testing.T) {
133
135
aggregators string
134
136
from int64
135
137
to int64
138
+ step int64
136
139
expected map [string ][]tsdbtest.DataPoint
137
140
ignoreReason string
138
141
expectFail bool
139
142
}{
140
143
{desc : "Should ingest and query one data point" , metricName : "cpu" ,
141
- labels : utils .FromStrings ("testLabel" , "balbala" ),
142
- data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 314.3 }},
143
- from : 0 , to : 1532940510 + 1 ,
144
+ labels : utils .FromStrings ("testLabel" , "balbala" ),
145
+ data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 314.3 }},
146
+ from : 0 ,
147
+ to : 1532940510 + 1 ,
148
+ step : defaultStepMs ,
144
149
expected : map [string ][]tsdbtest.DataPoint {"" : {{Time : 1532940510 , Value : 314.3 }}}},
145
150
146
151
{desc : "Should ingest and query multiple data points" , metricName : "cpu" ,
147
152
labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
148
153
data : []tsdbtest.DataPoint {{Time : 1532940510 - 10 , Value : 314.3 },
149
154
{Time : 1532940510 - 5 , Value : 300.3 },
150
155
{Time : 1532940510 , Value : 3234.6 }},
151
- from : 0 , to : 1532940510 + 1 ,
156
+ from : 0 ,
157
+ to : 1532940510 + 1 ,
158
+ step : defaultStepMs ,
152
159
expected : map [string ][]tsdbtest.DataPoint {"" : {{Time : 1532940510 - 10 , Value : 314.3 },
153
160
{Time : 1532940510 - 5 , Value : 300.3 },
154
161
{Time : 1532940510 , Value : 3234.6 }}}},
155
162
156
163
{desc : "Should query with filter on metric name" , metricName : "cpu" ,
157
- labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
158
- data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 33.3 }},
159
- filter : "_name=='cpu'" ,
160
- from : 0 , to : 1532940510 + 1 ,
164
+ labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
165
+ data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 33.3 }},
166
+ filter : "_name=='cpu'" ,
167
+ from : 0 ,
168
+ to : 1532940510 + 1 ,
169
+ step : defaultStepMs ,
161
170
expected : map [string ][]tsdbtest.DataPoint {"" : {{Time : 1532940510 , Value : 33.3 }}}},
162
171
163
172
{desc : "Should query with filter on label name" , metricName : "cpu" ,
164
- labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
165
- data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 31.3 }},
166
- filter : "os=='linux'" ,
167
- from : 0 , to : 1532940510 + 1 ,
173
+ labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
174
+ data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 31.3 }},
175
+ filter : "os=='linux'" ,
176
+ from : 0 ,
177
+ to : 1532940510 + 1 ,
178
+ step : defaultStepMs ,
168
179
expected : map [string ][]tsdbtest.DataPoint {"" : {{Time : 1532940510 , Value : 31.3 }}}},
169
180
170
181
{desc : "Should ingest and query data with '-' in the metric name (IG-8585)" , metricName : "cool-cpu" ,
171
- labels : utils .FromStrings ("testLabel" , "balbala" ),
172
- data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 314.3 }},
173
- from : 0 , to : 1532940510 + 1 ,
182
+ labels : utils .FromStrings ("testLabel" , "balbala" ),
183
+ data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 314.3 }},
184
+ from : 0 ,
185
+ to : 1532940510 + 1 ,
186
+ step : defaultStepMs ,
174
187
expected : map [string ][]tsdbtest.DataPoint {"" : {{Time : 1532940510 , Value : 314.3 }}}},
175
188
176
189
{desc : "Should ingest and query by time" , metricName : "cpu" ,
177
190
labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
178
191
data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 314.3 },
179
192
{Time : 1532940510 + 5 , Value : 300.3 },
180
193
{Time : 1532940510 + 10 , Value : 3234.6 }},
181
- from : 1532940510 + 2 , to : 1532940510 + 12 ,
194
+ from : 1532940510 + 2 ,
195
+ to : 1532940510 + 12 ,
196
+ step : defaultStepMs ,
182
197
expected : map [string ][]tsdbtest.DataPoint {"" : {{Time : 1532940510 + 5 , Value : 300.3 },
183
198
{Time : 1532940510 + 10 , Value : 3234.6 }}}},
184
199
@@ -187,26 +202,31 @@ func TestQueryData(t *testing.T) {
187
202
data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 314.3 },
188
203
{Time : 1532940510 + 5 , Value : 300.3 },
189
204
{Time : 1532940510 + 10 , Value : 3234.6 }},
190
- from : 1532940510 + 1 , to : 1532940510 + 4 ,
205
+ from : 1532940510 + 1 ,
206
+ to : 1532940510 + 4 ,
207
+ step : defaultStepMs ,
191
208
expected : map [string ][]tsdbtest.DataPoint {}},
192
209
193
210
{desc : "Should ingest and query an aggregator" , metricName : "cpu" ,
194
211
labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
195
212
data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 300.3 },
196
213
{Time : 1532940510 + 5 , Value : 300.3 },
197
214
{Time : 1532940510 + 10 , Value : 100.4 }},
198
- from : 1532940510 , to : 1532940510 + 11 ,
215
+ from : 1532940510 ,
216
+ to : 1532940510 + 11 ,
217
+ step : defaultStepMs ,
199
218
aggregators : "sum" ,
200
219
expected : map [string ][]tsdbtest.DataPoint {"sum" : {{Time : 1532940510 , Value : 701.0 }}}},
201
220
202
- {desc : "Should ingest and query an aggregator EXTRA " , metricName : "cpu" ,
221
+ {desc : "Should ingest and query an aggregator with interval greater than step size " , metricName : "cpu" ,
203
222
labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
204
223
data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 300.3 },
205
224
{Time : 1532940510 + 60 , Value : 300.3 },
206
225
{Time : 1532940510 + 2 * 60 , Value : 100.4 },
207
- {Time : 1532940510 + 2 * 60 , Value : 200.0 }},
226
+ {Time : 1532940510 + 5 * 60 , Value : 200.0 }},
208
227
from : 1532940510 ,
209
228
to : 1532940510 + 6 * 60 ,
229
+ step : defaultStepMs ,
210
230
aggregators : "sum" ,
211
231
expected : map [string ][]tsdbtest.DataPoint {"sum" : {{Time : 1532940510 , Value : 901.0 }}}},
212
232
@@ -215,7 +235,9 @@ func TestQueryData(t *testing.T) {
215
235
data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 300.3 },
216
236
{Time : 1532940510 + 5 , Value : 300.3 },
217
237
{Time : 1532940510 + 10 , Value : 100.4 }},
218
- from : 1532940510 , to : 1532940510 + 11 ,
238
+ from : 1532940510 ,
239
+ to : 1532940510 + 11 ,
240
+ step : defaultStepMs ,
219
241
aggregators : "sum,count" ,
220
242
expected : map [string ][]tsdbtest.DataPoint {"sum" : {{Time : 1532940510 , Value : 701.0 }},
221
243
"count" : {{Time : 1532940510 , Value : 3 }}}},
@@ -225,15 +247,19 @@ func TestQueryData(t *testing.T) {
225
247
data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 314.3 },
226
248
{Time : 1532940510 + 5 , Value : 300.3 },
227
249
{Time : 1532940510 + 10 , Value : 3234.6 }},
228
- from : 1532940510 + 1 , to : 0 ,
250
+ from : 1532940510 + 1 ,
251
+ to : 0 ,
252
+ step : defaultStepMs ,
229
253
expectFail : true ,
230
254
},
231
255
232
256
{desc : "Should query with filter on not existing metric name" , metricName : "cpu" ,
233
- labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
234
- data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 33.3 }},
235
- filter : "_name=='hahaha'" ,
236
- from : 0 , to : 1532940510 + 1 ,
257
+ labels : utils .FromStrings ("os" , "linux" , "iguaz" , "yesplease" ),
258
+ data : []tsdbtest.DataPoint {{Time : 1532940510 , Value : 33.3 }},
259
+ filter : "_name=='hahaha'" ,
260
+ from : 0 ,
261
+ to : 1532940510 + 1 ,
262
+ step : defaultStepMs ,
237
263
expected : map [string ][]tsdbtest.DataPoint {}},
238
264
}
239
265
0 commit comments