simonbence commented on a change in pull request #4883:
URL: https://github.com/apache/nifi/pull/4883#discussion_r592154776



##########
File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/status/history/EmbeddedQuestDbRolloverHandlerTest.java
##########
@@ -75,68 +95,146 @@ public void tearDown() throws Exception {
     }
 
     @Test
-    public void testRollOverWhenWithEmptyDatabase() throws Exception {
+    public void testNoOffsetTimeZoneWhenPartitionNeedsToBeRolled() throws 
Exception {
+        // given
+        givenTableIsCreated(dbContext);
+        givenTableIsPopulated(UTC_MAR_5_1200, UTC_MAR_6_1200, UTC_MAR_7_1200, 
UTC_MAR_8_1200);
+
+        // when
+        whenRollOverIsExecuted(UTC_MAR_8_1700);
+
+        // then
+        thenTheRemainingPartitionsAre("2021-03-06", "2021-03-07", 
"2021-03-08");
+    }
+
+    @Test
+    // This scenario might occur when the NiFi was stopped and the persistent 
storage remains in place
+    public void testNoOffsetTimeZoneAndNonConsecutive() throws Exception {
+        // given
+        givenTableIsCreated(dbContext);
+        givenTableIsPopulated(UTC_MAR_1_1200, UTC_MAR_2_1200, UTC_MAR_7_1200, 
UTC_MAR_8_1200);
+
+        // when
+        whenRollOverIsExecuted(UTC_MAR_8_1700);
+
+        // then
+        thenTheRemainingPartitionsAre("2021-03-07", "2021-03-08");
+    }
+
+    @Test
+    public void testNoOffsetTimeWhenNoPartitionsNeedToBeDropped() throws 
Exception {
+        // given
+        givenTableIsCreated(dbContext);
+        givenTableIsPopulated(UTC_MAR_6_1200, UTC_MAR_7_1200, UTC_MAR_8_1200);
+
+        // when
+        whenRollOverIsExecuted(UTC_MAR_8_1700);
+
+        // then
+        thenTheRemainingPartitionsAre("2021-03-06", "2021-03-07", 
"2021-03-08");
+    }
+
+    @Test
+    public void testNoOffsetTimeZoneAndLessPartitionThanNeeded() throws 
Exception {
+        // given
+        givenTableIsCreated(dbContext);
+        givenTableIsPopulated(UTC_MAR_7_1200, UTC_MAR_8_1200);
+
+        // when
+        whenRollOverIsExecuted(UTC_MAR_8_1700);
+
+        // then
+        thenTheRemainingPartitionsAre("2021-03-07", "2021-03-08");
+    }
+
+    @Test
+    public void testNoOffsetTimeZoneAndOldPartitionsOnly() throws Exception {
         // given
         givenTableIsCreated(dbContext);
+        givenTableIsPopulated(UTC_MAR_1_1200, UTC_MAR_2_1200);
 
         // when
-        whenRollOverIsExecuted();
+        whenRollOverIsExecuted(UTC_MAR_8_1700);
+
+        // then - QuestDB will not remove the active partition if presents
+        thenTheRemainingPartitionsAre("2021-03-02");
+    }
+
+    @Test
+    public void testNoOffsetTimeZoneAndEmptyDatabase() throws Exception {
+        // given
+        givenTableIsCreated(dbContext);
+
+        // when
+        whenRollOverIsExecuted(UTC_MAR_8_1700);
 
         // then
-        thenRemainingPartitionsAre(Arrays.asList());
+        thenNoPartitionsExpected();
     }
 
     @Test
-    public void testRollOverWhenLessPartitionThanNeeded() throws Exception {
+    public void testNegativeOffsetTimeZoneWhenOverlaps() throws Exception {
         // given
         givenTableIsCreated(dbContext);
-        givenTableIsPopulated(givenMeasurementTimes(Arrays.asList(0, 1)));
+        givenTableIsPopulated(EST_MAR_5_1200, EST_MAR_6_1200, EST_MAR_7_1200, 
EST_MAR_8_1200, EST_MAR_8_1600);
 
         // when
-        whenRollOverIsExecuted();
+        whenRollOverIsExecuted(EST_MAR_8_1700);
 
         // then
-        thenRemainingPartitionsAre(Arrays.asList(0, 1));
+        thenTheRemainingPartitionsAre("2021-03-06", "2021-03-07", 
"2021-03-08");
+    }
+
+    @Test
+    public void testNegativeOffsetTimeZoneWhenOverlapsAndRolledLater() throws 
Exception {
+        // given
+        givenTableIsCreated(dbContext);
+        givenTableIsPopulated(EST_MAR_5_1200, EST_MAR_6_1200, EST_MAR_7_1200, 
EST_MAR_8_1200, EST_MAR_8_1600);
+
+        // when
+        whenRollOverIsExecuted(EST_MAR_8_2300);
+
+        // then (there is no data inserted into the time range after the 
partition 2021-03-08, so 2021-03-09 is not created)
+        thenTheRemainingPartitionsAre("2021-03-07", "2021-03-08");
     }
 
     @Test
-    public void testRollOverWhenNoPartitionToDrop() throws Exception {
+    public void testNegativeOffsetTimeZoneWhenHangsOver() throws Exception {
         // given
         givenTableIsCreated(dbContext);
-        givenTableIsPopulated(givenMeasurementTimes(Arrays.asList(0, 1, 2)));
+        givenTableIsPopulated(EST_MAR_6_1200, EST_MAR_7_1200, EST_MAR_8_1200, 
EST_MAR_8_2200);
 
         // when
-        whenRollOverIsExecuted();
+        whenRollOverIsExecuted(EST_MAR_8_2300);
 
         // then
-        thenRemainingPartitionsAre(Arrays.asList(0, 1, 2));
+        thenTheRemainingPartitionsAre("2021-03-07", "2021-03-08", 
"2021-03-09");
     }
 
     @Test
-    public void testRollOverWhenOldPartitionsPresent() throws Exception {
+    public void testPositiveOffsetTimeZoneWhenOverlaps() throws Exception {
         // given
         givenTableIsCreated(dbContext);
-        givenTableIsPopulated(givenMeasurementTimes(Arrays.asList(0, 1, 2, 3, 
4)));
+        givenTableIsPopulated(SGT_MAR_4_1200, SGT_MAR_5_1200, SGT_MAR_6_1200, 
SGT_MAR_7_1200, SGT_MAR_8_1200);
 
         // when
-        whenRollOverIsExecuted();
+        whenRollOverIsExecuted(SGT_MAR_8_1300);
 
         // then
-        thenRemainingPartitionsAre(Arrays.asList(0, 1, 2));
+        thenTheRemainingPartitionsAre("2021-03-06", "2021-03-07", 
"2021-03-08");
     }
 
     @Test
-    // This scenario might occurs when the NiFi was stopped and the persistens 
storage remaing
-    public void testRollOverWhenNonconsecutivePartitionsPresent() throws 
Exception {
+    public void testPositiveOffsetTimeZoneWhenHangsOver() throws Exception {
         // given
         givenTableIsCreated(dbContext);
-        givenTableIsPopulated(givenMeasurementTimes(Arrays.asList(0, 1, 7, 8, 
9)));
+        givenTableIsPopulated(SGT_MAR_4_1200, SGT_MAR_5_1200, SGT_MAR_6_1200, 
SGT_MAR_7_1200, SGT_MAR_8_1200);
 
         // when
-        whenRollOverIsExecuted();
+        whenRollOverIsExecuted("03/08/2021 23:00:00 SGT"); // UTC: 03/09/2021 
04:00:00

Review comment:
       You are correct indeed, also I moved this time literal next to the 
others.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to