Skip to content

Commit 18fb2ee

Browse files
Fix no httpd service in cartridge (#238)
* Fix no httpd service in cartridge Co-authored-by: Tyubek Vasiliy <[email protected]>
1 parent c00e60d commit 18fb2ee

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Fixed
99
- cpu metrics hot reload [#228](https://github.com/tarantool/metrics/issues/228)
10+
- cartridge metrics role fails to start without http [#225](https://github.com/tarantool/metrics/issues/225)
1011

1112
## [0.8.0] - 2021-04-13
1213
### Added

cartridge/roles/metrics.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ local current_paths = {}
8484

8585
local function apply_routes(export)
8686
local httpd = cartridge.service_get('httpd')
87+
if httpd == nil then
88+
return
89+
end
8790
for _, exporter in ipairs(export) do
8891
local path, format = remove_side_slashes(exporter.path), exporter.format
8992
if current_paths[path] ~= format then
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
local fio = require('fio')
2+
local t = require('luatest')
3+
local g = t.group('cartridge-without-http')
4+
5+
local helpers = require('test.helper')
6+
7+
local function set_export(cluster, export)
8+
local server = cluster.main_server
9+
return server.net_box:eval([[
10+
local cartridge = require('cartridge')
11+
local metrics = cartridge.service_get('metrics')
12+
local _, err = pcall(
13+
metrics.set_export, ...
14+
)
15+
return err
16+
]], {export})
17+
end
18+
19+
20+
g.test_http_disabled = function()
21+
t.skip_if(type(helpers) ~= 'table', 'Skip cartridge test')
22+
local cluster = helpers.Cluster:new({
23+
datadir = fio.tempdir(),
24+
server_command = helpers.entrypoint('srv_basic'),
25+
replicasets = {
26+
{
27+
uuid = helpers.uuid('a'),
28+
roles = {},
29+
servers = {
30+
{instance_uuid = helpers.uuid('a', 1), alias = 'main'},
31+
},
32+
},
33+
},
34+
})
35+
cluster:start()
36+
37+
local server = cluster.main_server
38+
39+
server.net_box:eval([[
40+
local cartridge = require('cartridge')
41+
_G.old_service = cartridge.service_get('httpd')
42+
cartridge.service_set('httpd', nil)
43+
]])
44+
45+
local ret = set_export(cluster, {
46+
{
47+
path = '/metrics',
48+
format = 'json',
49+
},
50+
})
51+
t.assert_not(ret)
52+
53+
cluster:stop()
54+
fio.rmtree(cluster.datadir)
55+
end

0 commit comments

Comments
 (0)