Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINOR: update truncation test #18952

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tests/kafkatest/tests/client/truncation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class TruncationTest(VerifiableConsumerTest):
TOPICS = {
TOPIC: {
'partitions': NUM_PARTITIONS,
'replication-factor': 2
'replication-factor': 2,
'configs': {"min.insync.replicas": 1,
"unclean.leader.election.enable": True}
}
}
GROUP_ID = "truncation-test"
Expand Down Expand Up @@ -80,6 +82,9 @@ def test_offset_truncate(self, metadata_quorum, use_new_coordinator):
isr = self.kafka.isr_idx_list(self.TOPIC, 0)
node1 = self.kafka.get_node(isr[0])
self.kafka.stop_node(node1)
wait_until(lambda: len(self.kafka.isr_idx_list(self.TOPIC, 0)) == 1,
timeout_sec=30,
err_msg="The ISR update taking too long")
self.logger.info("Reduced ISR to one node, consumer is at %s", consumer.current_position(tp))

# Ensure remaining ISR member has a little bit of data
Expand Down Expand Up @@ -112,7 +117,10 @@ def none_consumed(this, consumer):

pre_truncation_pos = consumer.current_position(tp)

self.kafka.set_unclean_leader_election(self.TOPIC)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding, why can't we use this one any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_unclean_leader_election sets the unclean.leader.election.enable config to true. It is the same if we set this config when creating the topic.
Creating the topic with the config so that the unclean election can trigger by this event. In the old way, election happens here which is no longer possible if use wait_until to wait for the unclean leader election.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea that it's simpler to create the topic with this configuration than set it later? If so then the answer is "we could still use this, but we don't want to"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is simpler. The unclean.leader.election.enable has to be set before an event that triggers the election. Because I enforce the event sequence in this PR, it is too late to set the config in its original place. So we need to set the config earlier. The option I choose is to set it during the topic creation.

wait_until(lambda: len(self.kafka.isr_idx_list(self.TOPIC, 0)) == 1,
timeout_sec=30,
err_msg="The unclean leader election takes too long")

self.logger.info("New unclean leader, consumer is at %s", consumer.current_position(tp))

# Wait for truncation to be detected
Expand Down