11#! /usr/bin/env tarantool
22
3- os = require (' os' )
3+ local os = require (' os' )
4+ local fun = require (' fun' )
5+ local log = require (' log' )
6+ local json = require (' json' )
7+
48require (' console' ).listen (os.getenv (' ADMIN_PORT' ))
59box .cfg {
610 listen = os.getenv (' PRIMARY_PORT' ),
@@ -9,54 +13,67 @@ box.cfg{
913 slab_alloc_arena = 0.2
1014}
1115
12- lp = {
13- test = ' test' ,
14- test_empty = ' ' ,
15- test_big = ' 123456789012345678901234567890123456789012345678901234567890' -- '1234567890' * 6
16- }
17-
18- for k , v in pairs (lp ) do
19- if # box .space ._user .index .name :select {k } == 0 then
20- box .schema .user .create (k , { password = v })
21- end
22- end
23-
24- box .schema .user .grant (' test' , ' read,write,execute' , ' universe' , nil , {if_not_exists = true })
25-
26- if not box .space .test then
27- local test = box .schema .space .create (' test' )
28- test :create_index (' primary' , {type = ' TREE' , unique = true , parts = {1 , ' NUM' }})
29- test :create_index (' secondary' , {type = ' TREE' , unique = false , parts = {2 , ' NUM' , 3 , ' STR' }})
30- end
16+ box .once (' init' , function ()
17+ box .schema .user .create (' test' , { password = ' test' })
18+ box .schema .user .create (' test_empty' , { password = ' ' })
19+ box .schema .user .create (' test_big' , {
20+ password = ' 123456789012345678901234567890123456789012345678901234567890'
21+ })
22+ box .schema .user .grant (' test' , ' read,write,execute' , ' universe' )
3123
32- if not box .space .msgpack then
33- local msgpack = box .schema .space .create (' msgpack' )
34- msgpack :create_index (' primary' , {parts = {1 , ' NUM' }})
35- box .schema .user .grant (' test' , ' read,write' , ' space' , ' msgpack' )
36- msgpack :insert {1 , ' float as key' , {[2.7 ] = {1 , 2 , 3 }}}
37- msgpack :insert {2 , ' array as key' , {[{2 , 7 }] = {1 , 2 , 3 }}}
38- msgpack :insert {3 , ' array with float key as key' , {[{[2.7 ] = 3 , [7 ] = 7 }] = {1 , 2 , 3 }}}
39- msgpack :insert {6 , ' array with string key as key' , {[' megusta' ] = {1 , 2 , 3 }}}
40- end
24+ local space = box .schema .space .create (' test' )
25+ space :create_index (' primary' , {
26+ type = ' TREE' ,
27+ unique = true ,
28+ parts = {1 , ' NUM' }
29+ })
30+ space :create_index (' secondary' , {
31+ type = ' TREE' ,
32+ unique = false ,
33+ parts = {2 , ' NUM' , 3 , ' STR' }
34+ })
35+ local space = box .schema .space .create (' msgpack' )
36+ space :create_index (' primary' , {
37+ parts = {1 , ' NUM' }
38+ })
39+ space :insert {1 , ' float as key' , {
40+ [2.7 ] = {1 , 2 , 3 }
41+ }}
42+ space :insert {2 , ' array as key' , {
43+ [{2 , 7 }] = {1 , 2 , 3 }
44+ }}
45+ space :insert {3 , ' array with float key as key' , {
46+ [{
47+ [2.7 ] = 3 ,
48+ [7 ] = 7
49+ }] = {1 , 2 , 3 }
50+ }}
51+ space :insert {6 , ' array with string key as key' , {
52+ [' megusta' ] = {1 , 2 , 3 }
53+ }}
54+ end )
4155
4256function test_1 ()
4357 return true , {
44- c = {
45- [' 106' ]= {1 , 1428578535 },
46- [' 2' ]= {1 , 1428578535 }
58+ c = {
59+ [' 106' ] = {1 , 1428578535 },
60+ [' 2' ] = {1 , 1428578535 }
4761 },
48- pc = {
49- [' 106' ]= {1 , 1428578535 , 9243 },
50- [' 2' ]= {1 , 1428578535 , 9243 }
62+ pc = {
63+ [' 106' ] = {1 , 1428578535 , 9243 },
64+ [' 2' ] = {1 , 1428578535 , 9243 }
5165 },
52- s = {1 , 1428578535 },
53- u = 1428578535 ,
54- v = {}
66+ s = {1 , 1428578535 },
67+ u = 1428578535 ,
68+ v = {}
5569 }, true
5670end
5771
5872function test_2 ()
59- return { k2 = ' v' , k1 = ' v2' }
73+ return {
74+ k2 = ' v' ,
75+ k1 = ' v2'
76+ }
6077end
6178
6279function test_3 (x , y )
6582
6683function test_4 (...)
6784 local args = {... }
68- require ( ' log' ) .info (' %s' , require ( ' yaml ' ) .encode (args ))
85+ log .info (' %s' , json .encode (args ))
6986 return 2
7087end
88+
89+ function test_5 (count )
90+ log .info (' duplicating %d arrays' , count )
91+ local rv = fun .duplicate {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }:take (count ):totable ()
92+ log .info (' %s' , json .encode (rv ))
93+ return rv
94+ end
95+
96+ function test_6 (...)
97+ return ...
98+ end
0 commit comments