Skip to content

Commit

Permalink
admin: rename target to target_id
Browse files Browse the repository at this point in the history
  • Loading branch information
rystsov committed Jun 23, 2022
1 parent 68848c1 commit 1064521
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
9 changes: 6 additions & 3 deletions tests/rptest/services/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,18 @@ def get_partition_leader(self, *, namespace, topic, partition, node=None):

return partition_info['leader_id']

def transfer_leadership_to(self, *, namespace, topic, partition, target):
def transfer_leadership_to(self,
*,
namespace,
topic,
partition,
target_id=None):
"""
Looks up current ntp leader and transfer leadership to target node,
this operations is NOP when current leader is the same as target.
If user pass None for target this function will choose next replica for new leader.
If leadership transfer was performed this function return True
"""
target_id = self.redpanda.idx(target) if isinstance(
target, ClusterNode) else target

# check which node is current leader

Expand Down
11 changes: 6 additions & 5 deletions tests/rptest/tests/group_membership_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _transfer_with_retry(self, namespace, topic, partition, target_id):
admin.transfer_leadership_to(namespace=namespace,
topic=topic,
partition=partition,
target=target_id)
target_id=target_id)
except requests.exceptions.HTTPError as e:
if e.response.status_code == 503:
time.sleep(1)
Expand Down Expand Up @@ -321,10 +321,11 @@ def transfer_leadership(new_leader):
"""
self.logger.debug(
f"Transferring leadership to {new_leader.account.hostname}")
admin.transfer_leadership_to(namespace="kafka",
topic="__consumer_offsets",
partition=0,
target=self.redpanda.idx(new_leader))
admin.transfer_leadership_to(
namespace="kafka",
topic="__consumer_offsets",
partition=0,
target_id=self.redpanda.idx(new_leader))
for _ in range(3): # re-check a few times
leader = get_group_leader()
self.logger.debug(f"Current leader: {leader}")
Expand Down
2 changes: 1 addition & 1 deletion tests/rptest/tests/prefix_truncate_recovery_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def verify_offsets(self):
admin.transfer_leadership_to(namespace="kafka",
topic=self.topic,
partition=0,
target=node)
target_id=self.redpanda.idx(node))
# % ERROR: offsets_for_times failed: Local: Unknown partition
# may occur here presumably because there is an interaction
# with leadership transfer. the built-in retries in list_offsets
Expand Down
2 changes: 1 addition & 1 deletion tests/rptest/tests/tx_admin_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_expired_transaction(self):
self.admin.transfer_leadership_to(namespace="kafka",
topic=topic,
partition=partition,
target=None)
target_id=None)

def leader_is_changed():
new_leader = self.admin.get_partition_leader(
Expand Down

0 comments on commit 1064521

Please sign in to comment.