mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
8 hours ago 3cc8bed31505fb0d39a0b2630b696cfe529ff32b
Fix flaky BindOperationTestCase subtree auth-info tests (#727)
1 files modified
41 ■■■■■ changed files
opendj-server-legacy/src/test/java/org/opends/server/core/BindOperationTestCase.java 41 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/core/BindOperationTestCase.java
@@ -45,9 +45,11 @@
import org.opends.server.types.Control;
import org.opends.server.types.Operation;
import org.opends.server.types.OperationType;
import org.opends.server.util.TestTimer;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static java.util.concurrent.TimeUnit.*;
import static org.assertj.core.api.Assertions.*;
import static org.forgerock.opendj.ldap.ModificationType.*;
import static org.forgerock.opendj.ldap.requests.Requests.*;
@@ -1527,7 +1529,16 @@
        };
      assertEquals(LDAPDelete.run(nullPrintStream(), System.err, args), 0);
      assertNull(DirectoryServer.getAuthenticatedUsers().get(userDN));
      // AuthenticatedUsers is a POST_RESPONSE plugin: the registry is updated
      // after the client already received the response, so poll briefly.
      newAuthInfoTimer().repeatUntilSuccess(new TestTimer.CallableVoid()
      {
        @Override
        public void call() throws Exception
        {
          assertNull(DirectoryServer.getAuthenticatedUsers().get(userDN));
        }
      });
    }
    finally
    {
@@ -1591,9 +1602,18 @@
        };
      assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0);
      DN newUserDN = DN.valueOf("uid=test,ou=users,dc=example,dc=com");
      assertNotNull(DirectoryServer.getAuthenticatedUsers().get(newUserDN));
      assertEquals(DirectoryServer.getAuthenticatedUsers().get(newUserDN).size(), 1);
      final DN newUserDN = DN.valueOf("uid=test,ou=users,dc=example,dc=com");
      // AuthenticatedUsers is a POST_RESPONSE plugin: the registry is updated
      // after the client already received the response, so poll briefly.
      newAuthInfoTimer().repeatUntilSuccess(new TestTimer.CallableVoid()
      {
        @Override
        public void call() throws Exception
        {
          assertNotNull(DirectoryServer.getAuthenticatedUsers().get(newUserDN));
          assertEquals(DirectoryServer.getAuthenticatedUsers().get(newUserDN).size(), 1);
        }
      });
    }
    finally
    {
@@ -1602,6 +1622,19 @@
  }
  /**
   * Timer to await the asynchronous {@link AuthenticatedUsers} registry
   * update: it is performed by a POST_RESPONSE plugin, i.e. after the client
   * already received the operation response.
   */
  private TestTimer newAuthInfoTimer()
  {
    return new TestTimer.Builder()
        .maxSleep(10, SECONDS)
        .sleepTimes(100, MILLISECONDS)
        .toTimer();
  }
  /**
   * Tests to ensure that the "ignore" password policy state update policy
   * works as expected.
   *