From 6b85da3ce301bdbfa5defa18737eadfcaac8338e Mon Sep 17 00:00:00 2001 From: Piotr Smaron Date: Fri, 3 Apr 2026 11:42:22 +0200 Subject: [PATCH] test: fix snapshot cleanup helper The snapshot REST helper cleaned up multi-table snapshots with a single DELETE request that passed a comma-separated cf filter, but the API accepts only one table name there. Delete each table snapshot separately so existing tests that snapshot multiple tables use the API as documented. --- test/rest_api/rest_util.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/rest_api/rest_util.py b/test/rest_api/rest_util.py index e9a9786e36..6fb9913e87 100644 --- a/test/rest_api/rest_util.py +++ b/test/rest_api/rest_util.py @@ -16,6 +16,7 @@ def new_test_snapshot(rest_api, keyspaces=[], tables=[], tag=""): if not tag: tag = f"test_snapshot_{int(time.time() * 1000)}" params = { "tag": tag } + delete_params = [] if type(keyspaces) is str: params["kn"] = keyspaces else: @@ -23,15 +24,22 @@ def new_test_snapshot(rest_api, keyspaces=[], tables=[], tag=""): if tables: if type(tables) is str: params["cf"] = tables + delete_params.append(dict(params)) else: params["cf"] = ",".join(tables) + # DELETE /storage_service/snapshots accepts a single table name. + # When the snapshot spans multiple tables, clean it up per table. + delete_params.extend([{**params, "cf": table} for table in tables]) + else: + delete_params.append(dict(params)) resp = rest_api.send("POST", "storage_service/snapshots", params) resp.raise_for_status() try: yield tag finally: - resp = rest_api.send("DELETE", "storage_service/snapshots", params) - resp.raise_for_status() + for delete_param in delete_params: + resp = rest_api.send("DELETE", "storage_service/snapshots", delete_param) + resp.raise_for_status() # Tries to inject an error via Scylla REST API. It only works in specific # build modes (dev, debug, sanitize), so this function will trigger a test