1
1
#! /usr/bin/env tarantool
2
2
3
- local crud = require (' crud' )
4
- local vshard = require (' vshard' )
3
+ local function configure_crud_instance (primary_listen , crud , vshard )
4
+ box .schema .create_space (
5
+ ' tester' , {
6
+ format = {
7
+ {name = ' id' , type = ' unsigned' },
8
+ {name = ' bucket_id' , type = ' unsigned' },
9
+ {name = ' name' , type = ' string' },
10
+ }
11
+ })
12
+ box .space .tester :create_index (' primary_index' , {
13
+ parts = {
14
+ {field = 1 , type = ' unsigned' },
15
+ },
16
+ })
17
+ box .space .tester :create_index (' bucket_id' , {
18
+ parts = {
19
+ {field = 2 , type = ' unsigned' },
20
+ },
21
+ unique = false ,
22
+ })
23
+
24
+ -- Setup vshard.
25
+ _G .vshard = vshard
26
+ box .once (' guest' , function ()
27
+ box .schema .user .grant (' guest' , ' super' )
28
+ end )
29
+ local uri = ' [email protected] :' .. primary_listen
30
+ local cfg = {
31
+ bucket_count = 300 ,
32
+ sharding = {
33
+ [box .info ().cluster .uuid ] = {
34
+ replicas = {
35
+ [box .info ().uuid ] = {
36
+ uri = uri ,
37
+ name = ' storage' ,
38
+ master = true ,
39
+ },
40
+ },
41
+ },
42
+ },
43
+ }
44
+ vshard .storage .cfg (cfg , box .info ().uuid )
45
+ vshard .router .cfg (cfg )
46
+ vshard .router .bootstrap ()
47
+
48
+ -- Initialize crud.
49
+ crud .init_storage ()
50
+ crud .init_router ()
51
+ crud .cfg {stats = true }
52
+ end
53
+
54
+ local crud_imported , crud = pcall (require , ' crud' )
55
+ local vshard_imported , vshard = pcall (require , ' vshard' )
5
56
6
57
local admin_listen = os.getenv (" ADMIN" )
7
58
local primary_listen = os.getenv (" LISTEN" )
@@ -18,51 +69,17 @@ box.schema.user.grant(
18
69
' read,write,execute' ,
19
70
' universe'
20
71
)
21
- box .schema .create_space (
22
- ' tester' , {
23
- format = {
24
- {name = ' id' , type = ' unsigned' },
25
- {name = ' bucket_id' , type = ' unsigned' },
26
- {name = ' name' , type = ' string' },
27
- }
28
- })
29
- box .space .tester :create_index (' primary_index' , {
30
- parts = {
31
- {field = 1 , type = ' unsigned' },
32
- },
33
- })
34
- box .space .tester :create_index (' bucket_id' , {
35
- parts = {
36
- {field = 2 , type = ' unsigned' },
37
- },
38
- unique = false ,
39
- })
40
-
41
- -- Setup vshard.
42
- _G .vshard = vshard
43
- box .once (' guest' , function ()
44
- box .schema .user .grant (' guest' , ' super' )
45
- end )
46
- local uri = ' [email protected] :' .. primary_listen
47
- local cfg = {
48
- bucket_count = 300 ,
49
- sharding = {
50
- [box .info ().cluster .uuid ] = {
51
- replicas = {
52
- [box .info ().uuid ] = {
53
- uri = uri ,
54
- name = ' storage' ,
55
- master = true ,
56
- },
57
- },
58
- },
59
- },
60
- }
61
- vshard .storage .cfg (cfg , box .info ().uuid )
62
- vshard .router .cfg (cfg )
63
- vshard .router .bootstrap ()
64
72
65
- -- Initialize crud.
66
- crud .init_storage ()
67
- crud .init_router ()
68
- crud .cfg {stats = true }
73
+ if crud_imported == false or vshard_imported == false then
74
+ -- Set flag for unittest.
75
+ _G [' ROCKS_IMPORT_FAIL' ] = true
76
+ local fail_msg = ' The crud/vshard modules are not detected, ' ..
77
+ ' installation via rocks install is required ' ..
78
+ ' for CRUD testing purposes. You can use ' ..
79
+ ' <tarantoolctl rocks install crud> or ' ..
80
+ ' <tt rocks install crud> to install modules'
81
+ -- The print output will be captured in the logs.
82
+ print (fail_msg )
83
+ else
84
+ configure_crud_instance (primary_listen , crud , vshard )
85
+ end
0 commit comments