Files
scylladb/test/nodetool/test_cleanup.py
Kefu Chai a9d781d70f test/nodetool: only test "storage_service/cleanup_all" with scylla
this RESTful API is a scylla specific extension and is only used
by scylla-nodetool. currently, the java-based nodetool does not use
it at all, so mark it with "scylla_only".

one can verify this change with:
```
pytest --mode=debug --nodetool=cassandra test_cleanup.py::test_cleanup
```

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17001
2024-01-26 13:19:15 +02:00

69 lines
2.8 KiB
Python

#
# Copyright 2023-present ScyllaDB
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
from rest_api_mock import expected_request
import utils
def test_cleanup(nodetool, scylla_only):
nodetool("cleanup", expected_requests=[
expected_request("POST", "/storage_service/cleanup_all", response=0),
])
def test_cleanup_keyspace(nodetool):
nodetool("cleanup", "ks1", expected_requests=[
expected_request("GET", "/storage_service/keyspaces", multiple=expected_request.MULTIPLE,
response=["ks1", "ks2", "system"]),
expected_request("POST", "/storage_service/keyspace_cleanup/ks1", response=0),
])
def test_cleanup_table(nodetool):
nodetool("cleanup", "ks1", "tbl1", expected_requests=[
expected_request("GET", "/storage_service/keyspaces", multiple=expected_request.MULTIPLE,
response=["ks1", "ks2", "system"]),
expected_request("POST", "/storage_service/keyspace_cleanup/ks1", params={"cf": "tbl1"}, response=0),
])
def test_cleanup_tables(nodetool):
nodetool("cleanup", "ks1", "tbl1", "tbl2", "tbl3", expected_requests=[
expected_request("GET", "/storage_service/keyspaces", multiple=expected_request.MULTIPLE,
response=["ks1", "ks2", "system"]),
expected_request("POST", "/storage_service/keyspace_cleanup/ks1", params={"cf": "tbl1,tbl2,tbl3"}, response=0),
])
def test_cleanup_nonexistent_keyspace(nodetool):
utils.check_nodetool_fails_with(
nodetool,
("cleanup", "non_existent_ks"),
{"expected_requests": [
expected_request("GET", "/storage_service/keyspaces", response=["ks1", "ks2", "system"])]},
["nodetool: Keyspace [non_existent_ks] does not exist.",
"error processing arguments: keyspace non_existent_ks does not exist"])
def test_cleanup_jobs_arg(nodetool):
nodetool("cleanup", "ks1", "-j", "0", expected_requests=[
expected_request("GET", "/storage_service/keyspaces", multiple=expected_request.MULTIPLE,
response=["ks1", "ks2", "system"]),
expected_request("POST", "/storage_service/keyspace_cleanup/ks1", response=0),
])
nodetool("cleanup", "ks1", "--jobs", "2", expected_requests=[
expected_request("GET", "/storage_service/keyspaces", multiple=expected_request.MULTIPLE,
response=["ks1", "ks2", "system"]),
expected_request("POST", "/storage_service/keyspace_cleanup/ks1", response=0),
])
nodetool("cleanup", "ks1", "--jobs=1", expected_requests=[
expected_request("GET", "/storage_service/keyspaces", multiple=expected_request.MULTIPLE,
response=["ks1", "ks2", "system"]),
expected_request("POST", "/storage_service/keyspace_cleanup/ks1", response=0),
])