9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * CDDL HEADER START
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * The contents of this file are subject to the terms of the
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * Common Development and Distribution License, Version 1.0 only
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * (the "License"). You may not use this file except in compliance
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * with the License.
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * or http://forgerock.org/license/CDDLv1.0.html.
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * See the License for the specific language governing permissions
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * and limitations under the License.
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * When distributing Covered Code, include this CDDL HEADER in each
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * file and include the License file at legal-notices/CDDLv1_0.txt.
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * If applicable, add the following below this CDDL HEADER, with the
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * fields enclosed by brackets "[]" replaced with your own identifying
3437829f938dbb44527d91fbbc5f430a1243c5a5JnRouvignac * information:
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * Portions Copyright [yyyy] [name of copyright owner]
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * CDDL HEADER END
05b42f00b813c3dc70cbb80d62089f9cc0f6f549ludovicp * Copyright 2006-2008 Sun Microsystems, Inc.
6206ed2d27885390956a5dc0be3271367f84b20bJnRouvignac * Portions Copyright 2013 ForgeRock AS
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilsonimport org.opends.server.plugins.DelayPreOpPlugin;
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilsonimport org.opends.server.protocols.internal.InternalClientConnection;
63f894df9142a9f494ad67f454c77cc76974a9e3neil_a_wilsonimport org.opends.server.protocols.internal.InternalSearchOperation;
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilsonimport org.opends.server.types.ModificationType;
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * A set of test cases for the traditional work queue.
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * Ensures that the Directory Server is running.
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * @throws Exception If an unexpected problem occurs.
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * Tests to ensure that the work queue is configured and enabled within the
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * Directory Server.
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson WorkQueue workQueue = DirectoryServer.getWorkQueue();
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson assertTrue(workQueue instanceof TraditionalWorkQueue);
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * Verifies that the number of worker threads can be altered on the fly.
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson * @throws Exception If an unexpected problem occurs.
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson ArrayList<Modification> mods = new ArrayList<Modification>();
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson mods.add(new Modification(ModificationType.REPLACE,
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson ModifyOperation modifyOperation = conn.processModify(dn, mods);
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson mods.add(new Modification(ModificationType.REPLACE,
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson modifyOperation = conn.processModify(dn, mods);
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson // Perform seven external searches so that we can make sure that the
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson // unneeded worker threads can die off.
62625611993cc177eb95fb726fc137dbba01d6d2mmarie "--noPropertiesFile",
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
9b947221228796149abbb1d290c8be335e3d027cneil_a_wilson "(objectClass=*)",
80806023d36ac7397f356b6cda9cd0ea0e8d0f7dneil_a_wilson assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * Tests the {@code WorkQueue.waitUntilIdle()} method for a case in which the
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * work queue should already be idle.
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * @throws Exception If an unexpected problem occurs.
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson public void testWaitUntilIdleNoOpsInProgress()
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(10000));
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * Tests the {@code WorkQueue.waitUntilIdle()} method for a case in which the
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * work queue should already be idle and no timeout is given.
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * @throws Exception If an unexpected problem occurs.
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson public void testWaitUntilIdleNoOpsInProgressNoTimeout()
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(0));
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * Tests the {@code WorkQueue.waitUntilIdle()} method for a case in which the
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * work queue should not be idle for several seconds.
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * @throws Exception If an unexpected problem occurs.
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson public void testWaitUntilIdleSlowOpInProgress()
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson DelayPreOpPlugin.createDelayControlList(5000);
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson SearchFilter.createFilterFromString("(objectClass=*)");
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson LinkedHashSet<String> attrs = new LinkedHashSet<String>();
2efcb9667318c099d8723dd578f198c16b4a22c4matthew new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(),
2efcb9667318c099d8723dd578f198c16b4a22c4matthew InternalClientConnection.nextMessageID(),requestControls,
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson DirectoryServer.getWorkQueue().submitOperation(searchOperation);
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(10000));
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * Tests the {@code WorkQueue.waitUntilIdle()} method for a case in which the
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * work queue should not be idle for several seconds.
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson * @throws Exception If an unexpected problem occurs.
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson public void testWaitUntilTimeoutWithIdleSlowOpInProgress()
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson DelayPreOpPlugin.createDelayControlList(5000);
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson SearchFilter.createFilterFromString("(objectClass=*)");
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson LinkedHashSet<String> attrs = new LinkedHashSet<String>();
2efcb9667318c099d8723dd578f198c16b4a22c4matthew new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(),
2efcb9667318c099d8723dd578f198c16b4a22c4matthew InternalClientConnection.nextMessageID(), requestControls,
2729071ad5ffceebca0d3c36d32e7d601d3df5efneil_a_wilson DirectoryServer.getWorkQueue().submitOperation(searchOperation);