[RocksJava] Fix cleanup in tests
This commit is contained in:
parent
a01b592597
commit
f862b38124
@ -78,6 +78,7 @@ public abstract class AbstractComparatorTest {
|
||||
lastKey = thisKey;
|
||||
count++;
|
||||
}
|
||||
it.dispose();
|
||||
db.close();
|
||||
|
||||
assertThat(count).isEqualTo(ITERATIONS);
|
||||
@ -162,6 +163,8 @@ public abstract class AbstractComparatorTest {
|
||||
lastKey = thisKey;
|
||||
count++;
|
||||
}
|
||||
|
||||
it.dispose();
|
||||
for (ColumnFamilyHandle handle : cfHandles) {
|
||||
handle.dispose();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class ColumnFamilyTest {
|
||||
public void defaultColumnFamily() throws RocksDBException {
|
||||
RocksDB db = null;
|
||||
Options options = null;
|
||||
ColumnFamilyHandle cfh = null;
|
||||
ColumnFamilyHandle cfh;
|
||||
try {
|
||||
options = new Options().setCreateIfMissing(true);
|
||||
|
||||
@ -95,7 +95,7 @@ public class ColumnFamilyTest {
|
||||
db = RocksDB.open(options, dbFolder.getRoot().getAbsolutePath());
|
||||
columnFamilyHandle = db.createColumnFamily(
|
||||
new ColumnFamilyDescriptor("new_cf".getBytes(), new ColumnFamilyOptions()));
|
||||
db.close();
|
||||
|
||||
List<byte[]> columnFamilyNames;
|
||||
columnFamilyNames = RocksDB.listColumnFamilies(options, dbFolder.getRoot().getAbsolutePath());
|
||||
assertThat(columnFamilyNames).isNotNull();
|
||||
@ -464,6 +464,7 @@ public class ColumnFamilyTest {
|
||||
new ArrayList<>();
|
||||
List<ColumnFamilyHandle> columnFamilyHandleList =
|
||||
new ArrayList<>();
|
||||
List<RocksIterator> iterators = null;
|
||||
try {
|
||||
options = new DBOptions();
|
||||
options.setCreateIfMissing(true);
|
||||
@ -474,8 +475,7 @@ public class ColumnFamilyTest {
|
||||
|
||||
db = RocksDB.open(options, dbFolder.getRoot().getAbsolutePath(),
|
||||
cfNames, columnFamilyHandleList);
|
||||
List<RocksIterator> iterators =
|
||||
db.newIterators(columnFamilyHandleList);
|
||||
iterators = db.newIterators(columnFamilyHandleList);
|
||||
assertThat(iterators.size()).isEqualTo(2);
|
||||
RocksIterator iter = iterators.get(0);
|
||||
iter.seekToFirst();
|
||||
@ -499,6 +499,11 @@ public class ColumnFamilyTest {
|
||||
iter.next();
|
||||
}
|
||||
} finally {
|
||||
if (iterators != null) {
|
||||
for (RocksIterator rocksIterator : iterators) {
|
||||
rocksIterator.dispose();
|
||||
}
|
||||
}
|
||||
for (ColumnFamilyHandle columnFamilyHandle : columnFamilyHandleList) {
|
||||
columnFamilyHandle.dispose();
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ public class RocksDBTest {
|
||||
db.put((String.valueOf(i)).getBytes(), b);
|
||||
}
|
||||
db.compactRange("0".getBytes(), "201".getBytes(),
|
||||
true, 0, 0);
|
||||
true, 0, -1);
|
||||
} finally {
|
||||
if (db != null) {
|
||||
db.close();
|
||||
@ -580,7 +580,7 @@ public class RocksDBTest {
|
||||
String.valueOf(i).getBytes(), b);
|
||||
}
|
||||
db.compactRange(columnFamilyHandles.get(1), "0".getBytes(),
|
||||
"201".getBytes(), true, 0, 0);
|
||||
"201".getBytes(), true, 0, -1);
|
||||
} finally {
|
||||
for (ColumnFamilyHandle handle : columnFamilyHandles) {
|
||||
handle.dispose();
|
||||
@ -729,6 +729,9 @@ public class RocksDBTest {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
for (ColumnFamilyHandle handle : columnFamilyHandles) {
|
||||
handle.dispose();
|
||||
}
|
||||
if (db != null) {
|
||||
db.close();
|
||||
}
|
||||
|
@ -58,41 +58,9 @@ public class RocksIteratorTest {
|
||||
assertThat(iterator.value()).isEqualTo("value2".getBytes());
|
||||
iterator.status();
|
||||
} finally {
|
||||
if (db != null) {
|
||||
db.close();
|
||||
}
|
||||
if (options != null) {
|
||||
options.dispose();
|
||||
}
|
||||
if (iterator != null) {
|
||||
iterator.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rocksIteratorGc()
|
||||
throws RocksDBException {
|
||||
RocksDB db = null;
|
||||
Options options = null;
|
||||
try {
|
||||
options = new Options();
|
||||
options.setCreateIfMissing(true)
|
||||
.setCreateMissingColumnFamilies(true);
|
||||
db = RocksDB.open(options,
|
||||
dbFolder.getRoot().getAbsolutePath());
|
||||
db.put("key".getBytes(), "value".getBytes());
|
||||
db.newIterator();
|
||||
db.newIterator();
|
||||
RocksIterator iter3 = db.newIterator();
|
||||
db.close();
|
||||
db = null;
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
iter3.dispose();
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
} finally {
|
||||
if (db != null) {
|
||||
db.close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user