tkalkirill commented on code in PR #4572: URL: https://github.com/apache/ignite-3/pull/4572#discussion_r1803409006
########## modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageManagerImplTest.java: ########## @@ -338,6 +349,93 @@ public void onError(Throwable e) { assertThat("Safe time is advanced too early", watchCompleted.get(), is(true)); } + @Test + void testReadOperationsFutureWithoutReadOperations() { + assertTrue(metaStorageManager.readOperationsFuture(0).isDone()); + assertTrue(metaStorageManager.readOperationsFuture(1).isDone()); + } + + /** + * Tests {@link MetaStorageManagerImpl#readOperationsFuture} as expected in use. + * <ul> + * <li>Creates read operations from the leader and local ones.</li> + * <li>Set a new compaction revision via {@link MetaStorageManagerImpl#setCompactionRevisionLocally}.</li> + * <li>Wait for the completion of read operations on the new compaction revision.</li> + * </ul> + * + * <p>Due to the difficulty of testing all reading from leader methods at once, we test each of them separately.</p> + */ + @ParameterizedTest + @MethodSource("readFromLeaderOperations") + public void testReadOperationsFuture(ReadFromLeaderAction readFromLeaderAction) { + assertThat(metaStorageManager.put(FOO_KEY, VALUE), willCompleteSuccessfully()); + assertThat(metaStorageManager.put(FOO_KEY, VALUE), willCompleteSuccessfully()); + + var startSendReadActionRequestFuture = new CompletableFuture<Void>(); + var continueSendReadActionRequestFuture = new CompletableFuture<>(); + + ((DefaultMessagingService) clusterService.messagingService()).dropMessages((recipientConsistentId, message) -> { + if (message instanceof ReadActionRequest) { + startSendReadActionRequestFuture.complete(null); + + assertThat(continueSendReadActionRequestFuture, willCompleteSuccessfully()); + } + + return false; + }); + + CompletableFuture<?> readFromLeaderOperationFuture = readFromLeaderAction.read(metaStorageManager, FOO_KEY); + Cursor<Entry> getLocallyCursor = metaStorageManager.getLocally(FOO_KEY, FOO_KEY, 5); + + assertThat(startSendReadActionRequestFuture, willCompleteSuccessfully()); + + metaStorageManager.setCompactionRevisionLocally(1); + + CompletableFuture<Void> readOperationsFuture = metaStorageManager.readOperationsFuture(1); Review Comment: Add 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org