Skip to content

Commit

Permalink
test: test recoverContinuousRecords
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Yu <[email protected]>
  • Loading branch information
Chillax-0v0 committed Feb 19, 2024
1 parent 15aaadb commit a1140e7
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion s3stream/src/test/java/com/automq/stream/s3/S3StorageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,27 @@ public void testRecoverContinuousRecords() {

@Test
public void testRecoverOutOfOrderRecords() {
// TODO
List<WriteAheadLog.RecoverResult> recoverResults = List.of(
new TestRecoverResult(StreamRecordBatchCodec.encode(newRecord(42L, 9L))),
new TestRecoverResult(StreamRecordBatchCodec.encode(newRecord(42L, 10L))),
new TestRecoverResult(StreamRecordBatchCodec.encode(newRecord(42L, 13L))),
new TestRecoverResult(StreamRecordBatchCodec.encode(newRecord(42L, 11L))),
new TestRecoverResult(StreamRecordBatchCodec.encode(newRecord(42L, 12L))),
new TestRecoverResult(StreamRecordBatchCodec.encode(newRecord(42L, 14L))),
new TestRecoverResult(StreamRecordBatchCodec.encode(newRecord(42L, 20L)))
);

List<StreamMetadata> openingStreams = List.of(new StreamMetadata(42L, 0L, 0L, 10L, StreamState.OPENED));
LogCache.LogCacheBlock cacheBlock = S3Storage.recoverContinuousRecords(recoverResults.iterator(), openingStreams);
// ignore closed stream and noncontinuous records.
assertEquals(1, cacheBlock.records().size());
List<StreamRecordBatch> streamRecords = cacheBlock.records().get(42L);
assertEquals(5, streamRecords.size());
assertEquals(10L, streamRecords.get(0).getBaseOffset());
assertEquals(11L, streamRecords.get(1).getBaseOffset());
assertEquals(12L, streamRecords.get(2).getBaseOffset());
assertEquals(13L, streamRecords.get(3).getBaseOffset());
assertEquals(14L, streamRecords.get(4).getBaseOffset());
}

@Test
Expand Down

0 comments on commit a1140e7

Please sign in to comment.