From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 19CC627304 for ; Tue, 31 Jul 2018 07:33:04 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iEQ9fTFI3KQD for ; Tue, 31 Jul 2018 07:33:04 -0400 (EDT) Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id CC830272CB for ; Tue, 31 Jul 2018 07:33:03 -0400 (EDT) Received: from [185.6.245.156] (port=55350 helo=[100.96.166.235]) by smtp40.i.mail.ru with esmtpa (envelope-from ) id 1fkSti-0006eK-5y for tarantool-patches@freelists.org; Tue, 31 Jul 2018 14:33:02 +0300 Subject: [tarantool-patches] Re: [PATCH 4/4] Introduce storage reload evolution References: <1e067dd68d69270ccf5aea2ab73548ebd9a0f2ad.1532940401.git.avkhatskevich@tarantool.org> <3d8a81f7-33a6-bf1d-809f-ae5b95730a64@tarantool.org> From: Alex Khatskevich Message-ID: <83a958f1-e47c-cf5c-7996-3983b7a28b9f@tarantool.org> Date: Tue, 31 Jul 2018 14:33:02 +0300 MIME-Version: 1.0 In-Reply-To: <3d8a81f7-33a6-bf1d-809f-ae5b95730a64@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org diff of test/lua_libs/git_util.lua commit 199e198af97200e9a01b5b2568c8e9b2a2a9f34d Author: AKhatskevich 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 +}