diff --git a/x-pack/plugin/sql/qa/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/UserFunctionIT.java b/x-pack/plugin/sql/qa/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/UserFunctionIT.java index 68ae9fe9a068e..25c53e68e2513 100644 --- a/x-pack/plugin/sql/qa/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/UserFunctionIT.java +++ b/x-pack/plugin/sql/qa/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/UserFunctionIT.java @@ -59,11 +59,9 @@ protected String getProtocol() { private void setUpUsers() throws IOException { int usersCount = name.getMethodName().startsWith("testSingle") ? 1 : randomIntBetween(5, 15); users = new ArrayList(usersCount); - - for(int i = 0; i < usersCount; i++) { - String randomUserName = randomAlphaOfLengthBetween(1, 15); - users.add(randomUserName); - createUser(randomUserName, MINIMAL_ACCESS_ROLE); + users.addAll(randomUnique(() -> randomAlphaOfLengthBetween(1, 15), usersCount)); + for (String user : users) { + createUser(user, MINIMAL_ACCESS_ROLE); } }