Skip to content

Commit

Permalink
tests: replaces two actions with placeholders
Browse files Browse the repository at this point in the history
This changeset will focus on making the processkill action usable.
The actions to decommission nodes and leadership transfer will be
implemented in separate pull requests.
  • Loading branch information
abhijat committed Apr 27, 2022
1 parent bfff79c commit 31df1a8
Showing 1 changed file with 8 additions and 58 deletions.
66 changes: 8 additions & 58 deletions tests/rptest/services/action_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,41 +137,17 @@ def restore_state_on_exit(self, action_log: List[ActionLogEntry]):


class NodeDecommission(DisruptiveAction):
def __init__(
self,
redpanda: RedpandaService,
config: ActionConfig,
admin: Admin,
):
super().__init__(redpanda, config, admin)

def max_affected_nodes_reached(self):
return len(self.affected_nodes) >= self.config.max_affected_nodes

def do_action(self) -> ClusterNode:
brokers = self.admin.get_brokers()
node_to_decommission = random.choice(brokers)

broker_id = node_to_decommission['node_id']
self.redpanda.logger.warn(f'going to decom broker id {broker_id}')
self.admin.decommission_broker(id=node_to_decommission['node_id'])

def done():
return broker_id not in {
b['node_id']
for b in self.admin.get_brokers()
}

wait_until(done,
timeout_sec=120,
backoff_sec=2,
err_msg=f'Failed to decommission broker id {broker_id}')
self.affected_nodes.add(broker_id)
self.last_affected_node = broker_id
return self.last_affected_node

def do_reverse_action(self) -> ClusterNode:
self.admin.recommission_broker(self.last_affected_node)
self.affected_nodes.remove(self.last_affected_node)

last_affected_node, self.last_affected_node = self.last_affected_node, None
return last_affected_node

def do_restore_nodes(self, nodes_to_restore: Set[ClusterNode]):
pass


class LeadershipTransfer(DisruptiveAction):
def __init__(
Expand All @@ -188,32 +164,6 @@ def __init__(
def max_affected_nodes_reached(self):
return False

def do_action(self):
for topic in self.topics:
for partition in range(topic.partition_count):
old_leader = self.admin.get_partition_leader(
namespace='kafka', topic=topic, partition=partition)
self.admin.transfer_leadership_to(namespace='kafka',
topic=topic,
partition=partition,
target=None)

def leader_is_changed():
new_leader = self.admin.get_partition_leader(
namespace='kafka', topic=topic, partition=partition)
return new_leader != -1 and new_leader != old_leader

wait_until(leader_is_changed,
timeout_sec=30,
backoff_sec=2,
err_msg='Leadership transfer failed')

def do_reverse_action(self):
raise NotImplementedError('Leadership transfer is not reversible')

def do_restore_nodes(self, nodes_to_restore: Set[ClusterNode]):
pass


class ProcessKill(DisruptiveAction):
def __init__(self, redpanda: RedpandaService, config: ActionConfig,
Expand Down

0 comments on commit 31df1a8

Please sign in to comment.