Skip to content

Commit

Permalink
test/cql-pytest/nodetool.py: no_autocompaction_context: use the corre…
Browse files Browse the repository at this point in the history
…ct API

This `with` context is supposed to disable, then re-enable
autocompaction for the given keyspaces, but it used the wrong API for
it, it used the column_family/autocompaction API, which operates on
column families, not keyspaces. This oversight led to a silent failure
because the code didn't check the result of the request.
Both are fixed in this patch:
* switch to use `storage_service/auto_compaction/{keyspace}` endpoint
* check the result of the API calls and report errors as exceptions

Fixes: #13553

Closes #13568
  • Loading branch information
denesb authored and nyh committed Apr 20, 2023
1 parent 8d7b5f1 commit 66ee736
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/cql-pytest/nodetool.py
Expand Up @@ -118,13 +118,17 @@ def __init__(self, cql, *keyspaces):
def __enter__(self):
for ks in self._keyspaces:
if has_rest_api(self._cql):
requests.delete(f'{rest_api_url(self._cql)}/column_family/autocompaction/{ks}')
ret = requests.delete(f'{rest_api_url(self._cql)}/storage_service/auto_compaction/{ks}')
if not ret.ok:
raise RuntimeError(f"failed to disable autocompaction: {ret.text}")
else:
run_nodetool(self._cql, "disableautocompaction", ks)

def __exit__(self, exc_type, exc_value, exc_traceback):
for ks in self._keyspaces:
if has_rest_api(self._cql):
requests.post(f'{rest_api_url(self._cql)}/column_family/autocompaction/{ks}')
ret = requests.post(f'{rest_api_url(self._cql)}/storage_service/auto_compaction/{ks}')
if not ret.ok:
raise RuntimeError(f"failed to re-enable autocompaction: {ret.text}")
else:
run_nodetool(self._cql, "enableautocompaction", ks)

0 comments on commit 66ee736

Please sign in to comment.