diff --git a/src/box/lua/info.cc b/src/box/lua/info.cc index 439ef71f1f73654f43d52c794d02d8b637199dd0..0b72990db8e829a1ddd9799402509bd506a27ecc 100644 --- a/src/box/lua/info.cc +++ b/src/box/lua/info.cc @@ -172,6 +172,16 @@ lbox_info_index(struct lua_State *L) return 1; } +/** Push a bunch of compile-time or start-time constants into a Lua table. */ +static void +lbox_info_init_static_values(struct lua_State *L) +{ + /* tarantool version */ + lua_pushstring(L, "version"); + lua_pushstring(L, tarantool_version()); + lua_settable(L, -3); +} + /** * When user invokes box.info(), return a table of key/value * pairs containing the current info. @@ -180,6 +190,7 @@ static int lbox_info_call(struct lua_State *L) { lua_newtable(L); + lbox_info_init_static_values(L); for (int i = 0; lbox_info_dynamic_meta[i].name; i++) { lua_pushstring(L, lbox_info_dynamic_meta[i].name); lbox_info_dynamic_meta[i].func(L); @@ -217,5 +228,7 @@ box_lua_info_init(struct lua_State *L) lua_setmetatable(L, -2); + lbox_info_init_static_values(L); + lua_pop(L, 1); /* info module */ } diff --git a/test/box/admin.result b/test/box/admin.result index 681bf5834f3618afcc50d153d880eb28095223fd..10cd74f25e39ee59064735ee184d182a19a9a4c2 100644 --- a/test/box/admin.result +++ b/test/box/admin.result @@ -68,7 +68,7 @@ end; function test_box_info() local tmp = box.info() local num = {'pid', 'snapshot_pid', 'recovery_last_update', 'recovery_lag', 'uptime'} - local str = {'status' } + local str = {'version', 'status' } local failed = {} if check_type(tmp.server, 'table') == false then table.insert(failed1, 'box.info().server') diff --git a/test/box/admin.test.lua b/test/box/admin.test.lua index d973fb424cbf07f2f4be881d369a93c4c36785a6..e070545a7fba810b4ea9ae5516052327a6033af0 100644 --- a/test/box/admin.test.lua +++ b/test/box/admin.test.lua @@ -20,7 +20,7 @@ end; function test_box_info() local tmp = box.info() local num = {'pid', 'snapshot_pid', 'recovery_last_update', 'recovery_lag', 'uptime'} - local str = {'status' } + local str = {'version', 'status' } local failed = {} if check_type(tmp.server, 'table') == false then table.insert(failed1, 'box.info().server') diff --git a/test/box/info.result b/test/box/info.result index a7ef13cd07df82370af45d8bfaf00f25e8fb7163..c630c8eeca932ee4b72221ea1a62f698be77c9e1 100644 --- a/test/box/info.result +++ b/test/box/info.result @@ -12,6 +12,10 @@ box.info['unknown_variable'] --- - null ... +string.match(box.info.version, '^[1-9]') ~= nil +--- +- true +... string.match(box.info.pid, '^[1-9][0-9]*$') ~= nil --- - true @@ -60,6 +64,7 @@ t - status - uptime - vclock + - version ... box.info.snapshot_pid --- diff --git a/test/box/info.test.lua b/test/box/info.test.lua index 5dc3e2c1572015013494ad1d4a7b48f39fa51593..6edb102e47d0c0d978cd3ed265e6711cb28cef07 100644 --- a/test/box/info.test.lua +++ b/test/box/info.test.lua @@ -3,6 +3,7 @@ box.info.unknown_variable box.info[23] box.info['unknown_variable'] +string.match(box.info.version, '^[1-9]') ~= nil string.match(box.info.pid, '^[1-9][0-9]*$') ~= nil #box.info.server > 0 box.info.recovery_lag