Skip to content

Commit 2d2a15f

Browse files
authored
[Test] Reduce concurrency when testing creation of security index (#75293) (#77836)
The internal cluster could get overwhelmed by many nodes and large number of concurrent putUser request. It can sometimes fail with confusing messages when JVM is under pressure. This PR reduces the concurrency so it has a better chance to succeed. The test also no longer relies on the user being "created" instead of "updated". Since they do not make a difference for the purpose of this test.
1 parent f539086 commit 2d2a15f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/support/SecurityIndexManagerIntegTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ public class SecurityIndexManagerIntegTests extends SecurityIntegTestCase {
2828
public void testConcurrentOperationsTryingToCreateSecurityIndexAndAlias() throws Exception {
2929
assertSecurityIndexActive();
3030
final int processors = Runtime.getRuntime().availableProcessors();
31-
final int numThreads = scaledRandomIntBetween((processors + 1) / 2, 4 * processors);
32-
final int maxNumRequests = 100 / numThreads; // bound to a maximum of 100 requests
31+
final int numThreads = Math.min(50, scaledRandomIntBetween((processors + 1) / 2, 4 * processors)); // up to 50 threads
32+
final int maxNumRequests = 50 / numThreads; // bound to a maximum of 50 requests
3333
final int numRequests = scaledRandomIntBetween(Math.min(4, maxNumRequests), maxNumRequests);
34+
logger.info("creating users with [{}] threads, each sending [{}] requests", numThreads, numRequests);
3435

3536
final List<ActionFuture<PutUserResponse>> futures = new CopyOnWriteArrayList<>();
3637
final List<Exception> exceptions = new CopyOnWriteArrayList<>();
@@ -75,7 +76,10 @@ protected void doRun() throws Exception {
7576
assertThat(exceptions, Matchers.empty());
7677
assertEquals(futures.size(), numRequests * numThreads);
7778
for (ActionFuture<PutUserResponse> future : futures) {
78-
assertTrue(future.actionGet().created());
79+
// In rare cases, the user could be updated instead of created. For the purpose of
80+
// this test, either created or updated is sufficient to prove that the security
81+
// index is created. So we don't need to assert the value.
82+
future.actionGet().created();
7983
}
8084
}
8185

0 commit comments

Comments
 (0)