Files
scylladb/test/nodetool/test_cleanup.py
Avi Kivity f3eade2f62 treewide: relicense to ScyllaDB-Source-Available-1.0
Drop the AGPL license in favor of a source-available license.
See the blog post [1] for details.

[1] https://www.scylladb.com/2024/12/18/why-were-moving-to-a-source-available-license/
2024-12-18 17:45:13 +02:00

69 lines
2.9 KiB
Python

#
# Copyright 2023-present ScyllaDB
#
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
#
from test.nodetool.rest_api_mock import expected_request
from test.nodetool.utils import check_nodetool_fails_with
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):
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),
])