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-18617 Allow use of ClusterInstance inside BeforeEach #18662

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

Conversation

mumrah
Copy link
Member

@mumrah mumrah commented Jan 21, 2025

Move the ClusterTest setup callback to BeforeEachCallback instead of BeforeTestExecutionCallback. This allows the setup to happen slightly earlier and before any @BeforeEach methods are invoked.

We cannot inject ClusterInstance into a @BeforeEach method, but we can still use the constructor injection which allows a @BeforeEach fixture to access the ClusterInstance. This enables tests to do some common cluster setup (like creating topics) before each test case.

No changes were made to @AfterEach or our ClusterTest teardown logic.

@github-actions github-actions bot added tests Test fixes (including flaky tests) small Small PRs labels Jan 21, 2025
@@ -0,0 +1,38 @@
package org.apache.kafka.common.test.api;

import org.junit.jupiter.api.BeforeEach;
Copy link
Contributor

Choose a reason for hiding this comment

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

license missing

@mumrah mumrah requested a review from cmccabe January 22, 2025 23:42
@mumrah
Copy link
Member Author

mumrah commented Jan 22, 2025

@cmccabe can you take a quick look at this one?

@mumrah
Copy link
Member Author

mumrah commented Jan 23, 2025

This should probably go in after #18602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
small Small PRs tests Test fixes (including flaky tests)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants