From a7a5aada2a0af246722f8eb2b3b784c8006ff55c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Mon, 29 Jan 2024 06:59:36 -0500 Subject: [PATCH] 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. --- test/pylib/manager_client.py | 4 ++++ test/pylib/scylla_cluster.py | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/test/pylib/manager_client.py b/test/pylib/manager_client.py index bc36521d8a..56e7522ee3 100644 --- a/test/pylib/manager_client.py +++ b/test/pylib/manager_client.py @@ -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", {}, diff --git a/test/pylib/scylla_cluster.py b/test/pylib/scylla_cluster.py index 1437d3c348..20779e17c4 100644 --- a/test/pylib/scylla_cluster.py +++ b/test/pylib/scylla_cluster.py @@ -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