tarantool / vshard

The new generation of sharding based on virtual buckets
Other
98 stars 29 forks source link

`reload_evolution/storage.test.lua` behaves strange when `vshard.cfg` is included in `lua_libs/util` #452

Open Serpentian opened 7 months ago

Serpentian commented 7 months ago

The following diff causes an error in reload_evolution/storage.test.lua:

[009] reload_evolution/storage.test.lua
[009]
[009] [Instance "storage_2_a" returns with non-zero exit code: 1]
[009]
[009] Last 15 lines of Tarantool Log file [Instance "storage_2_a"][/home/serpentian/Programming/tnt/vshard/test/var/009_reload_evolution/storage_2_a.log]:
[009] Starting instance storage_2_a...
[009] started
[009] Start failed: ...rd/test/var/vshard_git_tree_copy/vshard/storage/init.lua:2045: attempt to call field 'split' (a nil value)
[009] [ fail ]
Diff ```diff diff --git a/test/lua_libs/util.lua b/test/lua_libs/util.lua index 3f435cc..dc1cd86 100644 --- a/test/lua_libs/util.lua +++ b/test/lua_libs/util.lua @@ -2,6 +2,7 @@ local fiber = require('fiber') local log = require('log') local fio = require('fio') local git = require('git_util') +local vcfg = require('vshard.cfg') local name_to_uuid = { storage_1_a = '8a274925-a26d-47fc-9e1b-af88ce939412', @@ -215,6 +216,23 @@ local function map_bucket_protection(test_run, cluster, value) [[vshard.storage.internal.is_bucket_protected = ...]], value) end +local function box_router_cfg(cfg, router) + local vcfg = require('vshard.cfg') + local vshard_cfg = vcfg.extract_vshard(cfg) + local box_cfg = vcfg.extract_box(cfg, {}) + box.cfg(box_cfg) + if router == nil then + -- Static router configuration + return vshard.router.cfg(vshard_cfg) + end + if type(router) == 'table' then + -- Named router reconfiguration + return router:cfg(vshard_cfg) + end + -- Named router creation + return vshard.router.new(router, vshard_cfg) +end + return { check_error = check_error, shuffle_masters = shuffle_masters, @@ -231,4 +249,5 @@ return { git_checkout = git_checkout, portable_error = portable_error, is_timeout_error = is_timeout_error, + box_router_cfg = box_router_cfg, } ```
Totktonada commented 7 months ago

It looks like require('vshard.cfg') catches a wrong version of the module: from the git clone rather than from the checked out old version.

I met a problem of this kind and, if I remember it correctly, it was around .rocks/cwd/system require search paths priority. Maybe I did tarantoolctl rocks make in the vshard directory or had some vshard version installed in /usr/share/tarantool or in /.rocks.

I hope it helps.