Skip to content

Commit

Permalink
test(java): add LiveFilesMetaData test
Browse files Browse the repository at this point in the history
  • Loading branch information
npepinpe committed Aug 28, 2023
1 parent 53e5037 commit cdba2e3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions java/src/test/java/org/rocksdb/RocksDBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,34 @@ public void getApproximateMemTableStatsSingleKey() throws RocksDBException {
}
}

@Test
public void getLiveFilesMetadataWithChecksum() throws RocksDBException {
final Properties props = new Properties();
final byte[] key1 = "key1".getBytes(UTF_8);
props.put("file_checksum_gen_factory", "FileChecksumGenCrc32cFactory");

try (final DBOptions dbOptions = DBOptions.getDBOptionsFromProps(props);
final ColumnFamilyOptions cfOptions = new ColumnFamilyOptions();
final Options options = new Options(dbOptions, cfOptions).setCreateIfMissing(true)) {
final String dbPath = dbFolder.getRoot().getAbsolutePath();

// disable WAL so we have a deterministic checksum
try (final RocksDB db = RocksDB.open(options, dbPath);
final WriteOptions writeOptions = new WriteOptions().setDisableWAL(true)) {
db.put(writeOptions, key1, key1);
}

try (final RocksDB db = RocksDB.open(options, dbPath)) {
final List<LiveFileMetaData> expectedFileMetadata = db.getLiveFilesMetaData();
assertThat(expectedFileMetadata).hasSize(1);
// ideally we could re-compute here, but CRC32C is a Java 9 feature, so we have no CRC32C
// implementation available here
final LiveFileMetaData sstFile = expectedFileMetadata.get(0);
assertThat(sstFile.fileChecksum()).isNotEmpty();
}
}
}

@Ignore("TODO(AR) re-enable when ready!")
@Test
public void compactFiles() throws RocksDBException {
Expand Down

0 comments on commit cdba2e3

Please sign in to comment.