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-7438: Replace Easymock & Powermock with Mockito in RocksDBMetricsRecorderGa… #14190

Merged
merged 1 commit into from Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -59,12 +59,11 @@
import static org.apache.kafka.streams.state.internals.metrics.RocksDBMetrics.NUMBER_OF_BACKGROUND_ERRORS;
import static org.apache.kafka.streams.state.internals.metrics.RocksDBMetrics.TOTAL_SST_FILES_SIZE;
import static org.apache.kafka.streams.state.internals.metrics.RocksDBMetrics.USAGE_OF_BLOCK_CACHE;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.mock;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.powermock.api.easymock.PowerMock.replay;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class RocksDBMetricsRecorderGaugesTest {
private static final String METRICS_SCOPE = "metrics-scope";
Expand Down Expand Up @@ -212,11 +211,8 @@ private void runAndVerifySumOfProperties(final String propertyName) throws Excep

final long recordedValue1 = 5L;
final long recordedValue2 = 3L;
expect(dbToAdd1.getAggregatedLongProperty(ROCKSDB_PROPERTIES_PREFIX + propertyName))
.andStubReturn(recordedValue1);
expect(dbToAdd2.getAggregatedLongProperty(ROCKSDB_PROPERTIES_PREFIX + propertyName))
.andStubReturn(recordedValue2);
replay(dbToAdd1, dbToAdd2);
when(dbToAdd1.getAggregatedLongProperty(ROCKSDB_PROPERTIES_PREFIX + propertyName)).thenReturn(recordedValue1);
when(dbToAdd2.getAggregatedLongProperty(ROCKSDB_PROPERTIES_PREFIX + propertyName)).thenReturn(recordedValue2);

verifyMetrics(streamsMetrics, propertyName, recordedValue1 + recordedValue2);
}
Expand All @@ -235,11 +231,8 @@ private void runAndVerifyBlockCacheMetricsWithSingleCache(final String propertyN
recorder.addValueProviders(SEGMENT_STORE_NAME_2, dbToAdd2, cacheToAdd1, statisticsToAdd2);

final long recordedValue = 5L;
expect(dbToAdd1.getAggregatedLongProperty(ROCKSDB_PROPERTIES_PREFIX + propertyName))
.andStubReturn(recordedValue);
expect(dbToAdd2.getAggregatedLongProperty(ROCKSDB_PROPERTIES_PREFIX + propertyName))
.andStubReturn(recordedValue);
replay(dbToAdd1, dbToAdd2);
when(dbToAdd1.getAggregatedLongProperty(ROCKSDB_PROPERTIES_PREFIX + propertyName)).thenReturn(recordedValue);
when(dbToAdd2.getAggregatedLongProperty(ROCKSDB_PROPERTIES_PREFIX + propertyName)).thenReturn(recordedValue);

verifyMetrics(streamsMetrics, propertyName, recordedValue);
}
Expand Down