Top.Mail.Ru
Class luatest.server | Tarantool
Tarantool
Узнайте содержание релиза 2.8

Class luatest.server

Class luatest.server

Class to run tarantool instance.

Methods

Generates environment to run process with. The result is merged into os.environ().

Returns:

map

Call remote function on the server by name.

This is a shortcut for server.net_box:call() .

Parameters:

  • fn_name: (string)
  • args: (tab) (optional)
  • options: (tab) (optional)

Establish net.box connection. It’s available in net_box field.

Evaluate Lua code on the server.

This is a shortcut for server.net_box:eval() .

Parameters:

  • code: (string)
  • args: (tab) (optional)
  • options: (tab) (optional)

Run given function on the server.

Much like Server:eval , but takes a function instead of a string. The executed function must have no upvalues (closures). Though it may use global functions and modules (like box , os , etc.)

Parameters:

  • fn: (function)
  • args: (tab) (optional)
  • options: (tab) (optional)

local vclock = server:exec(function()
    return box.info.vclock
end)

local sum = server:exec(function(a, b)
    return a + b
end, {1, 2})
-- sum == 3

server:exec(function()
    local t = require('luatest')
    t.assert_equals(math.pi, 3)
end)
-- mytest.lua:12: expected: 3, actual: 3.1415926535898

Perform HTTP request.

Parameters:

  • method: (string)
  • path: (string)
  • options:
    • body: (string) request body (optional)
    • json: data to encode as JSON into request body (optional)
    • http: (tab) other options for HTTP-client (optional)
    • raise: (bool) raise error when status is not in 200..299. Default to true. (optional)

Returns:

response object from HTTP client with helper methods.

Raises:

HTTPRequest error when response status is not 200.

See also:

  • luatest.http_response

Build server object.

Parameters:

  • object:
    • command: (string) Command to start server process.
    • workdir: (string) Value to be passed in TARANTOOL_WORKDIR .
    • chdir: (string) Path to cwd before running a process. (optional)
    • env: (tab) Table to pass as env variables to process. (optional)
    • args: (tab) Args to run command with. (optional)
    • http_port: (int) Value to be passed in TARANTOOL_HTTP_PORT and used to perform HTTP requests. (optional)
    • net_box_port: (int) Value to be passed in TARANTOOL_LISTEN and used for net_box connection. (optional)
    • net_box_credentials: (tab) Override default net_box credentials. (optional)
    • alias: (string) Instance alias. Used to prefix output. (optional)

Returns:

input object.

Restart server process.

Parameters:

  • params:

Start server process.

Stop server process.