You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/05/04 12:18:02 UTC

[GitHub] [flink] sjwiesman commented on a change in pull request #11980: [FLINK-17499][state-processor-api] LazyTimerService used to register …

sjwiesman commented on a change in pull request #11980:
URL: https://github.com/apache/flink/pull/11980#discussion_r419393124



##########
File path: flink-libraries/flink-state-processing-api/src/test/java/org/apache/flink/state/api/output/KeyedStateBootstrapOperatorTest.java
##########
@@ -43,11 +48,53 @@
  */
 public class KeyedStateBootstrapOperatorTest {
 
-	private static final ValueStateDescriptor<Long> descriptor = new ValueStateDescriptor<Long>("state", Types.LONG);
+	private static final ValueStateDescriptor<Long> descriptor = new ValueStateDescriptor<>("state", Types.LONG);
+
+	private static final Long EVENT_TIMER = Long.MAX_VALUE - 1;
+
+	private static final Long PROC_TIMER = Long.MAX_VALUE - 2;
 
 	@Rule
 	public TemporaryFolder folder = new TemporaryFolder();
 
+	@Test
+	public void testTimerStateRestorable() throws Exception {
+		Path path = new Path(folder.newFolder().toURI());
+
+		OperatorSubtaskState state;
+		KeyedStateBootstrapOperator<Long, Long> bootstrapOperator = new KeyedStateBootstrapOperator<>(0L, path, new TimerBootstrapFunction());
+		try (KeyedOneInputStreamOperatorTestHarness<Long, Long, TaggedOperatorSubtaskState> harness = getHarness(bootstrapOperator)) {
+			harness.open();
+
+			harness.processElement(1L, 0L);
+			harness.processElement(2L, 0L);
+			harness.processElement(3L, 0L);
+			bootstrapOperator.endInput();
+
+			state = harness.extractOutputValues().get(0).state;
+		}
+
+		KeyedProcessOperator<Long, Long, Tuple3<Long, Long, TimeDomain>> procOperator = new KeyedProcessOperator<>(new SimpleProcessFunction());
+		try (KeyedOneInputStreamOperatorTestHarness<Long, Long, Tuple3<Long, Long, TimeDomain>> harness = getHarness(procOperator)) {
+
+			harness.initializeState(state);
+			harness.open();
+
+			harness.processWatermark(EVENT_TIMER);
+			harness.setProcessingTime(PROC_TIMER);
+
+			Assert.assertThat(harness.extractOutputValues(), Matchers.containsInAnyOrder(
+				Tuple3.of(1L, EVENT_TIMER, TimeDomain.EVENT_TIME),
+				Tuple3.of(2L, EVENT_TIMER, TimeDomain.EVENT_TIME),
+				Tuple3.of(3L, EVENT_TIMER, TimeDomain.EVENT_TIME),
+				Tuple3.of(1L, PROC_TIMER, TimeDomain.PROCESSING_TIME),
+				Tuple3.of(2L, PROC_TIMER, TimeDomain.PROCESSING_TIME),
+				Tuple3.of(3L, PROC_TIMER, TimeDomain.PROCESSING_TIME)));
+
+			harness.snapshot(0L, 0L);

Review comment:
       Nope, copy-paste error. 




----------------------------------------------------------------
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:
users@infra.apache.org