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

Parameterization for group breaks tests, before_all is not executed #390

Open
Serpentian opened this issue Sep 26, 2024 · 2 comments
Open

Comments

@Serpentian
Copy link
Contributor

Serpentian commented Sep 26, 2024

When before_all trigger is defined as g.before_all = function() ..., then test with group config doesn't work, it seems before_all doesn't launch at all, as the test fails with the following error:

[001] replication-luatest/check_group_test.lua                                                                                                           [ fail ]
[001] Test failed! Output from reject file /tmp/t/rejects/replication-luatest/check_group.reject:
[001] Tarantool version is 3.3.0-entrypoint-107-g0c7f17ffe
[001] TAP version 13
[001] 1..2
[001] # Started on Thu Sep 26 11:48:30 2024
[001] # Starting group: hey.engine:"memtx"
[001] not ok 1	hey.engine:"memtx".test_something
[001] #   .../tarantool/test/replication-luatest/check_group_test.lua:20: attempt to index field 'master' (a nil value)
[001] #   stack traceback:
[001] #   	...
[001] #   	[C]: in function 'xpcall'
[001] # Starting group: hey.engine:"vinyl"
[001] not ok 2	hey.engine:"vinyl".test_something
[001] #   .../tarantool/test/replication-luatest/check_group_test.lua:20: attempt to index field 'master' (a nil value)
[001] #   stack traceback:
[001] #   	...
[001] #   	[C]: in function 'xpcall'
[001] # Ran 2 tests in 0.001 seconds, 0 succeeded, 2 errored

However, when it's defined as g.before_all(function()...), everything is fine.

Broken one
local t = require('luatest')
local replica_set = require('luatest.replica_set')
local server = require('luatest.server')

local g = t.group('hey', {{engine = 'memtx'}, {engine = 'vinyl'}})

g.before_all = function(lg)
    lg.replica_set = replica_set:new({})
    lg.master = lg.replica_set:build_and_add_server({alias = 'master', box_cfg = {
        replication_timeout = 0.1,
    }})
    lg.replica_set:start()
end

g.after_all = function(lg)
    lg.replica_set:drop()
end

g.test_something = function(lg)
    lg.master:exec(function()
        t.assert(true)
    end)
end
Working one
local t = require('luatest')
local replica_set = require('luatest.replica_set')
local server = require('luatest.server')

local g = t.group('hey', {{engine = 'memtx'}, {engine = 'vinyl'}})

g.before_all(function(lg)
    lg.replica_set = replica_set:new({})
    lg.master = lg.replica_set:build_and_add_server({alias = 'master', box_cfg = {
        replication_timeout = 0.1,
    }})
    lg.replica_set:start()
end)

g.after_all(function(lg)
    lg.replica_set:drop()
end)

g.test_something = function(lg)
    lg.master:exec(function()
        t.assert(true)
    end)
end
@Totktonada
Copy link
Member

See also tarantool/tarantool#8066. It would be nice to have some automatic check like it is done for a call of box.cfg() in a test in #245.

@Serpentian
Copy link
Contributor Author

Serpentian commented Sep 26, 2024

This should be fixed, at least with a proper error. I spent 2 hours today, trying to figure out, why parameterization doesn't work, it's impossible to find that closed ticket if you don't know, that before_all is the reason

@Serpentian Serpentian changed the title Config for group breaks tests, before_all is not executed Parameterization for group breaks tests, before_all is not executed Sep 26, 2024
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