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

KAFKA-18276 Migrate RebootstrapTest to new test infra #19046

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

clarkwtc
Copy link
Contributor

Migrate RebootstrapTest to new test infra and remove the old Scala test.

The test results
Screenshot 2025-02-27 at 9 05 52 AM

@github-actions github-actions bot added triage PRs from the community core Kafka Broker tests Test fixes (including flaky tests) labels Feb 27, 2025
Copy link
Contributor

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

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

Thanks for @clarkwtc, left some comments.

public void testRebootstrap(ClusterInstance clusterInstance) throws ExecutionException, InterruptedException {
String topic = "topic";
try (Admin admin = clusterInstance.admin()) {
admin.createTopics(Collections.singletonList(new NewTopic(topic, BROKER_COUNT, (short) 2))).all().get();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use List.of() instead Collections.singletonList, and I don't think we need to get the future value.

admin.createTopics(List.of(new NewTopic(topic, BROKER_COUNT, (short) 2)));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your comments.
Sure, we don't need to get any future value.

@ClusterTemplate(value = "generator")
public void testRebootstrap(ClusterInstance clusterInstance) throws ExecutionException, InterruptedException {
String topic = "topic";
try (Admin admin = clusterInstance.admin()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Variables should be declared using var to maintain consistency throughout the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed it to maintain consistency by using var.


try (var producer = clusterInstance.producer()) {
// Only the server 0 is available for the producer during the bootstrap.
RecordMetadata recordMetadata0 = producer.send(new ProducerRecord<>(topic, part, "key 1".getBytes(), "value 1".getBytes())).get();
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto: Variables should be declared using var to maintain consistency throughout the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed it to maintain consistency by using var.

// Current server 0 is offline.
// However, the server 1 from the bootstrap list is online.
// Should be able to produce records.
RecordMetadata recordMetadata1 = producer.send(new ProducerRecord<>(topic, part, "key 1".getBytes(), "value 1".getBytes())).get();
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto: Variables should be declared using var to maintain consistency throughout the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed it to maintain consistency by using var.

server0.startup();

// The same situation, but the server 1 has gone and server 0 is back.
RecordMetadata recordMetadata2 = producer.send(new ProducerRecord<>(topic, part, "key 1".getBytes(), "value 1".getBytes())).get();
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto: Variables should be declared using var to maintain consistency throughout the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed it to maintain consistency by using var.

Comment on lines 90 to 91
KafkaBroker server0 = clusterInstance.brokers().get(0);
KafkaBroker server1 = clusterInstance.brokers().get(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto: Variables should be declared using var to maintain consistency throughout the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed it to maintain consistency by using var.

Comment on lines 61 to 69
properties.put("metadata.recovery.rebootstrap.trigger.ms", "5000");
} else {
properties.put("metadata.recovery.rebootstrap.trigger.ms", "3600000");
properties.put("socket.connection.setup.timeout.ms", "5000");
properties.put("socket.connection.setup.timeout.max.ms", "5000");
properties.put("reconnect.backoff.ms", "1000");
properties.put("reconnect.backoff.max.ms", "1000");
}
properties.put("metadata.recovery.strategy", "rebootstrap");
Copy link
Contributor

Choose a reason for hiding this comment

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

We could use CommonClientConfigs.METADATA_RECOVERY_REBOOTSTRAP_TRIGGER_MS_CONFIG instead of plaintext, other configs are same.

Copy link
Contributor Author

@clarkwtc clarkwtc Feb 27, 2025

Choose a reason for hiding this comment

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

I can't do it because the styleAction check blocks the reference byCommonClientConfigs in tests.
I only just wrote it in plaintext.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can relax the conditions for core module import-control.

Copy link
Contributor Author

@clarkwtc clarkwtc Feb 28, 2025

Choose a reason for hiding this comment

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

Thank you, the method effectively relaxes the conditions.
I have tested to update the org.apache.kafka.clients pkg in import-control-core.xml.
Is it okay to submit this change directly on commit?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's not a problem.

@github-actions github-actions bot removed the triage PRs from the community label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Kafka Broker tests Test fixes (including flaky tests)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants