node_ops: use user task ttl for node ops virtual task

Use user task ttl for node ops virtual task. Modify the test accordingly.
This commit is contained in:
Aleksandra Martyniuk
2024-11-07 12:28:23 +01:00
parent 6241d49b64
commit e703ba08f8
3 changed files with 8 additions and 2 deletions

View File

@@ -143,7 +143,7 @@ future<> node_ops_virtual_task::abort(tasks::task_id id) noexcept {
future<std::vector<tasks::task_stats>> node_ops_virtual_task::get_stats() {
db::system_keyspace& sys_ks = _ss._sys_ks.local();
service::topology& topology = _ss._topology_state_machine._topology;
co_return boost::copy_range<std::vector<tasks::task_stats>>(co_await get_entries(sys_ks, topology, get_task_manager().get_task_ttl())
co_return boost::copy_range<std::vector<tasks::task_stats>>(co_await get_entries(sys_ks, topology, get_task_manager().get_user_task_ttl())
| boost::adaptors::transformed([] (const auto& e) {
auto id = e.first;
auto& entry = e.second;

View File

@@ -58,6 +58,12 @@ class TaskManagerClient():
assert(type(old_ttl) == int)
return old_ttl
async def set_user_task_ttl(self, node_ip: IPAddress, ttl: int) -> int:
"""Set task ttl and get old value."""
old_ttl = await self.api.client.post_json("/task_manager/user_ttl", params={ "user_ttl": str(ttl) }, host=node_ip)
assert(type(old_ttl) == int)
return old_ttl
async def get_task_status_recursively(self, node_ip: IPAddress, task_id: TaskID) -> list[TaskStatus]:
"""Get status of a task and all its descendants."""
status_list = await self.api.client.get_json(f"/task_manager/task_status_recursive/{task_id}", host=node_ip)

View File

@@ -222,7 +222,7 @@ async def test_node_ops_tasks_ttl(manager: ManagerClient):
tm = TaskManagerClient(manager.api)
servers = [await manager.server_add() for _ in range(2)]
[await tm.set_task_ttl(server.ip_addr, 3) for server in servers]
[await tm.set_user_task_ttl(server.ip_addr, 3) for server in servers]
time.sleep(3)
await get_new_virtual_tasks_statuses(tm, module_name, servers, [], expected_task_num=0)