Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH 1/1] Deal with upgrade mess in 2.0
@ 2018-06-08 19:45 Vladislav Shpilevoy
  0 siblings, 0 replies; only message in thread
From: Vladislav Shpilevoy @ 2018-06-08 19:45 UTC (permalink / raw)
  To: tarantool-patches; +Cc: kostja

Before the patch several problems had been existing:

* Tarantool < 1.9 emerged to be unable to upgrade to 2.0 because
  of privileges problems;
* Vinyl/upgrade and xlog/upgrade store 1.8 snapshots in 1.7.7
  directories;
* Upgrade from >= 1.9 to 2.0 skips 1.8 since version(1.8)
  actually < version(1.9/1.10), but formally 1.8 is newer. The
  mess was introduced by new versioning policy. And because of it
  system space _trigger was skipped.

The patch makes only possible decision: forbid to upgrade to 2.0
from Tarantool < 1.9, and zap 1.8 version. SQL initialization now
is transferred into upgrade_to_2_1_0.
---
Branch: https://github.com/tarantool/tarantool/tree/gerold103/upgrade-2.1.0-mess

 src/box/bootstrap.snap                             | Bin 1698 -> 1698 bytes
 src/box/lua/upgrade.lua                            | 268 ++++++++-------------
 test/sql/upgrade.result                            | 123 ++++++++++
 test/sql/upgrade.test.lua                          |  45 ++++
 test/sql/upgrade/1.10/00000000000000000003.snap    | Bin 0 -> 1568 bytes
 test/sql/upgrade/upgrade.lua                       |   7 +
 test/vinyl/suite.cfg                               |   3 -
 test/vinyl/suite.ini                               |   1 +
 .../vinyl/upgrade/1.7.7/00000000000000000000.vylog | Bin 1384 -> 0 bytes
 test/vinyl/upgrade/1.7.7/00000000000000000010.snap | Bin 1669 -> 0 bytes
 .../vinyl/upgrade/1.7.7/00000000000000000010.vylog | Bin 3771 -> 0 bytes
 test/vinyl/upgrade/1.7.7/00000000000000000010.xlog | Bin 3461 -> 0 bytes
 .../upgrade/1.7.7/513/0/00000000000000000011.index | Bin 191 -> 0 bytes
 .../upgrade/1.7.7/513/0/00000000000000000011.run   | Bin 156 -> 0 bytes
 .../upgrade/1.7.7/513/0/00000000000000000015.index | Bin 186 -> 0 bytes
 .../upgrade/1.7.7/513/0/00000000000000000015.run   | Bin 141 -> 0 bytes
 .../upgrade/1.7.7/513/1/00000000000000000017.index | Bin 234 -> 0 bytes
 .../upgrade/1.7.7/513/1/00000000000000000017.run   | Bin 171 -> 0 bytes
 .../upgrade/1.7.7/514/0/00000000000000000023.index | Bin 186 -> 0 bytes
 .../upgrade/1.7.7/514/0/00000000000000000023.run   | Bin 142 -> 0 bytes
 .../upgrade/1.7.7/514/1/00000000000000000021.index | Bin 208 -> 0 bytes
 .../upgrade/1.7.7/514/1/00000000000000000021.run   | Bin 142 -> 0 bytes
 .../upgrade/1.7.7/515/0/00000000000000000029.index | Bin 186 -> 0 bytes
 .../upgrade/1.7.7/515/0/00000000000000000029.run   | Bin 141 -> 0 bytes
 .../upgrade/1.7.7/515/0/00000000000000000037.index | Bin 186 -> 0 bytes
 .../upgrade/1.7.7/515/0/00000000000000000037.run   | Bin 143 -> 0 bytes
 .../upgrade/1.7.7/515/1/00000000000000000027.index | Bin 204 -> 0 bytes
 .../upgrade/1.7.7/515/1/00000000000000000027.run   | Bin 141 -> 0 bytes
 .../upgrade/1.7.7/515/1/00000000000000000034.index | Bin 204 -> 0 bytes
 .../upgrade/1.7.7/515/1/00000000000000000034.run   | Bin 143 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000035.index | Bin 242 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000035.run   | Bin 420 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000040.index | Bin 242 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000040.run   | Bin 420 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000042.index | Bin 242 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000042.run   | Bin 420 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000043.index | Bin 242 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000043.run   | Bin 420 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000052.index | Bin 209 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000052.run   | Bin 220 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000053.index | Bin 242 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000053.run   | Bin 420 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000057.index | Bin 223 -> 0 bytes
 .../upgrade/1.7.7/516/0/00000000000000000057.run   | Bin 300 -> 0 bytes
 test/xlog/suite.ini                                |   2 +-
 test/xlog/upgrade/1.7.7/00000000000000000000.snap  | Bin 1528 -> 0 bytes
 test/xlog/upgrade/1.7.7/00000000000000000000.xlog  | Bin 480 -> 0 bytes
 test/xlog/upgrade/1.7.7/00000000000000000005.xlog  | Bin 418 -> 0 bytes
 test/xlog/upgrade/1.7.7/00000000000000000010.xlog  | Bin 422 -> 0 bytes
 test/xlog/upgrade/1.7.7/00000000000000000015.xlog  | Bin 543 -> 0 bytes
 test/xlog/upgrade/1.7.7/00000000000000000020.xlog  | Bin 385 -> 0 bytes
 test/xlog/upgrade/1.7.7/00000000000000000025.xlog  | Bin 393 -> 0 bytes
 test/xlog/upgrade/1.7.7/00000000000000000030.xlog  | Bin 217 -> 0 bytes
 53 files changed, 273 insertions(+), 176 deletions(-)
diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index 8aaaf5c8b..2a2721f54 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -23,14 +23,6 @@ local function setmap(tab)
     return setmetatable(tab, { __serialize = 'map' })
 end
 
-local function ismap(tab)
-    if type(tab) ~= 'table' then
-        return false
-    end
-    local mt = getmetatable(tab)
-    return mt and (mt.__serialize == 'map' or mt.__serialize == 'mapping')
-end
-
 local mkversion = {}
 mkversion.__index = mkversion
 setmetatable(mkversion, {__call = function(c, ...) return c.new(...) end})
@@ -74,6 +66,7 @@ end
 local function set_system_triggers(val)
     box.space._space:run_triggers(val)
     box.space._index:run_triggers(val)
+    box.space._trigger:run_triggers(val)
     box.space._user:run_triggers(val)
     box.space._func:run_triggers(val)
     box.space._priv:run_triggers(val)
@@ -93,6 +86,7 @@ local function erase()
     truncate(box.space._sequence)
     truncate(box.space._truncate)
     truncate(box.space._collation)
+    truncate(box.space._trigger)
     --truncate(box.space._schema)
     box.space._schema:delete('version')
     box.space._schema:delete('max_id')
@@ -135,14 +129,7 @@ local function create_sysview(source_id, target_id)
     end
 end
 
-local function initial_1_7_5()
-    -- stick to the following convention:
-    -- prefer user id (owner id) in field #1
-    -- prefer object name in field #2
-    -- index on owner id is index #1
-    -- index on object name is index #2
-    --
-
+local function initial_1_9_0()
     local _schema = box.space[box.schema.SCHEMA_ID]
     local _space = box.space[box.schema.SPACE_ID]
     local _index = box.space[box.schema.INDEX_ID]
@@ -151,6 +138,10 @@ local function initial_1_7_5()
     local _priv = box.space[box.schema.PRIV_ID]
     local _cluster = box.space[box.schema.CLUSTER_ID]
     local _truncate = box.space[box.schema.TRUNCATE_ID]
+    local _sequence = box.space[box.schema.SEQUENCE_ID]
+    local _sequence_data = box.space[box.schema.SEQUENCE_DATA_ID]
+    local _space_sequence = box.space[box.schema.SPACE_SEQUENCE_ID]
+    local _collation = box.space[box.schema.COLLATION_ID]
     local MAP = setmap({})
 
     --
@@ -293,73 +284,17 @@ local function initial_1_7_5()
     _index:insert{_truncate.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}}}
 
     --
