36
36
-include_lib (" eunit/include/eunit.hrl" ).
37
37
-include (" ts_qbuf_util.hrl" ).
38
38
39
+ -define (TABLE_A , " table_with_regular_keys" ).
40
+ -define (TABLE_D , " table_with_descending_keys" ).
39
41
40
42
suite () ->
41
43
[{timetrap , {minutes , 5 }}].
@@ -44,8 +46,10 @@ init_per_suite(Cfg) ->
44
46
Cluster = ts_setup :start_cluster (1 ),
45
47
C = rt :pbc (hd (Cluster )),
46
48
Data = make_data (),
47
- ok = create_table (C , ? TABLE ),
48
- ok = insert_data (C , ? TABLE , Data ),
49
+ ok = create_table (C , ? TABLE_A ),
50
+ ok = create_table_desc (C , ? TABLE_D ),
51
+ ok = insert_data (C , ? TABLE_A , Data ),
52
+ ok = insert_data (C , ? TABLE_D , Data ),
49
53
[{cluster , Cluster },
50
54
{data , Data } | Cfg ].
51
55
@@ -185,7 +189,7 @@ query_invdist_mode(Cfg) ->
185
189
query_invdist_errors (Cfg ) ->
186
190
lists :foreach (
187
191
fun ({Select , Extra , ErrPat }) ->
188
- Qry = make_query (Select , Extra ),
192
+ Qry = make_query (? TABLE_A , Select , Extra ),
189
193
? assertEqual (
190
194
ok ,
191
195
ts_qbuf_util :ack_query_error (Cfg , Qry , ? E_SUBMIT , ErrPat ))
@@ -289,6 +293,18 @@ create table " ++ Table ++ "
289
293
{ok , {[], []}} = riakc_ts :query (Client , DDL ),
290
294
ok .
291
295
296
+ create_table_desc (Client , Table ) ->
297
+ DDL = "
298
+ create table " ++ Table ++ "
299
+ (a timestamp not null,
300
+ b double,
301
+ c sint64,
302
+ d sint64,
303
+ e sint64,
304
+ primary key ((quantum(a, 10, h)), a desc))" ,
305
+ {ok , {[], []}} = riakc_ts :query (Client , DDL ),
306
+ ok .
307
+
292
308
data_generator (I ) ->
293
309
{? TIMEBASE + (I + 1 ) * 1000 ,
294
310
100 * math :cos (float (I ) / 10 * math :pi ()),
@@ -313,10 +329,12 @@ insert_data(C, Table, Data) ->
313
329
end .
314
330
315
331
make_query (Select ) ->
316
- make_query (Select , " " ).
317
- make_query (Select , Extra ) ->
332
+ make_query (? TABLE_A , Select , " " ).
333
+ make_query (Table , Select ) ->
334
+ make_query (Table , Select , " " ).
335
+ make_query (Table , Select , Extra ) ->
318
336
fmt (" select ~s from ~s where a >= ~b and a <= ~b~s " ,
319
- [Select , ? TABLE ,
337
+ [Select , Table ,
320
338
? TIMEBASE , ? TIMEBASE * 1000 ,
321
339
[" " ++ Extra || Extra /= []]]).
322
340
@@ -334,19 +352,23 @@ check_column(C, Col, Data) ->
334
352
{0.36 , " (3.6/10)" },
335
353
{0.40 , " 0.5 - 1 * 0.1" }],
336
354
PercentileVariety <- [percentile_cont , percentile_disc ]],
355
+ Checker =
356
+ fun (Q , Need ) ->
357
+ ct :log (" Query \" ~s \" " , [Q ]),
358
+ {ok , {_Cols , [{Got }]}} =
359
+ riakc_ts :query (C , Q , [], undefined , []),
360
+ case Got == Need of
361
+ true ->
362
+ ok ;
363
+ false ->
364
+ ct :fail (" Got ~p , Need ~p \n " , [Got , Need ])
365
+ end
366
+ end ,
337
367
ok == lists :foreach (
338
368
fun ({PercentileFun , Pc , Pc_s }) ->
339
- Query = make_query (fmt (" ~s (~s , ~s )" , [PercentileFun , Col , Pc_s ])),
340
- ct :log (" Query \" ~s \" " , [Query ]),
341
- {ok , {_Cols , [{Got }]}} =
342
- riakc_ts :query (C , Query , [], undefined , []),
343
369
Need = apply (? MODULE , PercentileFun , [Col , Pc , SortedData ]),
344
- case Got == Need of
345
- true ->
346
- ok ;
347
- false ->
348
- ct :fail (" Got ~p , Need ~p \n " , [Got , Need ])
349
- end
370
+ ok = Checker (make_query (? TABLE_A , fmt (" ~s (~s , ~s )" , [PercentileFun , Col , Pc_s ])), Need ),
371
+ ok = Checker (make_query (? TABLE_D , fmt (" ~s (~s , ~s )" , [PercentileFun , Col , Pc_s ])), Need )
350
372
end ,
351
373
Combos ).
352
374
@@ -370,7 +392,7 @@ load_intercept(Node, C, Intercept) ->
370
392
wait_until_qbuf_mgr_reinit (C ).
371
393
372
394
wait_until_qbuf_mgr_reinit (C ) ->
373
- ProbingQuery = make_query (" *" , " " ),
395
+ ProbingQuery = make_query (" *" ),
374
396
case riakc_ts :query (C , ProbingQuery , [], undefined , []) of
375
397
{ok , _Data } ->
376
398
ok ;
0 commit comments