TestRegisterUserResource.registerUser JUnit test sometimes fails

Issue #13 resolved
Marco Ocana
created an issue

Sometimes this test will fail. Perhaps an asynchronicity/race condition? Relevant part of stack trace: com.sun.jersey.api.client.UniformInterfaceException: POST https://identity.genomespace.org:443/identityServer/usermanagement/register returned a response status of 409 at com.sun.jersey.api.client.WebResource.handle(WebResource.java:607) at com.sun.jersey.api.client.WebResource.post(WebResource.java:235) at org.genomespace.identity.usermanagement.resource.TestRegisterUserResource.registerUser(TestRegisterUserResource.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597)

Comments (2)

  1. liefeld

    409 means the user already exists so this sounds like a race condition. Are there multiple registrations being run in parallel? If so how do they avoid trying to register the same userid. If its using the getMilis() method then its possible this is happening when 2 registers occur within the same millisecond

  2. Eliot Polk

    Fixed by making unique user names by appending System.nanoTime(). Usernames had been non-unique, so if a two tests happened to overlap, or if a junit test was killed before being allowed to complete, there would be an existing username, and the attempt to register would fail with a 409 response.

  3. Log in to comment