-    -- Create users
-    --
-    log.info("create user guest")
-    _user:insert{GUEST, ADMIN, 'guest', 'user', MAP}
-    box.schema.user.passwd('guest', '')
-    log.info("create user admin")
-    _user:insert{ADMIN, ADMIN, 'admin', 'user', MAP}
-    log.info("create role public")
-    _user:insert{PUBLIC, ADMIN, 'public', 'role', MAP}
-    log.info("create role replication")
-    _user:insert{REPLICATION, ADMIN, 'replication', 'role', MAP}
-
-    --
-    -- Create grants
+    -- _sequence
     --
-    log.info("grant read,write,execute on universe to admin")
-    _priv:insert{ADMIN, ADMIN, 'universe', 0, box.priv.R + box.priv.W + box.priv.X}
-
-    -- grant role 'public' to 'guest'
-    log.info("grant role public to guest")
-    _priv:insert{ADMIN, GUEST, 'role', PUBLIC, box.priv.X}
-
-    -- replication can read the entire universe
-    log.info("grant read on universe to replication")
-    _priv:replace{ADMIN, REPLICATION, 'universe', 0, box.priv.R}
-    -- replication can append to '_cluster' system space
-    log.info("grant write on space _cluster to replication")
-    _priv:replace{ADMIN, REPLICATION, 'space', _cluster.id, box.priv.W}
-
-    _priv:insert{ADMIN, PUBLIC, 'space', _truncate.id, box.priv.W}
-
-    -- create "box.schema.user.info" function
-    log.info('create function "box.schema.user.info" with setuid')
-    _func:replace{1, ADMIN, 'box.schema.user.info', 1, 'LUA'}
-
-    -- grant 'public' role access to 'box.schema.user.info' function
-    log.info('grant execute on function "box.schema.user.info" to public')
-    _priv:replace{ADMIN, PUBLIC, 'function', 1, box.priv.X}
-
-    log.info("set max_id to box.schema.SYSTEM_ID_MAX")
-    _schema:insert{'max_id', box.schema.SYSTEM_ID_MAX}
-
-    log.info("set schema version to 1.7.5")
-    _schema:insert({'version', 1, 7, 5})
-end
-
-local sequence_format = {{name = 'id', type = 'unsigned'},
-                         {name = 'owner', type = 'unsigned'},
-                         {name = 'name', type = 'string'},
-                         {name = 'step', type = 'integer'},
-                         {name = 'min', type = 'integer'},
-                         {name = 'max', type = 'integer'},
-                         {name = 'start', type = 'integer'},
-                         {name = 'cache', type = 'integer'},
-                         {name = 'cycle', type = 'boolean'}}
---------------------------------------------------------------------------------
--- Tarantool 1.7.6
---------------------------------------------------------------------------------
-
-local function create_sequence_space()
-    local _space = box.space[box.schema.SPACE_ID]
-    local _index = box.space[box.schema.INDEX_ID]
-    local _sequence = box.space[box.schema.SEQUENCE_ID]
-    local _sequence_data = box.space[box.schema.SEQUENCE_DATA_ID]
-    local _space_sequence = box.space[box.schema.SPACE_SEQUENCE_ID]
-    local MAP = setmap({})
-
+    local sequence_format = {{name = 'id', type = 'unsigned'},
+                             {name = 'owner', type = 'unsigned'},
+                             {name = 'name', type = 'string'},
+                             {name = 'step', type = 'integer'},
+                             {name = 'min', type = 'integer'},
+                             {name = 'max', type = 'integer'},
+                             {name = 'start', type = 'integer'},
+                             {name = 'cache', type = 'integer'},
+                             {name = 'cycle', type = 'boolean'}}
     log.info("create space _sequence")
     _space:insert{_sequence.id, ADMIN, '_sequence', 'memtx', 0, MAP, sequence_format}
     log.info("create index _sequence:primary")
@@ -384,73 +319,83 @@ local function create_sequence_space()
     _index:insert{_space_sequence.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}}}
     log.info("create index _space_sequence:sequence")
     _index:insert{_space_sequence.id, 1, 'sequence', 'tree', {unique = false}, {{1, 'unsigned'}}}
