[ 
https://issues.apache.org/jira/browse/KAFKA-16323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831291#comment-17831291
 ] 

Chia-Ping Tsai commented on KAFKA-16323:
----------------------------------------

It seems to me the root cause could be the `spy` does not work well. We had met 
similar issue before - the spied method results in unexpected behavior when we 
test it in multi-threads. see https://github.com/apache/kafka/pull/10006

Hence, we can try to fix it by using `override` to replace spied method. for 
example: 

{code}
    val latch = new CountDownLatch(1)
    val remoteLogManager = new RemoteLogManager(
      remoteLogManagerConfig,
      0,
      TestUtils.tempRelativeDir("data").getAbsolutePath,
      "clusterId",
      time,
      _ => Optional.of(dummyLog),
      (TopicPartition, Long) => {},
      brokerTopicStats) {
      override def read(remoteStorageFetchInfo: RemoteStorageFetchInfo): 
FetchDataInfo = {
        // wait until verification completes
        latch.await(5000, TimeUnit.MILLISECONDS)
        mock(classOf[FetchDataInfo])
      }
    }
{code}


> Failing test: fix testRemoteFetchExpiresPerSecMetric 
> -----------------------------------------------------
>
>                 Key: KAFKA-16323
>                 URL: https://issues.apache.org/jira/browse/KAFKA-16323
>             Project: Kafka
>          Issue Type: Bug
>          Components: core
>            Reporter: Johnny Hsu
>            Assignee: Johnny Hsu
>            Priority: Major
>              Labels: test-failure
>
> Refer to 
> [https://ci-builds.apache.org/job/Kafka/job/kafka/job/trunk/2685/testReport/junit/kafka.server/ReplicaManagerTest/Build___JDK_21_and_Scala_2_13___testRemoteFetchExpiresPerSecMetric__/]
> This test is failing, and this ticket aims to address thisĀ 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to