Skip to content

Commit 3731c6a

Browse files
committed
[bugfix] Address timing issue in flaky test when run in fast compute environment
1 parent 6135977 commit 3731c6a

File tree

2 files changed

+50
-12
lines changed

2 files changed

+50
-12
lines changed

exist-core/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@
813813
<include>src/main/java/org/exist/source/SourceFactory.java</include>
814814
<include>src/main/java/org/exist/storage/BrokerFactory.java</include>
815815
<include>src/main/java/org/exist/storage/BrokerPool.java</include>
816+
<include>src/test/java/org/exist/storage/CopyResourceTest.java</include>
816817
<include>src/main/java/org/exist/storage/DBBroker.java</include>
817818
<include>src/main/java/org/exist/storage/IndexSpec.java</include>
818819
<include>src/main/java/org/exist/storage/Indexable.java</include>
@@ -1016,6 +1017,7 @@
10161017
<exclude>src/main/java/org/exist/source/SourceFactory.java</exclude>
10171018
<exclude>src/main/java/org/exist/storage/BrokerFactory.java</exclude>
10181019
<exclude>src/main/java/org/exist/storage/BrokerPool.java</exclude>
1020+
<exclude>src/test/java/org/exist/storage/CopyResourceTest.java</exclude>
10191021
<exclude>src/main/java/org/exist/storage/DBBroker.java</exclude>
10201022
<exclude>src/main/java/org/exist/storage/FluentBrokerAPI.java</exclude>
10211023
<exclude>src/main/java/org/exist/storage/IndexSpec.java</exclude>

exist-core/src/test/java/org/exist/storage/CopyResourceTest.java

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -110,8 +134,9 @@ public class CopyResourceTest {
110134
* As the owner copy {@link #USER1_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER1_NEW_DOC}.
111135
*/
112136
@Test
113-
public void copyXmlToNonExistentAsSelf() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
137+
public void copyXmlToNonExistentAsSelf() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
114138
final Subject user1 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER1_NAME, USER1_PWD);
139+
Thread.sleep(5);
115140
copyDoc(user1, NO_PRESERVE, USER1_DOC1, USER1_NEW_DOC);
116141
checkAttributes(USER1_NEW_DOC, USER1_NAME, USER1_NAME, USER1_DOC1_MODE, not(getCreated(USER1_DOC1)), not(getLastModified(USER1_DOC1)));
117142
}
@@ -120,8 +145,9 @@ public void copyXmlToNonExistentAsSelf() throws AuthenticationException, LockExc
120145
* As the owner copy {@link #USER1_BIN_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER1_NEW_BIN_DOC}.
121146
*/
122147
@Test
123-
public void copyBinaryToNonExistentAsSelf() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
148+
public void copyBinaryToNonExistentAsSelf() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
124149
final Subject user1 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER1_NAME, USER1_PWD);
150+
Thread.sleep(5);
125151
copyDoc(user1, NO_PRESERVE, USER1_BIN_DOC1, USER1_NEW_BIN_DOC);
126152
checkAttributes(USER1_NEW_BIN_DOC, USER1_NAME, USER1_NAME, USER1_BIN_DOC1_MODE, not(getCreated(USER1_BIN_DOC1)), not(getLastModified(USER1_BIN_DOC1)));
127153
}
@@ -154,8 +180,9 @@ public void copyBinaryToExistentAsSelf() throws AuthenticationException, LockExc
154180
* As a DBA copy {@link #USER1_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER1_NEW_DOC}.
155181
*/
156182
@Test
157-
public void copyXmlToNonExistentAsDBA() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
183+
public void copyXmlToNonExistentAsDBA() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
158184
final Subject adminUser = existWebServer.getBrokerPool().getSecurityManager().authenticate(ADMIN_DB_USER, ADMIN_DB_PWD);
185+
Thread.sleep(5);
159186
copyDoc(adminUser, NO_PRESERVE, USER1_DOC1, USER1_NEW_DOC);
160187
checkAttributes(USER1_NEW_DOC, ADMIN_DB_USER, DBA_GROUP, USER1_DOC1_MODE, not(getCreated(USER1_DOC1)), not(getLastModified(USER1_DOC1)));
161188
}
@@ -164,8 +191,9 @@ public void copyXmlToNonExistentAsDBA() throws AuthenticationException, LockExce
164191
* As a DBA copy {@link #USER1_BIN_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER1_NEW_BIN_DOC}.
165192
*/
166193
@Test
167-
public void copyBinaryToNonExistentAsDBA() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
194+
public void copyBinaryToNonExistentAsDBA() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
168195
final Subject adminUser = existWebServer.getBrokerPool().getSecurityManager().authenticate(ADMIN_DB_USER, ADMIN_DB_PWD);
196+
Thread.sleep(5);
169197
copyDoc(adminUser, NO_PRESERVE, USER1_BIN_DOC1, USER1_NEW_BIN_DOC);
170198
checkAttributes(USER1_NEW_BIN_DOC, ADMIN_DB_USER, DBA_GROUP, USER1_BIN_DOC1_MODE, not(getCreated(USER1_BIN_DOC1)), not(getLastModified(USER1_BIN_DOC1)));
171199
}
@@ -198,8 +226,9 @@ public void copyBinaryToExistentAsDBA() throws AuthenticationException, LockExce
198226
* As some other (non-owner) user copy {@link #USER1_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER2_NEW_DOC}.
199227
*/
200228
@Test
201-
public void copyXmlToNonExistentAsOther() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
229+
public void copyXmlToNonExistentAsOther() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
202230
final Subject user2 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER2_NAME, USER2_PWD);
231+
Thread.sleep(5);
203232
copyDoc(user2, NO_PRESERVE, USER1_DOC1, USER2_NEW_DOC);
204233
checkAttributes(USER2_NEW_DOC, USER2_NAME, USER2_NAME, USER1_DOC1_MODE, not(getCreated(USER1_DOC1)), not(getLastModified(USER1_DOC1)));
205234
}
@@ -208,8 +237,9 @@ public void copyXmlToNonExistentAsOther() throws AuthenticationException, LockEx
208237
* As some other (non-owner) user copy {@link #USER1_BIN_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER2_NEW_BIN_DOC}.
209238
*/
210239
@Test
211-
public void copyBinaryToNonExistentAsOther() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
240+
public void copyBinaryToNonExistentAsOther() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
212241
final Subject user2 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER2_NAME, USER2_PWD);
242+
Thread.sleep(5);
213243
copyDoc(user2, NO_PRESERVE, USER1_BIN_DOC1, USER2_NEW_BIN_DOC);
214244
checkAttributes(USER2_NEW_BIN_DOC, USER2_NAME, USER2_NAME, USER1_BIN_DOC1_MODE, not(getCreated(USER1_BIN_DOC1)), not(getLastModified(USER1_BIN_DOC1)));
215245
}
@@ -267,9 +297,10 @@ public void copyBinaryToExistentAsOther() throws AuthenticationException, EXistE
267297
* as the owner copy {@link #USER1_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER1_NEW_DOC}.
268298
*/
269299
@Test
270-
public void copyPreserveXmlToNonExistentAsSelf() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
300+
public void copyPreserveXmlToNonExistentAsSelf() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
271301
final Subject user1 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER1_NAME, USER1_PWD);
272302
final long doc1LastModified = getLastModified(USER1_DOC1);
303+
Thread.sleep(5);
273304
copyDoc(user1, PRESERVE, USER1_DOC1, USER1_NEW_DOC);
274305
checkAttributes(USER1_NEW_DOC, USER1_NAME, USER1_NAME, USER1_DOC1_MODE, equalTo(doc1LastModified), equalTo(doc1LastModified));
275306
}
@@ -279,9 +310,10 @@ public void copyPreserveXmlToNonExistentAsSelf() throws AuthenticationException,
279310
* as the owner copy {@link #USER1_BIN_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER1_NEW_BIN_DOC}.
280311
*/
281312
@Test
282-
public void copyPreserveBinaryToNonExistentAsSelf() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
313+
public void copyPreserveBinaryToNonExistentAsSelf() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
283314
final Subject user1 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER1_NAME, USER1_PWD);
284315
final long binDoc1LastModified = getLastModified(USER1_BIN_DOC1);
316+
Thread.sleep(5);
285317
copyDoc(user1, PRESERVE, USER1_BIN_DOC1, USER1_NEW_BIN_DOC);
286318
checkAttributes(USER1_NEW_BIN_DOC, USER1_NAME, USER1_NAME, USER1_BIN_DOC1_MODE, equalTo(binDoc1LastModified), equalTo(binDoc1LastModified));
287319
}
@@ -317,9 +349,10 @@ public void copyPreserveBinaryToExistentAsSelf() throws AuthenticationException,
317349
* as a DBA copy {@link #USER1_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER1_NEW_DOC}.
318350
*/
319351
@Test
320-
public void copyPreserveXmlToNonExistentAsDBA() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
352+
public void copyPreserveXmlToNonExistentAsDBA() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
321353
final Subject adminUser = existWebServer.getBrokerPool().getSecurityManager().authenticate(ADMIN_DB_USER, ADMIN_DB_PWD);
322354
final long doc1LastModified = getLastModified(USER1_DOC1);
355+
Thread.sleep(5);
323356
copyDoc(adminUser, PRESERVE, USER1_DOC1, USER1_NEW_DOC);
324357
checkAttributes(USER1_NEW_DOC, USER1_NAME, USER1_NAME, USER1_DOC1_MODE, equalTo(doc1LastModified), equalTo(doc1LastModified));
325358
}
@@ -329,9 +362,10 @@ public void copyPreserveXmlToNonExistentAsDBA() throws AuthenticationException,
329362
* as a DBA copy {@link #USER1_BIN_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER1_NEW_BIN_DOC}.
330363
*/
331364
@Test
332-
public void copyPreserveBinaryToNonExistentAsDBA() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
365+
public void copyPreserveBinaryToNonExistentAsDBA() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
333366
final Subject adminUser = existWebServer.getBrokerPool().getSecurityManager().authenticate(ADMIN_DB_USER, ADMIN_DB_PWD);
334367
final long binDoc1LastModified = getLastModified(USER1_BIN_DOC1);
368+
Thread.sleep(5);
335369
copyDoc(adminUser, PRESERVE, USER1_BIN_DOC1, USER1_NEW_BIN_DOC);
336370
checkAttributes(USER1_NEW_BIN_DOC, USER1_NAME, USER1_NAME, USER1_BIN_DOC1_MODE, equalTo(binDoc1LastModified), equalTo(binDoc1LastModified));
337371
}
@@ -367,9 +401,10 @@ public void copyPreserveBinaryToExistentAsDBA() throws AuthenticationException,
367401
* as some other (non-owner) user copy {@link #USER1_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER2_NEW_DOC}.
368402
*/
369403
@Test
370-
public void copyPreserveXmlToNonExistentAsOther() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
404+
public void copyPreserveXmlToNonExistentAsOther() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
371405
final Subject user2 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER2_NAME, USER2_PWD);
372406
final long doc1LastModified = getLastModified(USER1_DOC1);
407+
Thread.sleep(5);
373408
copyDoc(user2, PRESERVE, USER1_DOC1, USER2_NEW_DOC);
374409
checkAttributes(USER2_NEW_DOC, USER2_NAME, USER2_NAME, USER1_DOC1_MODE, equalTo(doc1LastModified), equalTo(doc1LastModified));
375410
}
@@ -379,9 +414,10 @@ public void copyPreserveXmlToNonExistentAsOther() throws AuthenticationException
379414
* some other (non-owner) user copy {@link #USER1_BIN_DOC1} from {@link TestConstants#TEST_COLLECTION_URI} to non-existent {@link #USER1_NEW_BIN_DOC}.
380415
*/
381416
@Test
382-
public void copyPreserveBinaryToNonExistentAsOther() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException {
417+
public void copyPreserveBinaryToNonExistentAsOther() throws AuthenticationException, LockException, PermissionDeniedException, EXistException, IOException, TriggerException, InterruptedException {
383418
final Subject user2 = existWebServer.getBrokerPool().getSecurityManager().authenticate(USER2_NAME, USER2_PWD);
384419
final long binDoc1LastModified = getLastModified(USER1_BIN_DOC1);
420+
Thread.sleep(5);
385421
copyDoc(user2, PRESERVE, USER1_BIN_DOC1, USER2_NEW_BIN_DOC);
386422
checkAttributes(USER2_NEW_BIN_DOC, USER2_NAME, USER2_NAME, USER1_BIN_DOC1_MODE, equalTo(binDoc1LastModified), equalTo(binDoc1LastModified));
387423
}

0 commit comments

Comments
 (0)