Skip to content

Commit b26c0a1

Browse files
committed
Tarantool startup fix.
1 parent b752d73 commit b26c0a1

File tree

5 files changed

+131
-120
lines changed

5 files changed

+131
-120
lines changed

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ WORKDIR /app
44

55
# copy csproj and restore as distinct layers
66
COPY . .
7-
RUN dotnet --version
8-
RUN dotnet restore
9-
RUN dotnet build -c Release -f netstandard1.4 src/progaudi.tarantool/progaudi.tarantool.csproj
10-
RUN dotnet build -c Release -f netcoreapp1.0 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj
11-
RUN dotnet build -c Release -f netcoreapp1.1 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj
7+
RUN /root/.dotnet/dotnet restore
8+
RUN /root/.dotnet/dotnet build -c Release -f netstandard1.4 src/progaudi.tarantool/progaudi.tarantool.csproj
9+
RUN /root/.dotnet/dotnet build -c Release -f netcoreapp1.0 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj
10+
RUN /root/.dotnet/dotnet build -c Release -f netcoreapp1.1 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: '2'
33
services:
44
tarantool:
55
image: tarantool/tarantool:1.7
6-
command: tarantool /usr/local/share/tarantool/tarantool.lua
6+
command: tarantool /usr/local/share/tarantool/tarantool.docker.lua
77
volumes:
88
- $PWD/tarantool:/usr/local/share/tarantool
99
ports:

tarantool/tarantool.docker.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
box.cfg
2+
{
3+
pid_file = nil,
4+
background = false,
5+
log_level = 5,
6+
listen = 3301
7+
}
8+
require('testdata')

tarantool/tarantool.lua

Lines changed: 5 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,10 @@
11
box.cfg
22
{
3-
pid_file = nil,
4-
background = false,
3+
pid_file = 'tarantool.pid',
4+
background = true,
55
log_level = 5,
6-
listen = 3301
6+
listen = 3301,
7+
log = 'file: tarantool.log'
78
}
8-
local function create_spaces_and_indecies()
9-
space1 = box.schema.space.create('primary_only_index', { if_not_exists = true })
10-
space1:create_index('primary', {type='hash', parts={1, 'unsigned'}, if_not_exists = true})
119

12-
performanceSpace = box.schema.space.create('performance', { if_not_exists = true })
13-
performanceSpace:create_index('primary', {type='hash', parts={1, 'unsigned'}, if_not_exists = true})
14-
15-
space2 = box.schema.space.create('primary_and_secondary_index', { if_not_exists = true })
16-
space2:create_index('hashIndex', {type='hash', parts={1, 'unsigned'}, if_not_exists = true })
17-
space2:create_index('treeIndex', {type='tree', parts={1, 'unsigned'}, if_not_exists = true })
18-
19-
space3 = box.schema.space.create('with_scalar_index', { if_not_exists = true })
20-
space3:create_index('primary', {type='tree', parts={1, 'scalar'}, if_not_exists = true})
21-
end
22-
23-
local function init()
24-
create_spaces_and_indecies()
25-
26-
box.schema.user.create('notSetPassword', { if_not_exists = true })
27-
box.schema.user.create('emptyPassword', { password = '', if_not_exists = true })
28-
29-
box.schema.user.create('operator', {password = 'operator', if_not_exists = true })
30-
box.schema.user.grant('operator','read,write,execute','universe', { if_not_exists = true })
31-
box.schema.user.grant('guest','read,write,execute','universe', { if_not_exists = true })
32-
box.schema.user.passwd('admin', 'adminPassword')
33-
end
34-
35-
local function space_TreeIndexMethods()
36-
space = box.schema.space.create('space_TreeIndexMethods', { if_not_exists = true })
37-
space:create_index('treeIndex', {type='tree', parts={1, 'unsigned'}, if_not_exists = true })
38-
39-
space:auto_increment{'asdf', 10.1}
40-
space:auto_increment{'zcxv'}
41-
space:auto_increment{2, 3}
42-
end
43-
44-
box.once('init', init)
45-
box.once('space_TreeIndexMethods', space_TreeIndexMethods)
46-
47-
local log = require('log')
48-
49-
function log_connect ()
50-
local m = 'Connection. user=' .. box.session.user() .. ' id=' .. box.session.id()
51-
log.info(m)
52-
end
53-
function log_disconnect ()
54-
local m = 'Disconnection. user=' .. box.session.user() .. ' id=' .. box.session.id()
55-
log.info(m)
56-
end
57-
58-
function log_auth ()
59-
local m = 'Authentication attempt'
60-
log.info(m)
61-
end
62-
function log_auth_ok (user_name)
63-
local m = 'Authenticated user ' .. user_name
64-
log.info(m)
65-
end
66-
67-
box.session.on_connect(log_connect)
68-
box.session.on_disconnect(log_disconnect)
69-
box.session.on_auth(log_auth)
70-
box.session.on_auth(log_auth_ok)
71-
72-
function return_null()
73-
log.info('return_null called')
74-
return require('msgpack').NULL
75-
end
76-
77-
function return_tuple_with_null()
78-
log.info('return_tuple_with_null called')
79-
return { require('msgpack').NULL }
80-
end
81-
82-
function return_tuple()
83-
log.info('return_tuple called')
84-
return { 1, 2 }
85-
end
86-
87-
88-
function return_array()
89-
log.info('return_array called')
90-
return {{ "abc", "def" }}
91-
end
92-
93-
function return_scalar()
94-
log.info('return_scalar called')
95-
return 1
96-
end
97-
98-
function return_nothing()
99-
log.info('return_nothing called')
100-
end
101-
102-
local truncate_space = function(name)
103-
local space = box.space[name]
104-
105-
if space then
106-
log.info("Truncating space %s...", name)
107-
space:truncate()
108-
log.info("Space %s trancated.", name)
109-
else
110-
log.warning("There is no space %s", name)
111-
end
112-
end
113-
114-
function clear_data(spaceNames)
115-
log.info('clearing data...')
116-
for _, spaceName in ipairs(spaceNames) do
117-
truncate_space(spaceName)
118-
end
119-
end
10+
require('tarantool.testdata')

tarantool/testdata.lua

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
2+
local function create_spaces_and_indecies()
3+
space1 = box.schema.space.create('primary_only_index', { if_not_exists = true })
4+
space1:create_index('primary', {type='hash', parts={1, 'unsigned'}, if_not_exists = true})
5+
6+
performanceSpace = box.schema.space.create('performance', { if_not_exists = true })
7+
performanceSpace:create_index('primary', {type='hash', parts={1, 'unsigned'}, if_not_exists = true})
8+
9+
space2 = box.schema.space.create('primary_and_secondary_index', { if_not_exists = true })
10+
space2:create_index('hashIndex', {type='hash', parts={1, 'unsigned'}, if_not_exists = true })
11+
space2:create_index('treeIndex', {type='tree', parts={1, 'unsigned'}, if_not_exists = true })
12+
13+
space3 = box.schema.space.create('with_scalar_index', { if_not_exists = true })
14+
space3:create_index('primary', {type='tree', parts={1, 'scalar'}, if_not_exists = true})
15+
end
16+
17+
local function init()
18+
create_spaces_and_indecies()
19+
20+
box.schema.user.create('notSetPassword', { if_not_exists = true })
21+
box.schema.user.create('emptyPassword', { password = '', if_not_exists = true })
22+
23+
box.schema.user.create('operator', {password = 'operator', if_not_exists = true })
24+
box.schema.user.grant('operator','read,write,execute','universe', { if_not_exists = true })
25+
box.schema.user.grant('guest','read,write,execute','universe', { if_not_exists = true })
26+
box.schema.user.passwd('admin', 'adminPassword')
27+
end
28+
29+
local function space_TreeIndexMethods()
30+
space = box.schema.space.create('space_TreeIndexMethods', { if_not_exists = true })
31+
space:create_index('treeIndex', {type='tree', parts={1, 'unsigned'}, if_not_exists = true })
32+
33+
space:auto_increment{'asdf', 10.1}
34+
space:auto_increment{'zcxv'}
35+
space:auto_increment{2, 3}
36+
end
37+
38+
box.once('init', init)
39+
box.once('space_TreeIndexMethods', space_TreeIndexMethods)
40+
41+
local log = require('log')
42+
43+
function log_connect ()
44+
local m = 'Connection. user=' .. box.session.user() .. ' id=' .. box.session.id()
45+
log.info(m)
46+
end
47+
function log_disconnect ()
48+
local m = 'Disconnection. user=' .. box.session.user() .. ' id=' .. box.session.id()
49+
log.info(m)
50+
end
51+
52+
function log_auth ()
53+
local m = 'Authentication attempt'
54+
log.info(m)
55+
end
56+
function log_auth_ok (user_name)
57+
local m = 'Authenticated user ' .. user_name
58+
log.info(m)
59+
end
60+
61+
box.session.on_connect(log_connect)
62+
box.session.on_disconnect(log_disconnect)
63+
box.session.on_auth(log_auth)
64+
box.session.on_auth(log_auth_ok)
65+
66+
function return_null()
67+
log.info('return_null called')
68+
return require('msgpack').NULL
69+
end
70+
71+
function return_tuple_with_null()
72+
log.info('return_tuple_with_null called')
73+
return { require('msgpack').NULL }
74+
end
75+
76+
function return_tuple()
77+
log.info('return_tuple called')
78+
return { 1, 2 }
79+
end
80+
81+
82+
function return_array()
83+
log.info('return_array called')
84+
return {{ "abc", "def" }}
85+
end
86+
87+
function return_scalar()
88+
log.info('return_scalar called')
89+
return 1
90+
end
91+
92+
function return_nothing()
93+
log.info('return_nothing called')
94+
end
95+
96+
local truncate_space = function(name)
97+
local space = box.space[name]
98+
99+
if space then
100+
log.info("Truncating space %s...", name)
101+
space:truncate()
102+
log.info("Space %s trancated.", name)
103+
else
104+
log.warning("There is no space %s", name)
105+
end
106+
end
107+
108+
function clear_data(spaceNames)
109+
log.info('clearing data...')
110+
for _, spaceName in ipairs(spaceNames) do
111+
truncate_space(spaceName)
112+
end
113+
end

0 commit comments

Comments
 (0)