97ab3f6622 changed "nodetool cleanup" (without arguments) to run
cleanup on all dirty nodes in the cluster. This was somewhat unexpected,
so this patch changes it back to run cleanup on the target node only (and
reset "cleanup needed" flag afterwards) and it adds "nodetool cluster
cleanup" command that runs the cleanup on all dirty nodes in the
cluster.
74 lines
3.1 KiB
Python
74 lines
3.1 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/", params={"global": "false"}, response=0),
|
|
])
|
|
|
|
|
|
def test_cleanup_global(nodetool, scylla_only):
|
|
nodetool("cluster", "cleanup", expected_requests=[
|
|
expected_request("POST", "/storage_service/cleanup_all/", params={"global": "true"}, 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),
|
|
])
|