File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313### Fixed
1414
1515- Removing the server if it is not in use (#212 ).
16+ - Changing server address if it was edited (#209 ).
1617
1718## [ 1.7.0] - 2024-11-15
1819
Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ local function apply_http(name, node)
9999 httpd = httpd ,
100100 routes = {},
101101 }
102+ elseif servers [name ].host ~= host or servers [name ].port ~= port then
103+ servers [name ].httpd :stop ()
104+ servers [name ].httpd = http_server .new (host , port , parse_params (node ))
105+ servers [name ].httpd :start ()
102106 end
103107end
104108
Original file line number Diff line number Diff line change @@ -129,3 +129,20 @@ g.test_stop_server_after_remove = function(cg)
129129
130130 t .assert_not (helpers .tcp_connection_exists (' localhost' , 13001 ))
131131end
132+
133+ g .test_change_server_addr_on_the_run = function (cg )
134+ local resp = http_client :get (' http://0.0.0.0:13001/ping' )
135+ t .assert_equals (resp .status , 200 , ' response not 200' )
136+ t .assert_equals (resp .body , ' pong' )
137+
138+ local cfg = table .deepcopy (config )
139+ cfg .groups [' group-001' ].replicasets [' replicaset-001' ].roles_cfg [' roles.httpd' ].additional .listen = ' localhost:13001'
140+ treegen .write_file (cg .server .chdir , ' config.yaml' , yaml .encode (cfg ))
141+ local _ , err = cg .server :eval (" require('config'):reload()" )
142+ t .assert_not (err )
143+
144+ t .assert_not (helpers .tcp_connection_exists (' 0.0.0.0' , 13001 ))
145+ resp = http_client :get (' http://localhost:13001/ping' )
146+ t .assert_equals (resp .status , 200 , ' response not 200' )
147+ t .assert_equals (resp .body , ' pong' )
148+ end
Original file line number Diff line number Diff line change @@ -291,3 +291,23 @@ g.test_stop_unused_servers = function()
291291 t .assert (httpd_role .get_server ())
292292 t .assert_equals (httpd_role .get_server (' additional' ))
293293end
294+
295+ g .test_edit_server_address = function ()
296+ local cfg = {
297+ [httpd_role .DEFAULT_SERVER_NAME ] = {
298+ listen = 13001 ,
299+ },
300+ }
301+
302+ httpd_role .apply (cfg )
303+ local result = httpd_role .get_server ()
304+ t .assert (result )
305+ t .assert_equals (result .port , cfg [httpd_role .DEFAULT_SERVER_NAME ].listen )
306+
307+ cfg [httpd_role .DEFAULT_SERVER_NAME ].listen = 13002
308+
309+ httpd_role .apply (cfg )
310+ result = httpd_role .get_server ()
311+ t .assert (result )
312+ t .assert_equals (result .port , cfg [httpd_role .DEFAULT_SERVER_NAME ].listen )
313+ end
You can’t perform that action at this time.
0 commit comments