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

[test] Fixed NPEs in RocksDBStorageEngineTest #823

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Set;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand All @@ -34,6 +35,7 @@ public class RocksDBStorageEngineTest extends AbstractStorageEngineTest {
private final ReadOnlyStoreRepository mockReadOnlyStoreRepository = mock(ReadOnlyStoreRepository.class);
private static final int versionNumber = 0;
private static final String topicName = Version.composeKafkaTopic(storeName, versionNumber);
private int testCount = 0;

@Override
public void createStorageEngineForTest() {
Expand Down Expand Up @@ -67,6 +69,24 @@ public void cleanUp() throws Exception {
storageService.stop();
}

@AfterMethod
public void testCounter() {
this.testCount++;
}

/**
* Some tests require a reset if other tests have run before them, as they are sensitive to contamination.
*
* Alternatively, we could make {@link #setUp()} have {@link org.testng.annotations.BeforeMethod} and
* {@link #cleanUp()} have {@link AfterMethod}, though that makes the class take longer than the current approach.
adamxchen marked this conversation as resolved.
Show resolved Hide resolved
*/
private void reset() throws Exception {
if (this.testCount > 0) {
cleanUp();
setUp();
}
}

@Test
public void testGetAndPut() {
super.testGetAndPut();
Expand Down Expand Up @@ -154,11 +174,13 @@ public void testGetInvalidKeys() {

@Test
public void testPartitioning() throws Exception {
reset();
super.testPartitioning();
}

@Test
public void testAddingAPartitionTwice() throws Exception {
reset();
super.testAddingAPartitionTwice();
}

Expand Down