SecurityClient.createUser fail randomly
We observe that from time to time the createUser fails randomly.
Mainly it fails to get the created user path in getAuthorizableNodeWithRetry as seen below in the stack trace.
While debugging, the user is created but the code logic that do this retry seems to be wrong or not waiting long enough (happening more often on cloud AEM).
[ForkJoinPool-1-worker-0] ERROR com.adobe.cq.sites.testing.utils.TestContentBuilder - Authorizable testCopyPageToSameFolderWithNewLabelAsAdmin_PWmMZrkw not found!
org.apache.sling.testing.clients.ClientException: Authorizable testCopyPageToSameFolderWithNewLabelAsAdmin_PWmMZrkw not found!
at com.adobe.cq.testing.client.security.AbstractAuthorizable.getAuthorizableNodeWithRetry(AbstractAuthorizable.java:270)
at com.adobe.cq.testing.client.security.AbstractAuthorizable.getAuthorizablePath(AbstractAuthorizable.java:225)
at com.adobe.cq.testing.client.security.AbstractAuthorizable.
What seems wrong is that it need to poll to know the created user path, shouldn't the endpoint used to create the user returning the path of the created user in the response ?
@tyge68 are you sure the user is created? it might be a sync problem at create, thus causing the getAuthorizableNodeWithRetry to fail.
Yes I debugged once this case, the user is created, the endpoint that is used to create the user wouldn't return 200 anyway otherwise, also it would make sense to log or assert that the returned response from the create operation contains the user path.
It can be that the search indexing is slower from time to time, so polling for a longer time may solve it (for example it could be configurable).