test/pylib: manager[_client]: add update_cmdline()

Similar to the existing update_config(). Updates the command-line
arguments of the specified nodes, merging the new options into the
existing ones. Needs a restart to take effect.
This commit is contained in:
Botond Dénes
2024-01-29 06:59:36 -05:00
parent 8a439fc2a8
commit a7a5aada2a
2 changed files with 28 additions and 0 deletions

View File

@@ -342,6 +342,10 @@ class ManagerClient():
await self.client.put_json(f"/cluster/server/{server_id}/update_config",
{"key": key, "value": value})
async def server_update_cmdline(self, server_id: ServerNum, cmdline_options: List[str]) -> None:
await self.client.put_json(f"/cluster/server/{server_id}/update_cmdline",
{"cmdline_options": cmdline_options})
async def server_change_ip(self, server_id: ServerNum) -> IPAddress:
"""Change server IP address. Applicable only to a stopped server"""
ret = await self.client.put_json(f"/cluster/server/{server_id}/change_ip", {},

View File

@@ -341,6 +341,11 @@ class ScyllaServer:
if self.cmd:
self.cmd.send_signal(signal.SIGHUP)
def update_cmdline(self, cmdline_options: List[str]) -> None:
"""Update the command-line options by merging the new options into the existing ones.
Takes effect only after the node is restarted."""
self.cmdline_options = merge_cmdline_options(self.cmdline_options, cmdline_options)
def take_log_savepoint(self) -> None:
"""Save the server current log size when a test starts so that if
the test fails, we can only capture the relevant lines of the log"""
@@ -992,6 +997,15 @@ class ScyllaCluster:
self.is_dirty = True
self.servers[server_id].update_config(key, value)
def update_cmdline(self, server_id: ServerNum, cmdline_options: List[str]) -> None:
"""Update the command-line options of the given server by merging the new options into the existing ones.
The update only takes effect after restart.
Marks the cluster as dirty.
Fails if the server cannot be found."""
assert server_id in self.servers, f"Server {server_id} unknown"
self.is_dirty = True
self.servers[server_id].update_cmdline(cmdline_options)
def setLogger(self, logger: logging.LoggerAdapter):
"""Change the logger used by the cluster.
Called when a cluster is reused between tests so that logs during the new test
@@ -1165,6 +1179,7 @@ class ScyllaClusterManager:
add_put('/cluster/rebuild-node/{server_id}', self._cluster_rebuild_node)
add_get('/cluster/server/{server_id}/get_config', self._server_get_config)
add_put('/cluster/server/{server_id}/update_config', self._server_update_config)
add_put('/cluster/server/{server_id}/update_cmdline', self._server_update_cmdline)
add_put('/cluster/server/{server_id}/change_ip', self._server_change_ip)
add_put('/cluster/server/{server_id}/change_rpc_address', self._server_change_rpc_address)
add_get('/cluster/server/{server_id}/get_log_filename', self._server_get_log_filename)
@@ -1397,6 +1412,15 @@ class ScyllaClusterManager:
self.cluster.update_config(ServerNum(int(request.match_info["server_id"])),
data['key'], data['value'])
async def _server_update_cmdline(self, request: aiohttp.web.Request) -> None:
"""Update the command-line options of the given server by merging the new options into the existing ones.
The update only takes effect after restart.
Marks the cluster as dirty."""
assert self.cluster
data = await request.json()
self.cluster.update_cmdline(ServerNum(int(request.match_info["server_id"])),
data['cmdline_options'])
async def _server_change_ip(self, request: aiohttp.web.Request) -> dict[str, object]:
"""Pass change_ip command for the given server to the cluster"""
assert self.cluster