Copilot commented on code in PR #10772:
URL: https://github.com/apache/ozone/pull/10772#discussion_r3584341467
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/defrag/TestSnapshotDefragService.java:
##########
@@ -224,6 +236,71 @@ private String getFromCodecBuffer(CodecBuffer buffer) {
return StringCodec.get().fromCodecBuffer(buffer);
}
+ private void putString(Table<String, CodecBuffer> table, String key,
+ String value) throws RocksDatabaseException, CodecException {
+ table.put(key, StringCodec.get().toDirectCodecBuffer(value));
+ }
+
+ private DBStore createDBStore(String name, String tableName)
+ throws RocksDatabaseException {
+ return DBStoreBuilder.newBuilder(configuration)
+ .setName(name)
+ .setPath(tempDir)
+ .addTable(tableName)
+ .build();
+ }
+
+ private Path createLiveSstDelta(DBStore sourceStore, String tableName,
+ String key, LiveSstType liveSstType) throws Exception {
+ Table<String, CodecBuffer> sourceTable = sourceStore.getTable(
+ tableName, StringCodec.get(), CodecBufferCodec.get(true));
+ putString(sourceTable, key, "source-value");
+ sourceStore.flushDB();
+
+ if (liveSstType == LiveSstType.PREVIOUSLY_INGESTED) {
+ File externalFile = tempDir.resolve("external-" + UUID.randomUUID()
+ + ".sst").toFile();
+ try (RDBSstFileWriter writer = new RDBSstFileWriter(externalFile);
+ CodecBuffer keyBuffer = StringCodec.get().toDirectCodecBuffer(key);
+ CodecBuffer valueBuffer = StringCodec.get()
+ .toDirectCodecBuffer("ingested-value")) {
+ writer.put(keyBuffer, valueBuffer);
+ }
+ sourceTable.loadFromFile(externalFile);
+ }
+
+ LiveFileMetaData liveFile = ((RDBStore) sourceStore).getDb()
+ .getLiveFilesMetaData().stream()
+ .max(Comparator.comparingLong(LiveFileMetaData::largestSeqno))
+ .orElseThrow(() -> new IllegalStateException("No live SST file"));
+ Path sourceFile = Paths.get(liveFile.path(), liveFile.fileName());
+ Path deltaFile = tempDir.resolve("delta-" + UUID.randomUUID() + ".sst");
+ Files.createLink(deltaFile, sourceFile);
+ return deltaFile;
+ }
Review Comment:
In createLiveSstDelta, the PREVIOUSLY_INGESTED branch still selects the
candidate SST via max(largestSeqno) across live files. That does not guarantee
the chosen file is the one produced by the external-file ingestion, so the
PREVIOUSLY_INGESTED parameterization may accidentally keep testing a
DB-generated SST and miss the intended regression coverage. Make the selection
deterministic by recording the live SST set before ingestion and then picking
the newly added file (scoped to the target column family).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]