-end
-
-local function create_collation_space()
-    local _collation = box.space[box.schema.COLLATION_ID]
 
+    --
+    -- _collation
+    --
     log.info("create space _collation")
-    box.space._space:insert{_collation.id, ADMIN, '_collation', 'memtx', 0, setmap({}),
+    box.space._space:insert{_collation.id, ADMIN, '_collation', 'memtx', 0, MAP,
         { { name = 'id', type = 'unsigned' }, { name = 'name', type = 'string' },
           { name = 'owner', type = 'unsigned' }, { name = 'type', type = 'string' },
           { name = 'locale', type = 'string' }, { name = 'opts', type = 'map' } } }
 
     log.info("create index primary on _collation")
-    box.space._index:insert{_collation.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}}}
+    _index:insert{_collation.id, 0, 'primary', 'tree', {unique = true}, {{0, 'unsigned'}}}
 
     log.info("create index name on _collation")
-    box.space._index:insert{_collation.id, 1, 'name', 'tree', {unique = true}, {{1, 'string'}}}
+    _index:insert{_collation.id, 1, 'name', 'tree', {unique = true}, {{1, 'string'}}}
 
     log.info("create predefined collations")
-    box.space._collation:replace{1, "unicode", ADMIN, "ICU", "", setmap{}}
-    box.space._collation:replace{2, "unicode_ci", ADMIN, "ICU", "", {strength='primary'}}
-
-    local _priv = box.space[box.schema.PRIV_ID]
-    _priv:insert{ADMIN, PUBLIC, 'space', _collation.id, box.priv.W}
-end
-
-local function upgrade_to_1_7_6()
-    create_sequence_space()
-    create_collation_space()
-end
+    _collation:replace{1, "unicode", ADMIN, "ICU", "", MAP}
+    _collation:replace{2, "unicode_ci", ADMIN, "ICU", "", {strength='primary'}}
 
---------------------------------------------------------------------------------
---- Tarantool 1.7.7
---------------------------------------------------------------------------------
-
-local function upgrade_to_1_7_7()
-    local _priv = box.space[box.schema.PRIV_ID]
-    local _user = box.space[box.schema.USER_ID]
     --
-    -- grant 'session' and 'usage' to all existing users
+    -- Create users
     --
-    for _, v in _user:pairs() do
-        if v[4] ~= "role" then
-            _priv:upsert({ADMIN, v[1], "universe", 0, box.priv.S + box.priv.U},
-                                                {{"|", 5, box.priv.S + box.priv.U}})
-        end
-    end
+    log.info("create user guest")
+    _user:insert{GUEST, ADMIN, 'guest', 'user', MAP}
+    box.schema.user.passwd('guest', '')
+    log.info("create user admin")
+    _user:insert{ADMIN, ADMIN, 'admin', 'user', MAP}
+    log.info("create role public")
+    _user:insert{PUBLIC, ADMIN, 'public', 'role', MAP}
+    log.info("create role replication")
+    _user:insert{REPLICATION, ADMIN, 'replication', 'role', MAP}
+    log.info("create role super")
+    _user:insert{SUPER, ADMIN, 'super', 'role', MAP}
+
     --
-    -- grant 'create' to all users with 'read' and 'write'
-    -- on the universe, since going forward we will require
-    -- 'create' rather than 'read,write' to be able to create
-    -- objects
+    -- Create grants
     --
-    for _, v in _priv.index.object:pairs{'universe'} do
-        if bit.band(v[5], 1) ~= 0 and bit.band(v[5], 2) ~= 0 then
-            _priv:update({v[2], v[3], v[4]}, {{ "|", 5, box.priv.C}})
-        end
-    end
-    -- grant admin all new privileges (session, usage, grant option,
-    -- create, alter, drop and anything that might come up in the future
+    log.info("grant read,write,execute on universe to admin")
+    _priv:insert{ADMIN, ADMIN, 'universe', 0, box.priv.ALL}
+    _priv:insert{ADMIN, GUEST, 'universe', 0, box.priv.S + box.priv.U}
+
+    -- Grant role 'public' to 'guest'.
+    log.info("grant role public to guest")
+    _priv:insert{ADMIN, GUEST, 'role', 2, box.priv.X}
+
+    -- Replication can read the entire universe.
+    log.info("grant read on universe to replication")
+    _priv:insert{ADMIN, REPLICATION, 'universe', 0, box.priv.R}
+    -- Replication can append to '_cluster' system space.
+    log.info("grant write on space _cluster to replication")
+    _priv:insert{ADMIN, REPLICATION, 'space', _cluster.id, box.priv.W}
+
+    _priv:insert{ADMIN, PUBLIC, 'space', _truncate.id, box.priv.W}
+
+    _priv:insert{ADMIN, PUBLIC, 'space', _collation.id, box.priv.W}
+
+    -- Create "box.schema.user.info" function.
+    log.info('create function "box.schema.user.info" with setuid')
+    _func:replace{1, ADMIN, 'box.schema.user.info', 1, 'LUA'}
     --
-    _priv:upsert({ADMIN, ADMIN, 'universe', 0, box.priv.ALL},
-                 {{ "|", 5, box.priv.ALL}})
+    -- Grant 'public' role access to 'box.schema.user.info'
+    -- function.
+    --
+    log.info('grant execute on function "box.schema.user.info" to public')
+    _priv:replace{ADMIN, PUBLIC, 'function', 1, box.priv.X}
     --
-    -- create role 'super' and grant it all privileges on universe
+    -- Create role 'super' and grant it all privileges on
+    -- universe.
     --
-    _user:replace{SUPER, ADMIN, 'super', 'role', setmap({})}
-    _priv:replace({ADMIN, SUPER, 'universe', 0, 4294967295})
+    _priv:replace({ADMIN, SUPER, 'universe', 0, box.priv.ALL})
+
+    log.info("set max_id to box.schema.SYSTEM_ID_MAX")
+    _schema:insert{'max_id', box.schema.SYSTEM_ID_MAX}
+
+    log.info("set schema version to 1.9.0")
+    _schema:insert({'version', 1, 9, 0})
 end
 
 --------------------------------------------------------------------------------
@@ -458,7 +403,8 @@ end
 --------------------------------------------------------------------------------
 local function create_vsequence_space()
     create_sysview(box.schema.SEQUENCE_ID, box.schema.VSEQUENCE_ID)
-    box.space._vsequence:format(sequence_format)
+    local format = box.space._space:get{box.schema.SEQUENCE_ID}.format
+    box.space._vsequence:format(format)
 end
 
 local function upgrade_to_1_10_0()
@@ -466,79 +412,60 @@ local function upgrade_to_1_10_0()
 end
 
 --------------------------------------------------------------------------------
--- Tarantool 1.8.2
+-- Tarantool 2.1.0
 --------------------------------------------------------------------------------
 
-local function upgrade_to_1_8_2()
+local function upgrade_to_2_1_0()
     local _space = box.space[box.schema.SPACE_ID]
     local _index = box.space[box.schema.INDEX_ID]
     local _trigger = box.space[box.schema.TRIGGER_ID]
+    local MAP = setmap({})
+
+    log.info("create space _trigger")
     local format = {{name='name', type='string'},
                     {name='opts', type='map'}}
+    _space:insert{_trigger.id, ADMIN, '_trigger', 'memtx', 0, MAP, format}
 
-    log.info("create space _trigger")
-    _space:insert{_trigger.id, ADMIN, '_trigger', 'memtx', 0, setmap({}), {}}
     log.info("create index primary on _trigger")
     _index:insert{_trigger.id, 0, 'primary', 'tree', { unique = true },
-        {{0, 'string'}}}
-
-    log.info("alter space _trigger set format")
-    _trigger:format(format)
-end
-
---------------------------------------------------------------------------------
--- Tarantool 1.8.4
---------------------------------------------------------------------------------
+                  {{0, 'string'}}}
 
