rkhachatryan commented on code in PR #20313:
URL: https://github.com/apache/flink/pull/20313#discussion_r927001242
##########
flink-runtime/src/test/java/org/apache/flink/runtime/state/SharedStateRegistryTest.java:
##########
@@ -182,20 +194,113 @@ public void testRegisterChangelogStateBackendHandles()
throws InterruptedExcepti
}
@Test
- public void testUnregisterUnusedState() {
+ public void testUnregisterUnusedSavepointState() {
SharedStateRegistry sharedStateRegistry = new
SharedStateRegistryImpl();
TestingStreamStateHandle handle = new TestingStreamStateHandle();
- sharedStateRegistry.registerReference(new
SharedStateRegistryKey("first"), handle, 1L);
- sharedStateRegistry.registerReference(new
SharedStateRegistryKey("first"), handle, 2L);
- sharedStateRegistry.registerReference(new
SharedStateRegistryKey("first"), handle, 3L);
+
+ registerInitialCheckpoint(
+ sharedStateRegistry,
+ RESTORED_STATE_ID,
+ CheckpointProperties.forSavepoint(false,
SavepointFormatType.NATIVE));
+
+ sharedStateRegistry.registerReference(
+ new SharedStateRegistryKey(RESTORED_STATE_ID), handle, 2L);
+ sharedStateRegistry.registerReference(
+ new SharedStateRegistryKey(RESTORED_STATE_ID), handle, 3L);
+ sharedStateRegistry.registerReference(
+ new SharedStateRegistryKey("new-state"), new
TestingStreamStateHandle(), 4L);
+
+ assertEquals(
+ "Only the initial checkpoint should be retained because its
state is in use",
+ singleton(1L),
+ sharedStateRegistry.unregisterUnusedState(3));
+ assertTrue(
+ "The initial checkpoint state is unused so it could be
discarded",
+ sharedStateRegistry.unregisterUnusedState(4).isEmpty());
Review Comment:
Right, added `testUnregisterNonInitialCheckpoint` test.
--
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]