JAkutenshi commented on code in PR #6072: URL: https://github.com/apache/ignite-3/pull/6072#discussion_r2161323327
########## modules/partition-replicator/src/test/java/org/apache/ignite/internal/partition/replicator/PartitionReplicaLifecycleManagerTest.java: ########## @@ -324,4 +378,55 @@ void producesEventsOnPartitionDestroy() { assertThat(beforeReplicaDestroyedFuture.thenApply(LocalPartitionReplicaEventParameters::zonePartitionId), willBe(zonePartitionId)); assertThat(afterReplicaDestroyedFuture.thenApply(LocalPartitionReplicaEventParameters::zonePartitionId), willBe(zonePartitionId)); } + + @Test + public void partitionLifecycleManagerStopsCorrectWhenAllComponentsAreStoppedFine() throws Exception { + assertDoesNotThrow(() -> partitionReplicaLifecycleManager.beforeNodeStop()); + + assertThat(partitionReplicaLifecycleManager.stopAsync(), willCompleteSuccessfully()); + + verify(replicaManager, times(CatalogUtils.DEFAULT_PARTITION_COUNT)).stopReplica(any()); + } + + @Test + public void partitionLifecycleManagerStopsCorrectWhenReplicasAreStoppedExceptionally() throws Exception { + when(replicaManager.stopReplica(any())).thenThrow(new NodeStoppingException()); + + assertDoesNotThrow(() -> partitionReplicaLifecycleManager.beforeNodeStop()); + + assertThat(partitionReplicaLifecycleManager.stopAsync(), willCompleteSuccessfully()); + + // One more because of exceptional mock above counts. + verify(replicaManager, times(CatalogUtils.DEFAULT_PARTITION_COUNT + 1)).stopReplica(any()); + + // Do reset for correct replica manager stop on tear down. + reset(replicaManager); + } + + @Test + public void partitionLifecycleManagerStopsCorrectWhenTxStatePartitionStoragesAreStoppedExceptionally() throws Exception { Review Comment: Because not every exception on stop process breaks `stopAsync`: broken `stopReplica` works fine and doesn't propagate the exception -- 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