-local function upgrade_to_1_8_4()
-    local _space = box.space[box.schema.SPACE_ID]
-    local _index = box.space[box.schema.INDEX_ID]
     local stat1_ft = {{name='tbl', type='string'},
                       {name='idx', type='string'},
-	              {name='stat', type='string'}}
+                      {name='stat', type='string'}}
     local stat4_ft = {{name='tbl', type='string'},
                       {name='idx', type='string'},
                       {name='neq', type='string'},
                       {name='nlt', type='string'},
                       {name='ndlt', type='string'},
                       {name='sample', type='scalar'}}
-    local MAP = setmap({})
 
     log.info("create space _sql_stat1")
-    _space:insert{box.schema.SQL_STAT1_ID, ADMIN, '_sql_stat1', 'memtx', 0,
-                  MAP, stat1_ft}
+    _space:insert{box.schema.SQL_STAT1_ID, ADMIN, '_sql_stat1', 'memtx', 0, MAP,
+                  stat1_ft}
 
     log.info("create index primary on _sql_stat1")
     _index:insert{box.schema.SQL_STAT1_ID, 0, 'primary', 'tree',
                   {unique = true}, {{0, 'string'}, {1, 'string'}}}
 
     log.info("create space _sql_stat4")
-    _space:insert{box.schema.SQL_STAT4_ID, ADMIN, '_sql_stat4', 'memtx', 0,
-                  MAP, stat4_ft}
+    _space:insert{box.schema.SQL_STAT4_ID, ADMIN, '_sql_stat4', 'memtx', 0, MAP,
+                  stat4_ft}
 
     log.info("create index primary on _sql_stat4")
     _index:insert{box.schema.SQL_STAT4_ID, 0, 'primary', 'tree',
                   {unique = true}, {{0, 'string'}, {1, 'string'},
-                  {5, 'scalar'}}}
+                                    {5, 'scalar'}}}
 
     -- Nullability wasn't skipable. This was fixed in 1-7.
     -- Now, abscent field means NULL, so we can safely set second
     -- field in format, marking it nullable.
     log.info("Add nullable value field to space _schema")
-    local format = {}
-    format[1] = {type='string', name='key'}
-    format[2] = {type='any', name='value', is_nullable=true}
+    format = {{type='string', name='key'},
+              {type='any', name='value', is_nullable=true}}
     box.space._schema:format(format)
 end
 
---------------------------------------------------------------------------------
--- Tarantool 2.1.0
---------------------------------------------------------------------------------
-
-local function upgrade_to_2_1_0()
-    upgrade_to_1_10_0()
-end
-
 local function get_version()
     local version = box.space._schema:get{'version'}
     if version == nil then
@@ -556,16 +483,13 @@ local function upgrade(options)
     setmetatable(options, {__index = {auto = false}})
 
     local version = get_version()
-    if version < mkversion(1, 7, 5) then
-        log.warn('can upgrade from 1.7.5 only')
+    if version < mkversion(1, 9, 0) then
+        log.warn('can upgrade from 1.9.0 only')
         return
     end
 
     local handlers = {
-        {version = mkversion(1, 7, 6), func = upgrade_to_1_7_6, auto = true},
-        {version = mkversion(1, 7, 7), func = upgrade_to_1_7_7, auto = true},
-        {version = mkversion(1, 8, 2), func = upgrade_to_1_8_2, auto = true},
-        {version = mkversion(1, 8, 4), func = upgrade_to_1_8_4, auto = true},
+        {version = mkversion(1, 10, 0), func = upgrade_to_1_10_0, auto = true},
         {version = mkversion(2, 1, 0), func = upgrade_to_2_1_0, auto = true}
     }
 
@@ -595,7 +519,7 @@ local function bootstrap()
     -- erase current schema
     erase()
     -- insert initial schema
-    initial_1_7_5()
+    initial_1_9_0()
     -- upgrade schema to the latest version
     upgrade()
 
