Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Serpentian opened this issue Dec 6, 2023 · 1 comment
Assignees

Comments

@Serpentian
Copy link
Contributor

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 --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,
 }
@Serpentian Serpentian self-assigned this Dec 6, 2023
@Totktonada
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants