You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "guozhangwang (via GitHub)" <gi...@apache.org> on 2023/03/01 02:54:50 UTC

[GitHub] [kafka] guozhangwang opened a new pull request, #13319: MINOR: Fix flaky tests in DefaultStateUpdaterTest

guozhangwang opened a new pull request, #13319:
URL: https://github.com/apache/kafka/pull/13319

   Found a few flaky tests while reviewing another PR. The root cause seems to be with changing the return behavior of `when` in mockito. Fixed those without using `reset` and also bumped a couple debug log lines to info since they could be very helpful in debugging.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang commented on pull request #13319: MINOR: Fix flaky tests in DefaultStateUpdaterTest

Posted by "guozhangwang (via GitHub)" <gi...@apache.org>.
guozhangwang commented on PR #13319:
URL: https://github.com/apache/kafka/pull/13319#issuecomment-1451145318

   Merged to trunk.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang commented on pull request #13319: MINOR: Fix flaky tests in DefaultStateUpdaterTest

Posted by "guozhangwang (via GitHub)" <gi...@apache.org>.
guozhangwang commented on PR #13319:
URL: https://github.com/apache/kafka/pull/13319#issuecomment-1450565316

   I checked the latest failure on `shouldPauseStandbyTaskAndNotTransit..` and found out that it's because of the test condition itself is timing dependent. What it wants to verify is the following sequence:
   
   `task1 added, task2 added, and then task1 paused`. In this case the `transitToUpdateStandby` should be called once.
   
   But it is possible that the following sequence can also happen:
   
   `task1 added, task1 paused, task2 added` (because the updater thread can interleave its runOnce with the `addTask` call), in which case the `transitToUpdateStandby` could be called twice.
   
   I've relaxed that condition and I think this test should not fail anymore.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] showuon commented on pull request #13319: MINOR: Fix flaky tests in DefaultStateUpdaterTest

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on PR #13319:
URL: https://github.com/apache/kafka/pull/13319#issuecomment-1450060935

   I can see the test result is better, but there are still failed tests in `DefaultStateUpdaterTest`
   ```
       Build / JDK 17 and Scala 2.13 / kafka.server.DynamicBrokerReconfigurationTest.testTrustStoreAlter(String).quorum=kraft
       Build / JDK 8 and Scala 2.12 / org.apache.kafka.streams.processor.internals.DefaultStateUpdaterTest.shouldPauseStandbyTaskAndNotTransitToUpdateStandbyAgain()
       Build / JDK 8 and Scala 2.12 / org.apache.kafka.streams.processor.internals.DefaultStateUpdaterTest.shouldPauseStandbyTaskAndNotTransitToUpdateStandbyAgain()
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang commented on pull request #13319: MINOR: Fix flaky tests in DefaultStateUpdaterTest

Posted by "guozhangwang (via GitHub)" <gi...@apache.org>.
guozhangwang commented on PR #13319:
URL: https://github.com/apache/kafka/pull/13319#issuecomment-1450512377

   Honestly I do not quite understanding how mockito is messing here.. take `shouldPauseActiveTaskAndTransitToUpdateStandby` for example, after task1 (named topologyA) and task2 (named topologyB) are updating, then there's the line `when(topologyMetadata.isPaused("A")).thenReturn(true);`. In succeeding cases, task1 is indeed paused, and everything works just fine; however in those flaky failing cases, task2 is paused instead, indicating `topologyMetadata.isPaused("B")` returns true but `topologyMetadata.isPaused("A")` returns false... I honestly have no idea why that could happen, but after changing that to `when(topologyMetadata.isPaused(task1.id().topologyName())).thenReturn(false).thenReturn(true);` (i.e. let it to return false on the first call when adding task, and then return true on the second call to pause) I did not see that test failing any more. I checked mockito's docs but still do not see how `when` could mess up on the return values, so I kinda fixed it but do not know 
 exactly why I fixed it..


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] showuon commented on pull request #13319: MINOR: Fix flaky tests in DefaultStateUpdaterTest

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on PR #13319:
URL: https://github.com/apache/kafka/pull/13319#issuecomment-1449265831

   Thanks for investigating it! This test did fail quite frequently recently. But I'm not completely understanding this:
   
   > The root cause seems to be with changing the return behavior of when in mockito. Fixed those without using reset
   
   What does the "return bahavior change" in mockito? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] lucasbru commented on pull request #13319: MINOR: Fix flaky tests in DefaultStateUpdaterTest

Posted by "lucasbru (via GitHub)" <gi...@apache.org>.
lucasbru commented on PR #13319:
URL: https://github.com/apache/kafka/pull/13319#issuecomment-1449663595

   I looked into this flakyness before and I don't quite understand the behavior of mockito here. Could you explain this, or did you stumble upon the solution, and maybe add a comment somewhere explaining the solution?
   
   Either way, results speak for themselves so approving


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang merged pull request #13319: MINOR: Fix flaky tests in DefaultStateUpdaterTest

Posted by "guozhangwang (via GitHub)" <gi...@apache.org>.
guozhangwang merged PR #13319:
URL: https://github.com/apache/kafka/pull/13319


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang commented on pull request #13319: MINOR: Fix flaky tests in DefaultStateUpdaterTest

Posted by "guozhangwang (via GitHub)" <gi...@apache.org>.
guozhangwang commented on PR #13319:
URL: https://github.com/apache/kafka/pull/13319#issuecomment-1449254753

   ping @cadonna @lucasbru for a quick review.
   
   Before this PR, local runs fail about 50% of the time; after this PR it succeeds with about 10 runs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org