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

Fix no httpd service in cartridge #238

Merged
merged 3 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- cpu metrics hot reload [#228](https://github.com/tarantool/metrics/issues/228)
- cartridge metrics role fails to start without http [#225](https://github.com/tarantool/metrics/issues/225)

## [0.8.0] - 2021-04-13
### Added
Expand Down
3 changes: 3 additions & 0 deletions cartridge/roles/metrics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ local current_paths = {}

local function apply_routes(export)
local httpd = cartridge.service_get('httpd')
if httpd == nil then
return
end
for _, exporter in ipairs(export) do
local path, format = remove_side_slashes(exporter.path), exporter.format
if current_paths[path] ~= format then
Expand Down
55 changes: 55 additions & 0 deletions test/integration/cartridge_nohttp_test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
local fio = require('fio')
local t = require('luatest')
local g = t.group('cartridge-without-http')

local helpers = require('test.helper')

local function set_export(cluster, export)
local server = cluster.main_server
return server.net_box:eval([[
local cartridge = require('cartridge')
local metrics = cartridge.service_get('metrics')
local _, err = pcall(
metrics.set_export, ...
)
return err
]], {export})
end


g.test_http_disabled = function()
t.skip_if(type(helpers) ~= 'table', 'Skip cartridge test')
local cluster = helpers.Cluster:new({
vasiliy-t marked this conversation as resolved.
Show resolved Hide resolved
datadir = fio.tempdir(),
server_command = helpers.entrypoint('srv_basic'),
replicasets = {
{
uuid = helpers.uuid('a'),
roles = {},
servers = {
{instance_uuid = helpers.uuid('a', 1), alias = 'main'},
},
},
},
})
cluster:start()

local server = cluster.main_server

server.net_box:eval([[
local cartridge = require('cartridge')
_G.old_service = cartridge.service_get('httpd')
cartridge.service_set('httpd', nil)
]])

local ret = set_export(cluster, {
{
path = '/metrics',
format = 'json',
},
})
t.assert_not(ret)

cluster:stop()
fio.rmtree(cluster.datadir)
end