diff --git a/test/sql/upgrade.result b/test/sql/upgrade.result
new file mode 100644
index 000000000..dcdb689bb
--- /dev/null
+++ b/test/sql/upgrade.result
@@ -0,0 +1,123 @@
+test_run = require('test_run').new()
+---
+...
+work_dir = 'sql/upgrade/1.10/'
+---
+...
+test_run:cmd('create server upgrade with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"')
+---
+- true
+...
+test_run:cmd('start server upgrade')
+---
+- true
+...
+test_run:switch('upgrade')
+---
+- true
+...
+-- test system tables
+box.space._space.index['name']:get('_trigger')
+---
+- [328, 1, '_trigger', 'memtx', 0, {}, [{'name': 'name', 'type': 'string'}, {'name': 'opts',
+      'type': 'map'}]]
+...
+box.space._space.index['name']:get('_sql_stat1')
+---
+- [348, 1, '_sql_stat1', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
+      'type': 'string'}, {'name': 'stat', 'type': 'string'}]]
+...
+box.space._space.index['name']:get('_sql_stat4')
+---
+- [349, 1, '_sql_stat4', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
+      'type': 'string'}, {'name': 'neq', 'type': 'string'}, {'name': 'nlt', 'type': 'string'},
+    {'name': 'ndlt', 'type': 'string'}, {'name': 'sample', 'type': 'scalar'}]]
+...
+box.space._index:get({box.space._space.index['name']:get('_trigger').id, 0})
+---
+- [328, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
+...
+box.space._index:get({box.space._space.index['name']:get('_sql_stat1').id, 0})
+---
+- [348, 0, 'primary', 'tree', {'unique': true}, [[0, 'string'], [1, 'string']]]
+...
+box.space._index:get({box.space._space.index['name']:get('_sql_stat4').id, 0})
+---
+- [349, 0, 'primary', 'tree', {'unique': true}, [[0, 'string'], [1, 'string'], [5,
+      'scalar']]]
+...
+box.space._schema:format()
+---
+- [{'type': 'string', 'name': 'key'}, {'type': 'any', 'name': 'value', 'is_nullable': true}]
+...
+-- test data migration
+box.space._space.index['name']:get('T1')
+---
+- [512, 1, 'T1', 'memtx', 0, {}, [{'name': 'x', 'type': 'unsigned'}]]
+...
+box.space._index:get({box.space._space.index['name']:get('T1').id, 0})
+---
+- [512, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
+...
+-- test system tables functionality
+box.sql.execute("CREATE TABLE t(x INTEGER PRIMARY KEY);")
+---
+...
+box.sql.execute("CREATE TABLE t_out(x INTEGER PRIMARY KEY);")
+---
+...
+box.sql.execute("CREATE TRIGGER t1t AFTER INSERT ON t BEGIN INSERT INTO t_out VALUES(1); END;")
+---
+...
+box.space._space.index['name']:get('T')
+---
+- [513, 1, 'T', 'memtx', 1, {'sql': 'CREATE TABLE t(x INTEGER PRIMARY KEY)'}, [{'type': 'integer',
+      'nullable_action': 'abort', 'name': 'X', 'is_nullable': false}]]
+...
+box.space._space.index['name']:get('T_OUT')
+---
+- [514, 1, 'T_OUT', 'memtx', 1, {'sql': 'CREATE TABLE t_out(x INTEGER PRIMARY KEY)'},
+  [{'type': 'integer', 'nullable_action': 'abort', 'name': 'X', 'is_nullable': false}]]
+...
+box.space._trigger:get('T1T')
+---
+- ['T1T', {'sql': 'CREATE TRIGGER t1t AFTER INSERT ON t BEGIN INSERT INTO t_out VALUES(1);
+      END;'}]
+...
+box.sql.execute("INSERT INTO T VALUES(1);")
+---
+...
+box.space.T:select()
+---
+- - [1]
+...
+box.space.T_OUT:select()
+---
+- - [1]
+...
+box.sql.execute("SELECT * FROM T")
+---
+- - [1]
+...
+box.sql.execute("SELECT * FROM T")
+---
+- - [1]
+...
+box.sql.execute("DROP TABLE T;")
+---
+...
+box.sql.execute("DROP TABLE T_OUT;")
+---
+...
+test_run:switch('default')
+---
+- true
+...
+test_run:cmd('stop server upgrade')
+---
+- true
+...
+test_run:cmd('cleanup server upgrade')
+---
+- true
+...
diff --git a/test/sql/upgrade.test.lua b/test/sql/upgrade.test.lua
new file mode 100644
index 000000000..d0add86f0
--- /dev/null
+++ b/test/sql/upgrade.test.lua
@@ -0,0 +1,45 @@
+test_run = require('test_run').new()
+
+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._space.index['name']:get('_sql_stat1')
+box.space._space.index['name']:get('_sql_stat4')
+
+box.space._index:get({box.space._space.index['name']:get('_trigger').id, 0})
+box.space._index:get({box.space._space.index['name']:get('_sql_stat1').id, 0})
+box.space._index:get({box.space._space.index['name']:get('_sql_stat4').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.sql.execute("CREATE TABLE t(x INTEGER PRIMARY KEY);")
+box.sql.execute("CREATE TABLE t_out(x INTEGER PRIMARY KEY);")
+box.sql.execute("CREATE TRIGGER t1t AFTER INSERT ON t BEGIN INSERT INTO t_out VALUES(1); END;")
+box.space._space.index['name']:get('T')
+box.space._space.index['name']:get('T_OUT')
+box.space._trigger:get('T1T')
+
+box.sql.execute("INSERT INTO T VALUES(1);")
+box.space.T:select()
+box.space.T_OUT:select()
+box.sql.execute("SELECT * FROM T")
+box.sql.execute("SELECT * FROM T")
+
+
+box.sql.execute("DROP TABLE T;")
+box.sql.execute("DROP TABLE T_OUT;")
+
+
+test_run:switch('default')
+test_run:cmd('stop server upgrade')
+test_run:cmd('cleanup server upgrade')

diff --git a/test/sql/upgrade/upgrade.lua b/test/sql/upgrade/upgrade.lua
new file mode 100644
index 000000000..2853492b0
--- /dev/null
+++ b/test/sql/upgrade/upgrade.lua
@@ -0,0 +1,7 @@
+#!/usr/bin/env tarantool
+
+box.cfg{
+    listen = os.getenv("LISTEN"),
+}
+
+require('console').listen(os.getenv('ADMIN'))
diff --git a/test/vinyl/suite.cfg b/test/vinyl/suite.cfg
index 35316810c..0eb97d5d0 100644
--- a/test/vinyl/suite.cfg
+++ b/test/vinyl/suite.cfg
@@ -1,8 +1,5 @@
 {
     "options.test.lua": {
         "edge": {"index_options": {"range_size": 1, "page_size": 1}}
-    },
-    "upgrade.test.lua": {
-        "1.7.7": {"version": "1.7.7"}
     }
 }
diff --git a/test/vinyl/suite.ini b/test/vinyl/suite.ini
index ca964289b..322c6a474 100644
--- a/test/vinyl/suite.ini
+++ b/test/vinyl/suite.ini
@@ -8,3 +8,4 @@ lua_libs = suite.lua stress.lua large.lua txn_proxy.lua ../box/lua/utils.lua
 use_unix_sockets = True
 long_run = stress.test.lua large.test.lua write_iterator_rand.test.lua dump_stress.test.lua select_consistency.test.lua
 is_parallel = False
+disabled = upgrade.test.lua

diff --git a/test/xlog/suite.ini b/test/xlog/suite.ini
index 8ee97204c..016c5707b 100644
--- a/test/xlog/suite.ini
+++ b/test/xlog/suite.ini
@@ -2,7 +2,7 @@
 core = tarantool
 description = tarantool write ahead log tests
 script = xlog.lua
-disabled = snap_io_rate.test.lua
+disabled = snap_io_rate.test.lua upgrade.test.lua
 valgrind_disabled =
 release_disabled = errinj.test.lua panic_on_lsn_gap.test.lua
 config = suite.cfg

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-06-08 19:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-08 19:45 [tarantool-patches] [PATCH 1/1] Deal with upgrade mess in 2.0 Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox