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

Ban direct calling of box.cfg() #245

Closed
Tracked by #283
Totktonada opened this issue Sep 24, 2022 · 2 comments
Closed
Tracked by #283

Ban direct calling of box.cfg() #245

Totktonada opened this issue Sep 24, 2022 · 2 comments
Assignees
Labels
feature A new functionality

Comments

@Totktonada
Copy link
Member

It likely badly influence other tests and may look like luatest itself is buggy.

The proposal is to forbid calling box.cfg() not only from topmost level code, but also from tests. If we'll do only the former, a test that follows one that calls box.cfg() will be influenced and this effect will depend on the order of tests. It is better if a test with box.cfg() will always fail.

It can be implemented either as a check after require('<...>_test.lua') and after execution of a test. Or we can simply do box.cfg = nil before loading tests.

If box.cfg() is required for testing, it should be called on an auxiliary instance.

Motivating issue in tarantool/tarantool#7647. See also #191.

@Totktonada
Copy link
Member Author

Just box.cfg = nil doesn't work (because the indexing is handled by box's metatable). However, we still can forbid it:

tarantool> box.cfg = setmetatable({}, {__call = function() error('No!', 0) end})
tarantool> box.cfg()
---
- error: No!
...

@ylobankov proposed to just add it to test.helper (a module that is required by luatest automatically) into tarantool repository. If it works, this is a good variant: easy to copy-paste by ones who need it, don't hurt simple test suites, where it may be convenient to call box.cfg() directly.

ochaplashkin pushed a commit to ochaplashkin/tarantool that referenced this issue May 26, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg
ochaplashkin pushed a commit to ochaplashkin/tarantool that referenced this issue May 30, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg
ochaplashkin pushed a commit to ochaplashkin/tarantool that referenced this issue May 31, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg
ochaplashkin pushed a commit to ochaplashkin/tarantool that referenced this issue May 31, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg
ochaplashkin pushed a commit to ochaplashkin/tarantool that referenced this issue Jun 1, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg
ochaplashkin pushed a commit to ochaplashkin/tarantool that referenced this issue Jun 2, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg
ochaplashkin pushed a commit to ochaplashkin/tarantool that referenced this issue Jun 2, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg
ylobankov pushed a commit to tarantool/tarantool that referenced this issue Jun 2, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg
ylobankov pushed a commit to tarantool/tarantool that referenced this issue Jun 2, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg

(cherry picked from commit fc3426d)
ylobankov pushed a commit to tarantool/tarantool that referenced this issue Jun 2, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg

(cherry picked from commit fc3426d)
ylobankov pushed a commit to tarantool/tarantool that referenced this issue Jun 2, 2023
Direct call and configuration of the runner instance is prohibited. Now
if you need to test something with specific configuration use a server
instance please (see luatest.Server module).

In-scope-of tarantool/luatest#245

NO_DOC=ban calling box.cfg
NO_TEST=ban calling box.cfg
NO_CHANGELOG=ban calling box.cfg

(cherry picked from commit fc3426d)
@ylobankov
Copy link
Contributor

Let's consider this fixed. We banned calling box.cfg() in tarantool tests via tarantool/tarantool#8709. Anyone can do the same for her project as well.

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

No branches or pull requests

4 participants