[tarantool-patches] Re: [PATCH 4/4] Introduce storage reload evolution
Alex Khatskevich
avkhatskevich at tarantool.org
Tue Jul 31 14:33:02 MSK 2018
diff of test/lua_libs/git_util.lua
commit 199e198af97200e9a01b5b2568c8e9b2a2a9f34d
Author: AKhatskevich <avkhatskevich at tarantool.org>
Date: Fri Jun 29 20:34:26 2018 +0300
Introduce storage reload evolution
Changes:
1. Introduce storage reload evolution.
2. Setup cross-version reload testing.
1:
This mechanism updates Lua objects on reload in case they are
changed in a new vshard.storage version.
Since this commit, any change in vshard.storage.M has to be
reflected in vshard.storage.reload_evolution to guarantee
correct reload.
2:
The testing uses git infrastructure and is performed in the following
way:
1. Copy old version of vshard to a temp folder.
2. Run vshard on this code.
3. Checkout the latest version of the vshard sources.
4. Reload vshard storage.
5. Make sure it works (Perform simple tests).
Notes:
* this patch contains some legacy-driven decisions:
1. SOURCEDIR path retrieved differently in case of
packpack build.
2. git directory in the `reload_evolution/storage` test
is copied with respect to Centos 7 and `ro` mode of
SOURCEDIR.
Closes #112 #125
diff --git a/test/lua_libs/git_util.lua b/test/lua_libs/git_util.lua
new file mode 100644
index 0000000..8826c4c
--- /dev/null
+++ b/test/lua_libs/git_util.lua
@@ -0,0 +1,49 @@
+--
+-- Lua bridge for some of the git commands.
+--
+local os = require('os')
+
+--
+-- Exec a git command.
+-- @param params Table of parameters:
+-- * options - git options.
+-- * cmd - git command.
+-- * args - command arguments.
+-- * dir - working directory.
+-- * fout - write output to the file.
+local function exec_cmd(params)
+ local fout = params.fout
+ local shell_cmd = {'git'}
+ for _, param in pairs({'options', 'cmd', 'args'}) do
+ table.insert(shell_cmd, params[param])
+ end
+ if fout then
+ table.insert(shell_cmd, ' >' .. fout)
+ end
+ shell_cmd = table.concat(shell_cmd, ' ')
+ if params.dir then
+ shell_cmd = string.format('cd %s && %s', params.dir, shell_cmd)
+ end
+ local res = os.execute(shell_cmd)
+ assert(res == 0, 'Git cmd error: ' .. res)
+end
+
+local function log_hashes(params)
+ params.args = "--format='%h' " .. params.args
+ -- Store log to the file.
+ local temp_file = os.tmpname()
+ params.fout = temp_file
+ params.cmd = 'log'
+ exec_cmd(params)
+ local lines = {}
+ for line in io.lines(temp_file) do
+ table.insert(lines, line)
+ end
+ os.remove(temp_file)
+ return lines
+end
+
+return {
+ exec_cmd = exec_cmd,
+ log_hashes = log_hashes
+}
More information about the Tarantool-patches
mailing list