Skip to content
Snippets Groups Projects
Commit bf1f05b0 authored by Ilya Grishnov's avatar Ilya Grishnov Committed by Yaroslav Lobankov
Browse files

box: fix shared lang between connected clients

Fixed the implementation of the box console.
Before this fix, result of `\set language` is shared between clients
via `console.connect`, despite the fact that clients have different
`box.session.id`. Now the parameter of the selected language is stored
by each client in his own `box.session.storage`.

Fixes #8817

NO_DOC=bugfix

(cherry picked from commit e4fda4b7)
parent 66443f84
No related branches found
No related tags found
No related merge requests found
## bugfix/box
* Fixed a bug in the box console implementation because of
which the `language` parameter was shared between connected
clients (gh-8817).
......@@ -426,7 +426,7 @@ local function local_eval(storage, line)
end
local function eval(line)
return local_eval(box.session, line)
return local_eval(box.session.storage, line)
end
local text_connection_mt = {
......
local fio = require('fio')
local t = require('luatest')
local server = require('luatest.server')
local it = require('test.interactive_tarantool')
local g = t.group()
-- Create test instances and open connections.
g.before_all(function()
g.server = server:new({alias = 'test-gh-8817-server'})
g.server:start()
local socket_path = fio.pathjoin(g.server.workdir, 'admin.socket')
local listen_command = "require('console').listen('%s')"
local connect_command = "require('console').connect('%s')"
listen_command = listen_command:format(socket_path)
connect_command = connect_command:format(socket_path)
-- Listen on the server.
g.server:eval(listen_command)
g.first_client = it:new()
g.second_client = it:new()
-- Create first connection to the server.
g.first_client:execute_command(connect_command)
t.assert_equals(
g.first_client:read_response(),
true
)
g.first_client:set_prompt(('unix/:%s> '):format(socket_path))
-- Create second connection to the server.
g.second_client:execute_command(connect_command)
t.assert_equals(
g.second_client:read_response(),
true
)
g.second_client:set_prompt(('unix/:%s> '):format(socket_path))
-- Make sure that box.session.id are different on test clients.
g.first_client:execute_command("box.session.id()")
local first_client_session_id = g.first_client:read_response()
g.second_client:execute_command("box.session.id()")
local second_client_session_id = g.second_client:read_response()
t.assert_not_equals(
first_client_session_id,
second_client_session_id
)
end)
-- Stop test instances.
g.after_all(function()
g.server:stop()
g.first_client:close()
g.second_client:close()
end)
-- Checks that the language setting is not shared between clients.
g.test_set_language_not_shared_between_clients = function()
-- Check initial language on clients.
g.first_client:execute_command("\\set language")
t.assert_equals(
g.first_client:read_response(),
{language = "lua"}
)
g.second_client:execute_command("\\set language")
t.assert_equals(
g.second_client:read_response(),
{language = "lua"}
)
-- Set new language on first client.
g.first_client:execute_command("\\set language sql")
t.assert_equals(
g.first_client:read_response(),
true
)
-- Check that language changes on the first client
-- did not spread to the second.
g.second_client:execute_command("\\set language")
t.assert_equals(
g.second_client:read_response(),
{language = "lua"}
)
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment