File: upgrade.test.lua

package info (click to toggle)
tarantool 2.6.0-1.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 85,396 kB
  • sloc: ansic: 513,775; cpp: 69,493; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,176; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (74 lines) | stat: -rw-r--r-- 2,206 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
test_run = require('test_run').new()
engine = test_run:get_cfg('engine')
_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}})

work_dir = 'sql/upgrade/1.10/'
test_run:cmd('create server upgrade with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"')
test_run:cmd('start server upgrade')

test_run:switch('upgrade')

-- test system tables
box.space._space.index['name']:get('_trigger')

box.space._index:get({box.space._space.index['name']:get('_trigger').id, 0})

box.space._schema:format()

-- test data migration
box.space._space.index['name']:get('T1')
box.space._index:get({box.space._space.index['name']:get('T1').id, 0})

-- test system tables functionality
box.execute("CREATE TABLE t(x INTEGER PRIMARY KEY);")
box.execute("CREATE TABLE t_out(x INTEGER PRIMARY KEY);")
box.execute("CREATE TRIGGER t1t AFTER INSERT ON t FOR EACH ROW BEGIN INSERT INTO t_out VALUES(1); END;")
box.execute("CREATE TRIGGER t2t AFTER INSERT ON t FOR EACH ROW BEGIN INSERT INTO t_out VALUES(2); END;")
box.space._space.index['name']:get('T')
box.space._space.index['name']:get('T_OUT')
t1t = box.space._trigger:get('T1T')
t2t = box.space._trigger:get('T2T')
t1t.name
t1t.opts
t2t.name
t2t.opts
assert(t1t.space_id == t2t.space_id)
assert(t1t.space_id == box.space.T.id)

box.execute("INSERT INTO T VALUES(1);")
box.space.T:select()
box.space.T_OUT:select()
box.execute("SELECT * FROM T")
box.execute("SELECT * FROM T")


box.execute("DROP TABLE T;")
box.execute("DROP TABLE T_OUT;")


test_run:switch('default')
test_run:cmd('stop server upgrade')
test_run:cmd('cleanup server upgrade')

-- Test Tarantool 2.1.0 to 2.1.1 migration.
work_dir = 'sql/upgrade/2.1.0/'
test_run:cmd('create server upgrade210 with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"')
test_run:cmd('start server upgrade210')

test_run:switch('upgrade210')

s = box.space.T5
s ~= nil
i = box.space._index:select(s.id)
i ~= nil
i[1].opts.sql == nil
box.space._space:get(s.id).flags.checks == nil
check = box.space._ck_constraint:select()[1]
check ~= nil
check.name
check.code
s:drop()

test_run:switch('default')
test_run:cmd('stop server upgrade210')
test_run:cmd('cleanup server upgrade210')