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

Migrate cluster module and adapt it #406

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

georgiy-belyanin
Copy link
Member

@georgiy-belyanin georgiy-belyanin commented Dec 15, 2024

The original cluster module (tarantool/test/config-luatest/cluster.lua) has been moved to the current project and will be available as follows:

local t = require('luatest')
local cluster = t.cluster:new(...)

cluster:start()

It is used to simplify managing Tarantool clusters based on the provided configuration. The helper requires Tarantool 3.0.0 or newer. Otherwise cluster methods cause an error.

Original helper created by: [email protected]
Test author: [email protected]

Closes #368

@georgiy-belyanin
Copy link
Member Author

georgiy-belyanin commented Dec 15, 2024

The changes I've made to the original helper:

  • g.cluster variable preserving the cluster is now g._cluster to avoid clashing with the module itself in this scenario:
local t = require('luatest')
-- If the created cluster is saved in g.cluster the clash occurs
local cluster = t.cluster.new(...)
  • Now cluster.init/drop/clean hooks are registered automatically (I've dropped init() since it only had a stub in it).
  • I've changed the wait_for_start code a bit since there is a problem with capturing upvalue luatest by server:exec.
-             server:exec(function()
-                 t.helpers.retrying({timeout = 60}, function()
-                     t.assert_equals(box.info.status, 'running')
-                 end)
+             helpers.retrying({timeout = 60}, function()
+                 assertions.assert_equals(server:eval('return box.info.status'),
+                                          'running')
  • Some annoying renames local server -> local iserver in the helper, cluster -> c in the tests due to the linter settings.
  • A little bit of extra docs for consistency.

@georgiy-belyanin georgiy-belyanin force-pushed the cluster-helper branch 2 times, most recently from 8dfbae0 to 902f6db Compare December 17, 2024 15:13
@georgiy-belyanin georgiy-belyanin marked this pull request as ready for review December 17, 2024 15:17
luatest/cluster.lua Outdated Show resolved Hide resolved
luatest/cluster.lua Outdated Show resolved Hide resolved
Copy link
Member

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've no objections. Thanks for working on it!

Left a few remarks about consistency with other luatest APIs.

@Totktonada Totktonada removed their assignment Dec 19, 2024
The original `cluster` module
(tarantool/test/config-luatest/cluster.lua) has been moved to the
current project and will be available as follows:

```lua
local t = require('luatest')
local cluster = t.cluster:new(...)

cluster:start()
```

It is used to simplify managing Tarantool clusters based on the provided
configuration. The helper requires Tarantool 3.0.0 or newer. Otherwise
cluster methods cause an error.

Original helper created by: [email protected]
Test author: [email protected]

Closes tarantool#368
@Totktonada Totktonada removed their assignment Dec 20, 2024
@Totktonada
Copy link
Member

@georgiy-belyanin Thanks for the updates! I'm ready to merge it.

@locker Do you have any objections regarding luatest-consistent API?

Personally, I don't like all this quazi-oop, but it seems like this is the luatest way.

@locker
Copy link
Member

locker commented Dec 20, 2024

@locker Do you have any objections regarding luatest-consistent API?

No.

@Totktonada Totktonada merged commit b446120 into tarantool:master Dec 20, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

Add cluster.lua module from tarantool to luatest and adapt it
3 participants