zentol commented on a change in pull request #7654: [FLINK-11524] Solve race condition in EmbeddedLeaderService URL: https://github.com/apache/flink/pull/7654#discussion_r254216932
########## File path: flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/nonha/embedded/EmbeddedHaServicesTest.java ########## @@ -164,4 +171,70 @@ public void testResourceManagerLeaderRetrieval() throws Exception { verify(leaderRetrievalListener).notifyLeaderAddress(eq(address), eq(leaderId)); } + + /** + * Tests that concurrent leadership operations (granting and revoking) leadership leave the + * system in a sane state. + */ + @Test + public void testConcurrentLeadershipOperations() throws Exception { + final LeaderElectionService dispatcherLeaderElectionService = embeddedHaServices.getDispatcherLeaderElectionService(); + final ArrayBlockingQueue<UUID> offeredSessionIds = new ArrayBlockingQueue<>(2); + final TestingLeaderContender leaderContender = new TestingLeaderContender(offeredSessionIds); + + dispatcherLeaderElectionService.start(leaderContender); + + final UUID oldLeaderSessionId = offeredSessionIds.take(); + + assertThat(dispatcherLeaderElectionService.hasLeadership(oldLeaderSessionId), is(true)); + + embeddedHaServices.getDispatcherLeaderService().revokeLeadership().get(); Review comment: is there a reason you don't access `dispatcherLeaderElectionService` directly? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services