Skip to content

Commit b68fb78

Browse files
committed
rptest/services/admin: typify a few functions
list_reconfigurations, get_partition, set_partition_replicas, transfer_leadership_to
1 parent 4ce51fe commit b68fb78

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

tests/rptest/services/admin.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from enum import Enum
1616
from json.decoder import JSONDecodeError
1717
from logging import Logger
18-
from typing import Any, Callable, NamedTuple, Optional, Protocol, cast
18+
from typing import Any, Callable, List, NamedTuple, Optional, Protocol, cast
1919
from uuid import UUID
2020

2121
import requests
@@ -1094,7 +1094,7 @@ def trigger_cores_rebalance(self, node):
10941094

10951095
return self._request("post", path, node=node)
10961096

1097-
def list_reconfigurations(self, node=None):
1097+
def list_reconfigurations(self, node: ClusterNode | None = None):
10981098
"""
10991099
List pending reconfigurations
11001100
"""
@@ -1135,7 +1135,9 @@ def get_partitions(self, topic=None, partition=None, *, namespace=None, node=Non
11351135

11361136
return self._request("get", path, node=node).json()
11371137

1138-
def get_partition(self, ns: str, topic: str, id: int, node=None):
1138+
def get_partition(
1139+
self, ns: str, topic: str, id: int, node: ClusterNode | None = None
1140+
) -> dict[str, Any]:
11391141
return self._request("GET", f"partitions/{ns}/{topic}/{id}", node=node).json()
11401142

11411143
def get_transactions(self, topic, partition, namespace, node=None):
@@ -1193,7 +1195,12 @@ def find_tx_coordinator(self, tid, node=None):
11931195
return self._request("get", path, node=node).json()
11941196

11951197
def set_partition_replicas(
1196-
self, topic, partition, replicas, *, namespace="kafka", node=None
1198+
self,
1199+
topic: str,
1200+
partition: int,
1201+
replicas: List[dict[str, int]],
1202+
namespace: str = "kafka",
1203+
node: ClusterNode | None = None,
11971204
):
11981205
"""
11991206
[ {"node_id": 0, "core": 1}, ... ]
@@ -1402,8 +1409,14 @@ def get_partition_leader(self, *, namespace, topic, partition, node=None):
14021409
return partition_info["leader_id"]
14031410

14041411
def transfer_leadership_to(
1405-
self, *, namespace, topic, partition, target_id=None, leader_id=None
1406-
):
1412+
self,
1413+
*,
1414+
namespace: str,
1415+
topic: str,
1416+
partition: int,
1417+
target_id: int | None = None,
1418+
leader_id: int | None = None,
1419+
) -> bool:
14071420
"""
14081421
Looks up current ntp leader and transfer leadership to target node,
14091422
this operations is NOP when current leader is the same as target.

0 commit comments

Comments
 (0)