From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: Oleg Babin <olegrok@tarantool.org>, tarantool-patches@dev.tarantool.org, yaroslav.dynnikov@tarantool.org Subject: Re: [Tarantool-patches] [PATCH vshard 2/2] storage: introduce vshard.storage._call() Date: Sun, 22 Mar 2020 20:13:09 +0100 [thread overview] Message-ID: <4a6edd2a-7173-706c-0622-a805b152dc70@tarantool.org> (raw) In-Reply-To: <1f571d45-179d-1b72-941d-3de21c2e8f11@tarantool.org> On 22/03/2020 06:08, Oleg Babin wrote: > Thanks for your patch! See comments bellow. > > On 21/03/2020 21:59, Vladislav Shpilevoy wrote: >> _call can't be properly integrated at this moment, because that >> would break rebalancing from old nodes. The new function is only >> added. Its usage and drop of old functions will happen in 0.1.17 >> when I will finish and merge top commit from this branch: >> https://github.com/tarantool/vshard/tree/gerold103/gh-227-drop-old-functions > > Could you add some "smoke" tests for "_call" function? The test in this patch only checks that it exists but don't check that it works. If it's hard and non-trivial ignore this comment. Ok, see my attempt below. It is hard to test each function, because 1) bucket_recv() requires to be called twice, and with non-trivial arguments; 2) rebalancer_apply_routes() is async, it starts a fiber and returns always true, so to test its _call invocation it is necessary to do some manual rebalancing. But since _call functions are anyway used in other places, and are already tested, the only thing left to test is whether all functions are added to _call API, and if the arguments are forwarded correctly. So I added a new function for this: 'test_api'. It returns which functions are present in _call API, and how arguments are forwarded. (And which proves why _call is so useful - can add anything to there, hidden from a user, from _func space, even add some test things.) ==================== diff --git a/test/upgrade/upgrade.result b/test/upgrade/upgrade.result index 104d31a..9e6d810 100644 --- a/test/upgrade/upgrade.result +++ b/test/upgrade/upgrade.result @@ -162,6 +162,16 @@ vshard.storage._call ~= nil | --- | - true | ... +vshard.storage._call('test_api', 1, 2, 3) + | --- + | - bucket_recv: true + | rebalancer_apply_routes: true + | test_api: true + | rebalancer_request_state: true + | - 1 + | - 2 + | - 3 + | ... test_run:switch('storage_1_b') | --- diff --git a/test/upgrade/upgrade.test.lua b/test/upgrade/upgrade.test.lua index 422920e..aea0da8 100644 --- a/test/upgrade/upgrade.test.lua +++ b/test/upgrade/upgrade.test.lua @@ -53,6 +53,7 @@ box.space._schema:get({'vshard_version'}) vshard.storage.internal.schema_current_version() vshard.storage.internal.schema_latest_version vshard.storage._call ~= nil +vshard.storage._call('test_api', 1, 2, 3) test_run:switch('storage_1_b') box.space._schema:get({'vshard_version'}) diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua index 77bc9dd..6aa5d6a 100644 --- a/vshard/storage/init.lua +++ b/vshard/storage/init.lua @@ -2184,11 +2184,24 @@ local function storage_call(bucket_id, mode, name, args) return ok, ret1, ret2, ret3 end -local service_call_api = { +local service_call_api + +local function service_call_test_api(...) + return service_call_api, ... +end + +service_call_api = setmetatable({ bucket_recv = bucket_recv, rebalancer_apply_routes = rebalancer_apply_routes, rebalancer_request_state = rebalancer_request_state, -} + test_api = service_call_test_api, +}, {__serialize = function(api) + local res = {} + for k, _ in pairs(api) do + res[k] = true + end + return res +end}) local function service_call(...) local service_name = select(1, ...) ==================== __serialize is redefined so as not to print function addresses in the test. >> +local service_call_api = { >> + bucket_recv = bucket_recv, >> + rebalancer_apply_routes = rebalancer_apply_routes, >> + rebalancer_request_state = rebalancer_request_state, >> +} >> + >> +local function service_call(...) >> + local service_name = select(1, ...) >> + return service_call_api[service_name](select(2, ...)) >> +end > > What's about checking that "service_call_api[service_name]" exists? Since the API is entirely internal, I decided to avoid here such sanity checks against API misusage.
next prev parent reply other threads:[~2020-03-22 19:13 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-21 18:59 [Tarantool-patches] [PATCH vshard 0/2] vshard upgrade and _call Vladislav Shpilevoy 2020-03-21 18:59 ` [Tarantool-patches] [PATCH vshard 1/2] storage: introduce upgrade strategy Vladislav Shpilevoy 2020-03-22 5:05 ` Oleg Babin 2020-03-22 19:12 ` Vladislav Shpilevoy 2020-03-23 6:35 ` Oleg Babin 2020-03-23 22:32 ` Vladislav Shpilevoy 2020-03-24 4:32 ` Oleg Babin 2020-03-24 15:21 ` Yaroslav Dynnikov 2020-03-24 23:44 ` Vladislav Shpilevoy 2020-03-21 18:59 ` [Tarantool-patches] [PATCH vshard 2/2] storage: introduce vshard.storage._call() Vladislav Shpilevoy 2020-03-22 5:08 ` Oleg Babin 2020-03-22 19:13 ` Vladislav Shpilevoy [this message] 2020-03-23 6:42 ` Oleg Babin 2020-03-23 22:32 ` Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=4a6edd2a-7173-706c-0622-a805b152dc70@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=olegrok@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=yaroslav.dynnikov@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH vshard 2/2] storage: introduce vshard.storage._call()' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox