diff --git a/extra/empty.snap b/extra/empty.snap index 090233cf41eba4ac388176c20370673e5da3ae5d..3997fc8528c0be601a60bd590ddcbe847567cff8 100644 Binary files a/extra/empty.snap and b/extra/empty.snap differ diff --git a/extra/schema_erase.lua b/extra/schema_erase.lua index 56d773df5fc079f08fee5c178b32d7a135289310..3593cbb1ae4f3f439bb16ed89990e6009bd17733 100644 --- a/extra/schema_erase.lua +++ b/extra/schema_erase.lua @@ -6,21 +6,31 @@ _func = box.space[box.schema.FUNC_ID] _priv = box.space[box.schema.PRIV_ID] _cluster = box.space[box.schema.CLUSTER_ID] -- destroy everything - save snapshot produces an empty snapshot now -_schema:run_triggers(false) -_schema:truncate() + +-- space:truncate() doesn't work with disabled triggers on __index +local function truncate(space) + local pk = space.index[0] + while pk:len() > 0 do + local state, t + for state, t in pk:pairs() do + local key = {} + for _k2, parts in ipairs(pk.parts) do + table.insert(key, t[parts.fieldno]) + end + space:delete(key) + end + end +end + _space:run_triggers(false) -_space:truncate() _index:run_triggers(false) -_index:truncate() _user:run_triggers(false) -_user:truncate() _func:run_triggers(false) -_func:truncate() _priv:run_triggers(false) -_priv:truncate() -_cluster:run_triggers(false) --- select server id 1 - self -t = _cluster:get{1} -_cluster:truncate() --- preserve self-identification -_cluster:insert(t) + +truncate(_space) +truncate(_index) +truncate(_user) +truncate(_func) +truncate(_priv) +_schema:delete('version') diff --git a/test/box/bootstrap.result b/test/box/bootstrap.result new file mode 100644 index 0000000000000000000000000000000000000000..670fab9ff86cb24ef0e53e7f1c082742492de37f --- /dev/null +++ b/test/box/bootstrap.result @@ -0,0 +1,91 @@ +dofile("<builddir>/extra/schema_erase.lua") +--- +... +box.space._schema:select{} +--- +- - ['cluster', '<cluster uuid>'] +... +box.space._cluster:select{} +--- +- - [1, '<server uuid>'] +... +box.space._space:select{} +--- +- [] +... +box.space._index:select{} +--- +- [] +... +box.space._user:select{} +--- +- [] +... +box.space._func:select{} +--- +- [] +... +box.space._priv:select{} +--- +- [] +... +dofile("<builddir>/extra/schema_fill.lua") +--- +... +box.snapshot() +--- +- ok +... +box.space._schema:select{} +--- +- - ['cluster', '<cluster uuid>'] + - ['version', 1, 6] +... +box.space._cluster:select{} +--- +- - [1, '<server uuid>'] +... +box.space._space:select{} +--- +- - [272, 1, '_schema', 'memtx', 0] + - [280, 1, '_space', 'memtx', 0] + - [288, 1, '_index', 'memtx', 0] + - [296, 1, '_func', 'memtx', 0] + - [304, 1, '_user', 'memtx', 0] + - [312, 1, '_priv', 'memtx', 0] + - [320, 1, '_cluster', 'memtx', 0] +... +box.space._index:select{} +--- +- - [272, 0, 'primary', 'tree', 1, 1, 0, 'str'] + - [280, 0, 'primary', 'tree', 1, 1, 0, 'num'] + - [280, 1, 'owner', 'tree', 0, 1, 1, 'num'] + - [280, 2, 'name', 'tree', 1, 1, 2, 'str'] + - [288, 0, 'primary', 'tree', 1, 2, 0, 'num', 1, 'num'] + - [288, 2, 'name', 'tree', 1, 2, 0, 'num', 2, 'str'] + - [296, 0, 'primary', 'tree', 1, 1, 0, 'num'] + - [296, 1, 'owner', 'tree', 0, 1, 1, 'num'] + - [296, 2, 'name', 'tree', 1, 1, 2, 'str'] + - [304, 0, 'primary', 'tree', 1, 1, 0, 'num'] + - [304, 1, 'owner', 'tree', 0, 1, 1, 'num'] + - [304, 2, 'name', 'tree', 1, 1, 2, 'str'] + - [312, 0, 'primary', 'tree', 1, 3, 1, 'num', 2, 'str', 3, 'num'] + - [312, 1, 'owner', 'tree', 0, 1, 0, 'num'] + - [312, 2, 'object', 'tree', 0, 2, 2, 'str', 3, 'num'] + - [320, 0, 'primary', 'tree', 1, 1, 0, 'num'] + - [320, 1, 'uuid', 'tree', 1, 1, 1, 'str'] +... +box.space._user:select{} +--- +- - [0, 1, 'guest', 'user'] + - [1, 1, 'admin', 'user'] + - [2, 1, 'public', 'role'] +... +box.space._func:select{} +--- +- [] +... +box.space._priv:select{} +--- +- - [1, 1, 'universe', 0, 7] +... diff --git a/test/box/bootstrap.test.py b/test/box/bootstrap.test.py new file mode 100644 index 0000000000000000000000000000000000000000..ada352dbf07e64875443de5f4da5dc61434e8969 --- /dev/null +++ b/test/box/bootstrap.test.py @@ -0,0 +1,34 @@ + +import sys +import yaml + +server_uuid = server.get_param('server')['uuid'] +sys.stdout.push_filter(server_uuid, '<server uuid>') +cluster_uuid = yaml.load(server.admin('box.space._schema:get("cluster")', + silent = True))[0][1] +sys.stdout.push_filter(cluster_uuid, '<cluster uuid>') +sys.stdout.push_filter(server.builddir, '<builddir>') + +server.admin('dofile("%s/extra/schema_erase.lua")' % server.builddir) +server.admin('box.space._schema:select{}') +server.admin('box.space._cluster:select{}') +server.admin('box.space._space:select{}') +server.admin('box.space._index:select{}') +server.admin('box.space._user:select{}') +server.admin('box.space._func:select{}') +server.admin('box.space._priv:select{}') + +server.admin('dofile("%s/extra/schema_fill.lua")' % server.builddir) +server.admin("box.snapshot()") +server.restart() + +server.admin('box.space._schema:select{}') +server.admin('box.space._cluster:select{}') +server.admin('box.space._space:select{}') +server.admin('box.space._index:select{}') +server.admin('box.space._user:select{}') +server.admin('box.space._func:select{}') +server.admin('box.space._priv:select{}') + +# Cleanup +sys.stdout.pop_filter()