You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/11/03 13:14:04 UTC

[GitHub] [kafka] cadonna opened a new pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

cadonna opened a new pull request #11462:
URL: https://github.com/apache/kafka/pull/11462


   With a nice mock in `RocksDBMetricsRecorderTest#shouldCorrectlyHandleHitRatioRecordingsWithZeroHitsAndMisses()` and `RocksDBMetricsRecorderTest#shouldCorrectlyHandleAvgRecordingsWithZeroSumAndCount()` were green although `getTickerCount()` was never called. The tests were green because EasyMock returns 0 for a numerical return value by default if no expectation is specified. Thus, commenting out the expectation for `getTickerCount()` did not change the result of the test.
   
   This commit changes the mock to a default mock and fixes the expectation to expect `getAndResetTickerCount()`. Now, commenting out the expectation leads to a test failure.
    
   ### 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] cadonna commented on pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on pull request #11462:
URL: https://github.com/apache/kafka/pull/11462#issuecomment-959048389


   Call for review: @Luizfrf3  


-- 
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] cadonna merged pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

Posted by GitBox <gi...@apache.org>.
cadonna merged pull request #11462:
URL: https://github.com/apache/kafka/pull/11462


   


-- 
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] cadonna commented on pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on pull request #11462:
URL: https://github.com/apache/kafka/pull/11462#issuecomment-973069804


   Test failures are unrelated and known to be flaky.


-- 
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] cadonna commented on pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on pull request #11462:
URL: https://github.com/apache/kafka/pull/11462#issuecomment-959048389


   Call for review: @Luizfrf3  


-- 
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] cadonna commented on a change in pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on a change in pull request #11462:
URL: https://github.com/apache/kafka/pull/11462#discussion_r741926434



##########
File path: streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderTest.java
##########
@@ -557,10 +555,10 @@ public void shouldNotRecordStatisticsBasedMetricsIfStatisticsIsNull() {
 
     @Test
     public void shouldCorrectlyHandleHitRatioRecordingsWithZeroHitsAndMisses() {
-        resetToNice(statisticsToAdd1);
+        reset(statisticsToAdd1);
         recorder.addValueProviders(SEGMENT_STORE_NAME_1, dbToAdd1, cacheToAdd1, statisticsToAdd1);
         expect(statisticsToAdd1.getHistogramData(anyObject())).andStubReturn(new HistogramData(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0L, 0L, 0.0));
-        expect(statisticsToAdd1.getTickerCount(anyObject())).andStubReturn(0L);

Review comment:
       `getTickerCount()` is never called in production code. You can comment out this line and the test will still be successful. This is because the mock is specified to be nice.




-- 
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] cadonna commented on a change in pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on a change in pull request #11462:
URL: https://github.com/apache/kafka/pull/11462#discussion_r741926434



##########
File path: streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderTest.java
##########
@@ -557,10 +555,10 @@ public void shouldNotRecordStatisticsBasedMetricsIfStatisticsIsNull() {
 
     @Test
     public void shouldCorrectlyHandleHitRatioRecordingsWithZeroHitsAndMisses() {
-        resetToNice(statisticsToAdd1);
+        reset(statisticsToAdd1);
         recorder.addValueProviders(SEGMENT_STORE_NAME_1, dbToAdd1, cacheToAdd1, statisticsToAdd1);
         expect(statisticsToAdd1.getHistogramData(anyObject())).andStubReturn(new HistogramData(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0L, 0L, 0.0));
-        expect(statisticsToAdd1.getTickerCount(anyObject())).andStubReturn(0L);

Review comment:
       `getTickerCount()` is never called in production code. You can comment out this line and the test will still be successful. This is because the mock is specified to be nice.

##########
File path: streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderTest.java
##########
@@ -557,10 +555,10 @@ public void shouldNotRecordStatisticsBasedMetricsIfStatisticsIsNull() {
 
     @Test
     public void shouldCorrectlyHandleHitRatioRecordingsWithZeroHitsAndMisses() {
-        resetToNice(statisticsToAdd1);
+        reset(statisticsToAdd1);
         recorder.addValueProviders(SEGMENT_STORE_NAME_1, dbToAdd1, cacheToAdd1, statisticsToAdd1);
         expect(statisticsToAdd1.getHistogramData(anyObject())).andStubReturn(new HistogramData(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0L, 0L, 0.0));
-        expect(statisticsToAdd1.getTickerCount(anyObject())).andStubReturn(0L);

Review comment:
       `getTickerCount()` is never called in production code. You can comment out this line and the test will still be successful. This is because the mock is specified to be nice.




-- 
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] cadonna commented on pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on pull request #11462:
URL: https://github.com/apache/kafka/pull/11462#issuecomment-959048389


   Call for review: @Luizfrf3  


-- 
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] cadonna commented on pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on pull request #11462:
URL: https://github.com/apache/kafka/pull/11462#issuecomment-959048389


   Call for review: @Luizfrf3  


-- 
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] cadonna commented on a change in pull request #11462: MINOR: Set mock correctly in RocksDBMetricsRecorderTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on a change in pull request #11462:
URL: https://github.com/apache/kafka/pull/11462#discussion_r741926434



##########
File path: streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderTest.java
##########
@@ -557,10 +555,10 @@ public void shouldNotRecordStatisticsBasedMetricsIfStatisticsIsNull() {
 
     @Test
     public void shouldCorrectlyHandleHitRatioRecordingsWithZeroHitsAndMisses() {
-        resetToNice(statisticsToAdd1);
+        reset(statisticsToAdd1);
         recorder.addValueProviders(SEGMENT_STORE_NAME_1, dbToAdd1, cacheToAdd1, statisticsToAdd1);
         expect(statisticsToAdd1.getHistogramData(anyObject())).andStubReturn(new HistogramData(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0L, 0L, 0.0));
-        expect(statisticsToAdd1.getTickerCount(anyObject())).andStubReturn(0L);

Review comment:
       `getTickerCount()` is never called in production code. You can comment out this line and the test will still be successful. This is because the mock is specified to be nice.




-- 
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