From e39e0ec64113717f5b092bf5a7b352baa55c65cb Mon Sep 17 00:00:00 2001 From: Richard Dennehy Date: Fri, 22 Aug 2025 10:43:43 +0100 Subject: [PATCH] fix flaky testInvalidToken --- .../xpack/security/authc/AuthenticationServiceTests.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java index 4c2d0587ebdc5..74ab1e704201d 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java @@ -1980,6 +1980,11 @@ public void testInvalidToken() throws Exception { when(projectIndex.getUnavailableReason(any())).thenReturn(new ElasticsearchException(getTestName())); } else { when(projectIndex.isAvailable(any())).thenReturn(true); + doAnswer(invocationOnMock -> { + Runnable runnable = (Runnable) invocationOnMock.getArguments()[1]; + runnable.run(); + return null; + }).when(projectIndex).checkIndexVersionThenExecute(anyConsumer(), any(Runnable.class)); doAnswer(inv -> { final GetRequest request = inv.getArgument(0); final ActionListener listener = inv.getArgument(1);