mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-14 06:51:56 +00:00
100 lines
5.4 KiB
YAML
100 lines
5.4 KiB
YAML
desc: Tests key sorting of all usable types in secondary indexes
|
|
table_variable_name: tbl
|
|
tests:
|
|
|
|
|
|
# Test key sorting
|
|
- def:
|
|
py: binary_a = r.binary(b'')
|
|
rb: binary_a = r.binary('')
|
|
js: binary_a = Buffer('')
|
|
|
|
- def:
|
|
py: binary_trunc1 = r.binary(b'123456789012345678901234567890123456789012345678901234567890' +
|
|
b'123456789012345678901234567890123456789012345678901234567890')
|
|
rb: binary_trunc1 = r.binary('123456789012345678901234567890123456789012345678901234567890' +
|
|
'123456789012345678901234567890123456789012345678901234567890')
|
|
js: binary_trunc1 = Buffer('123456789012345678901234567890123456789012345678901234567890' +
|
|
'123456789012345678901234567890123456789012345678901234567890')
|
|
|
|
- def:
|
|
py: binary_trunc2 = r.binary(b'123456789012345678901234567890123456789012345678901234567890' +
|
|
b'123456789012345678901234567890123456789012345678901234567891')
|
|
rb: binary_trunc2 = r.binary('123456789012345678901234567890123456789012345678901234567890' +
|
|
'123456789012345678901234567890123456789012345678901234567891')
|
|
js: binary_trunc2 = Buffer('123456789012345678901234567890123456789012345678901234567890' +
|
|
'123456789012345678901234567890123456789012345678901234567891')
|
|
|
|
- def:
|
|
py: binary_b = r.binary(b'5aurhbviunr')
|
|
rb: binary_b = r.binary('5aurhbviunr')
|
|
js: binary_b = Buffer('5aurhbviunr')
|
|
|
|
- def: str_trunc1 = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'
|
|
- def: str_trunc2 = '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891'
|
|
|
|
# Define a set of rows in order of increasing sindex keys
|
|
- def: trows = [ {'id':0,'idx':[0]},
|
|
{'id':1,'idx':[1, 2, 3, 4, 5, 6, 7, 0]},
|
|
{'id':2,'idx':[1, 2, 3, 4, 5, 6, 7, 4]},
|
|
{'id':3,'idx':[1, 2, 3, 4, 5, 6, 7, 4, 5]},
|
|
{'id':4,'idx':[1, 2, 3, 4, 5, 6, 7, 8, 1]},
|
|
{'id':5,'idx':[1, 3, binary_trunc1]},
|
|
{'id':6,'idx':[1, 3, binary_trunc2]},
|
|
{'id':7,'idx':[1, 3, r.epoch_time(0), r.epoch_time(0), r.epoch_time(0)]},
|
|
{'id':8,'idx':[1, 3, r.epoch_time(0), r.epoch_time(0), r.epoch_time(0), r.epoch_time(0)]},
|
|
{'id':9,'idx':[1, 3, r.epoch_time(0), r.epoch_time(0), r.epoch_time(0), r.epoch_time(1)]},
|
|
{'id':10,'idx':[1, 3, str_trunc1, str_trunc1]},
|
|
{'id':11,'idx':[1, 3, str_trunc1, str_trunc2]},
|
|
{'id':12,'idx':[1, 4, 3, 4, 5, 6, 7, 8, 2]},
|
|
{'id':13,'idx':[binary_trunc1]},
|
|
{'id':14,'idx':[binary_trunc2]},
|
|
{'id':15,'idx':False},
|
|
{'id':16,'idx':True},
|
|
{'id':17,'idx':-500},
|
|
{'id':18,'idx':500},
|
|
{'id':19,'idx':binary_a},
|
|
{'id':20,'idx':binary_trunc1},
|
|
{'id':21,'idx':binary_trunc2},
|
|
{'id':22,'idx':binary_b},
|
|
{'id':23,'idx':r.epoch_time(0)},
|
|
{'id':24,'idx':''},
|
|
{'id':25,'idx':' str'},
|
|
{'id':26,'idx':str_trunc1},
|
|
{'id':27,'idx':str_trunc2}]
|
|
|
|
- def:
|
|
cd: expected = r.range(tbl.count()).coerce_to('array')
|
|
|
|
- cd: tbl.insert(trows)['inserted']
|
|
js: tbl.insert(trows)('inserted')
|
|
ot: 28
|
|
|
|
- cd: tbl.index_create('idx')
|
|
ot: ({'created':1})
|
|
|
|
- cd: tbl.index_wait('idx').pluck('index', 'ready')
|
|
ot: [{'index':'idx','ready':true}]
|
|
|
|
- rb: tbl.order_by({:index => 'idx'}).map{|row| row['id']}.coerce_to('array').eq(expected)
|
|
js: tbl.order_by({index:'idx'}).map(r.row('id')).coerce_to('array').eq(expected)
|
|
py: tbl.order_by(index='idx').map(r.row['id']).coerce_to('array').eq(expected)
|
|
ot: true
|
|
|
|
# Test minval and maxval
|
|
- rb: tbl.order_by(:index => 'idx').between(r.minval, r.maxval).map{|x| x['id']}.coerce_to('array').eq(expected)
|
|
js: tbl.order_by({index:'idx'}).between(r.minval, r.maxval).map(r.row('id')).coerce_to('array').eq(expected)
|
|
py: tbl.order_by(index='idx').between(r.minval, r.maxval).map(r.row['id']).coerce_to('array').eq(expected)
|
|
ot: true
|
|
|
|
- py: tbl.order_by(index='idx').between([1,2,3,4,5,6,7,4],[1,2,3,4,5,6,8]).map(r.row['id']).coerce_to('array')
|
|
js: tbl.order_by({index:'idx'}).between([1,2,3,4,5,6,7,4],[1,2,3,4,5,6,8]).map(r.row('id')).coerce_to('array')
|
|
rb: tbl.order_by(:index => 'idx').between([1,2,3,4,5,6,7,4],[1,2,3,4,5,6,8]).map{|x| x['id']}.coerce_to('array')
|
|
ot: [2,3,4]
|
|
|
|
- py: tbl.order_by(index='idx').between([1,2,3,4,5,6,7,4,r.minval],[1,2,3,4,5,6,7,4,r.maxval]).map(r.row['id']).coerce_to('array')
|
|
js: tbl.order_by({index:'idx'}).between([1,2,3,4,5,6,7,4,r.minval],[1,2,3,4,5,6,7,4,r.maxval]).map(r.row('id')).coerce_to('array')
|
|
rb: tbl.order_by(:index => 'idx').between([1,2,3,4,5,6,7,4,r.minval],[1,2,3,4,5,6,7,4,r.maxval]).map{|x| x['id']}.coerce_to('array')
|
|
ot: [3]
|
|
|