Skip to content

KAFKA-7341 Migrate core module to JUnit 5#9855

Merged
chia7712 merged 24 commits intoapache:trunkfrom
chia7712:KAFKA-7341
Jan 18, 2021
Merged

KAFKA-7341 Migrate core module to JUnit 5#9855
chia7712 merged 24 commits intoapache:trunkfrom
chia7712:KAFKA-7341

Conversation

@chia7712
Copy link
Copy Markdown
Member

@chia7712 chia7712 commented Jan 10, 2021

issue: https://issues.apache.org/jira/browse/KAFKA-7341

This PR includes following changes.

  1. replace org.junit.Assert by org.junit.jupiter.api.Assertions
  2. replace org.junit by org.junit.jupiter.api
  3. remove ScalaTest from core dependencies
  4. replace org.junit.runners.Parameterized by org.junit.jupiter.params.ParameterizedTest
  5. replace org.junit.runners.Parameterized.Parameters by org.junit.jupiter.params.provider.{Arguments, MethodSource}
  6. replace Before by BeforeEach
  7. replace After by AfterEach

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@chia7712 chia7712 requested a review from ijuma January 10, 2021 21:37
Comment thread core/src/test/scala/integration/kafka/admin/BrokerApiVersionsCommandTest.scala Outdated
@ijuma
Copy link
Copy Markdown
Member

ijuma commented Jan 14, 2021

FYI, I started reviewing this so please no force pushes. :)

Comment thread core/src/test/scala/unit/kafka/server/epoch/LeaderEpochFileCacheTest.scala Outdated
@ijuma
Copy link
Copy Markdown
Member

ijuma commented Jan 14, 2021

Quick update: I reviewed over 200 files, so I think I'll be able to complete this later today.

Comment thread build.gradle
Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

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

Went through a few more lines and left more comments. 21 to go. :)

Comment thread core/src/test/scala/unit/kafka/utils/TestUtils.scala
Comment thread core/src/test/scala/integration/kafka/api/PlaintextConsumerTest.scala Outdated
Comment thread core/src/test/scala/integration/kafka/api/PlaintextConsumerTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/admin/TopicCommandWithAdminClientTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/log/LogCleanerIntegrationTest.scala
Comment thread core/src/test/scala/unit/kafka/server/DynamicBrokerConfigTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/ReplicaAlterLogDirsThreadTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/ReplicaFetcherThreadTest.scala Outdated
Comment thread core/src/test/scala/integration/kafka/api/BaseProducerSendTest.scala Outdated
Comment thread core/src/test/scala/integration/kafka/api/ProducerFailureHandlingTest.scala Outdated
Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

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

A few more comments. About 10 files to go.

Comment thread core/src/test/scala/unit/kafka/server/ReplicaFetcherThreadTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/LogDirFailureTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/ClientQuotaManagerTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/ClientQuotaManagerTest.scala Outdated
Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

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

Finally completed the review, hopefully last set of comments below. Thanks for your effort and persistence!

Comment thread core/src/test/scala/unit/kafka/log/LogCleanerParameterizedIntegrationTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/log/LogCleanerParameterizedIntegrationTest.scala Outdated
Comment thread core/src/test/scala/integration/kafka/api/BaseProducerSendTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/admin/TopicCommandWithAdminClientTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/ClientQuotaManagerTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/security/authorizer/AclAuthorizerTest.scala Outdated
@BeforeEach
override def setUp(): Unit = {
// junit 5 can't make parametered BeforeEach so we override setup to do nothing as we do setup cluster in test case
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not ideal. Since we have a single test, maybe we can do the parameterization manually within the test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That requires to modify server configs "before" the @BeforeEach. It seem to me the only way to address it is to separate the test class. WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The last commit rewrite the test by nested test and it seems to me that is more readable than dynamic test. WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure. I think I would prefer 4 hardcoded test methods calling a private method with two booleans. Seems like it does the job in a simpler way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Basically:

  1. testAutoCreationEnabled
  2. testBrokerAutoCreationEnabled
  3. testClientAutoCreationEnabled
  4. testAutoCreationDisabled

Comment thread core/src/test/scala/unit/kafka/log/LogTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/log/LogCleanerParameterizedIntegrationTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/admin/ConfigCommandTest.scala Outdated
Comment thread core/src/test/scala/integration/kafka/api/ConsumerTopicCreationTest.scala Outdated
@Test
def testAutoCreationDisabled(): Unit = testAutoTopicCreation(false, false)

private def testAutoTopicCreation(brokerAutoTopicCreationEnable: JBoolean, consumerAllowAutoCreateTopics: JBoolean): Unit = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With this, you don't need the separate TestCase, right? You can rely on standard JUnit lifecycle methods.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, this doesn't solve the problem. In that case, my suggestion was bad and what you had before was better. Sorry about that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the related code is reverted.

Copy link
Copy Markdown
Member

@ijuma ijuma 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 the updates, LGTM.

@chia7712
Copy link
Copy Markdown
Member Author

org.apache.kafka.streams.integration.AdjustStreamThreadCountTest

this flaky traced by #9887 and #9888

kafka.api.PlaintextConsumerTest.testLowMaxFetchSizeForRequestAndPartition()

this flaky traced by #9877

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Jan 18, 2021

Will you go ahead and merge then?

@chia7712
Copy link
Copy Markdown
Member Author

Will you go ahead and merge then?

give me one second. the QA is always fails on JDK 8. I'm testing it on my local.

@chia7712 chia7712 merged commit 5a4bbb9 into apache:trunk Jan 18, 2021
List[Integer](brokerId, brokerId + 1, brokerId + 2),
List[Integer](brokerId, brokerId + 1, brokerId + 2),
List.empty[Integer], List.empty[Integer], Seq.empty[Int], false),
List.empty[Integer], List.empty[Integer], Seq.empty[Int], Boolean.box(false)),
Copy link
Copy Markdown
Member

@ijuma ijuma Jan 18, 2021

Choose a reason for hiding this comment

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

For the future (no need to change right now), I think it's a bit cleaner to do false: java.lang.Boolean. The compiler figures out the most appropriate way to convert.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I’ll keep it in mind.

@chia7712 chia7712 deleted the KAFKA-7341 branch March 25, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants