dcapwell commented on code in PR #3656:
URL: https://github.com/apache/cassandra/pull/3656#discussion_r1830066468


##########
test/unit/org/apache/cassandra/tcm/log/LogStateTestBase.java:
##########
@@ -244,6 +291,47 @@ public void 
sinceArbitraryEpochWithMultipleCorruptSnapshots()
         assertEntries(state.entries, since.nextEpoch(), CURRENT_EPOCH);
     }
 
+    @Test
+    public void getLogStateBetween()
+    {
+        qt().forAll(SNAPSHOTS_GEN, BETWEEN_GEN).check((snapshots, between) -> {
+            LogStateSUT sut = getSystemUnderTest(snapshots);
+            LogState state = sut.reader().getLogState(between.start, 
between.end, true);
+            Assertions.assertThat(state.entries).describedAs("with and without 
snapshot should have the same 
entries").isEqualTo(sut.reader().getLogState(between.start, between.end, 
false).entries);
+            
Assertions.assertThat(state.baseState.epoch).isEqualTo(between.start);
+
+            List<Entry> entries = state.entries;
+            
Assertions.assertThat(entries.size()).isEqualTo(between.end.getEpoch() - 
between.start.getEpoch());
+
+            long expected = between.start.nextEpoch().getEpoch();
+            for (Entry e : entries)
+            {
+                long actual = e.epoch.getEpoch();
+                Assertions.assertThat(actual).describedAs("Unexpected 
epoch").isEqualTo(expected);
+                expected++;
+            }
+        });
+    }
+
+    @Test
+    public void getEntriesBetween()
+    {
+        qt().forAll(SNAPSHOTS_GEN, BETWEEN_GEN).check((snapshots, between) -> {
+            LogStateSUT sut = getSystemUnderTest(snapshots);
+            LogReader.EntryHolder entries = 
sut.reader().getEntries(between.start, between.end);
+            Assertions.assertThat(entries.since).isEqualTo(between.start);
+            
Assertions.assertThat(entries.entries.size()).isEqualTo(between.end.getEpoch() 
- between.start.getEpoch());
+
+            long expected = between.start.nextEpoch().getEpoch();
+            for (Entry e : entries.entries)
+            {
+                long actual = e.epoch.getEpoch();
+                Assertions.assertThat(actual).describedAs("Unexpected 
epoch").isEqualTo(expected);
+                expected++;

Review Comment:
   personally I avoid allocating when I don't need to... that just does `new 
Epoch(epoch + 1)` then we would use the long



-- 
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]

Reply via email to