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

Maxim Thomas
03.30.2025 61dac86bceb9d727e1bd707982c41ab9467c6d5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2007-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.replication;
 
import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.Requests.newSearchRequest;
import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
 
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
 
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.MemoryBackend;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.replication.common.CSNGenerator;
import org.opends.server.replication.plugin.DomainFakeCfg;
import org.opends.server.replication.plugin.LDAPReplicationDomain;
import org.opends.server.replication.plugin.MultimasterReplication;
import org.opends.server.replication.protocol.AddMsg;
import org.opends.server.replication.protocol.DeleteMsg;
import org.opends.server.replication.protocol.ModifyDNMsg;
import org.opends.server.replication.protocol.ModifyMsg;
import org.opends.server.replication.server.ReplServerFakeConfiguration;
import org.opends.server.replication.server.ReplicationServer;
import org.opends.server.replication.service.ReplicationBroker;
import org.opends.server.types.Attributes;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
 
/**
 * Test that the dependencies are computed correctly when replaying
 * sequences of operations that requires to follow a given order
 * such as : ADD an entry, ADD a children entry.
 */
@SuppressWarnings("javadoc")
public class DependencyTest extends ReplicationTestCase
{
 
  private final long CLEAN_DB_GENERATION_ID = 7883L;
  private DN TEST_ROOT_DN;
 
 
  @BeforeClass
  public void setup() throws Exception
  {
     TEST_ROOT_DN = DN.valueOf(TEST_ROOT_DN_STRING);
  }
 
  /**
   * Check that a sequence of dependents adds and mods is correctly ordered:
   * Using a deep dit :
   *    TEST_ROOT_DN_STRING
   *       |
   *    dc=dependency1
   *       |
   *    dc=dependency2
   *       |
   *    dc=dependency3
   *       |
   *
   *       |
   *    dc=dependencyN
   * This test sends a sequence of interleaved ADD operations and MODIFY
   * operations to build such a dit.
   *
   * Then test that the sequence of Delete necessary to remove
   * all those entries is also correctly ordered.
   */
  @Test(enabled=true, groups="slow")
  public void addModDelDependencyTest() throws Exception
  {
    ReplicationServer replServer = null;
    LDAPReplicationDomain domain = null;
    DN baseDN = TEST_ROOT_DN;
    int brokerId = 2;
    int serverId = 1;
    int replServerId = 81;
    int addSequenceLength = 30;
 
 
    cleanDB();
 
    try
    {
      /*
       * FIRST PART :
       * Check that a sequence of dependent ADD is correctly ordered.
       *
       * - Create replication server
       * - Send sequence of ADD messages to the replication server
       * - Configure replication server
       * - check that the last entry has been correctly added
       */
      Entry entry = TestCaseUtils.makeEntry(
          "dn:" + TEST_ROOT_DN_STRING,
          "objectClass: top",
          "objectClass: organization",
          "entryuuid: " + stringUID(1));
 
      replServer = newReplicationServer(
          replServerId, addSequenceLength * 5 + 100, "dependencyTestAddModDelDependencyTestDb");
 
      ReplicationBroker broker = openReplicationSession(
          baseDN, brokerId, 1000, replServer.getReplicationPort(), 1000, CLEAN_DB_GENERATION_ID);
 
      Thread.sleep(2000);
 
      // send a sequence of add operation
      DN addDN = TEST_ROOT_DN;
      CSNGenerator gen = new CSNGenerator(brokerId, 0L);
 
      int sequence;
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        entry.removeAttribute(getEntryUUIDAttributeType());
        entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
                           new LinkedList<ByteString>());
        addDN = DN.valueOf("dc=dependency" + sequence + "," + addDN);
        broker.publish(addMsg(addDN, entry, sequence + 1, sequence, gen));
        broker.publish(modifyMsg(addDN, sequence + 1, generatemods("description", "test"), gen));
      }
 
      // configure and start replication of TEST_ROOT_DN_STRING on the server
      domain = startNewLDAPReplicationDomain(replServer, baseDN, serverId, 100000);
 
      // check that last entry in sequence got added.
      Entry lastEntry = getEntry(addDN, 30000, true);
      assertNotNull(lastEntry,
                    "The last entry of the ADD sequence was not added.");
 
      // Check that all the modify have been replayed
      // (all the entries should have a description).
      addDN = TEST_ROOT_DN;
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        addDN = DN.valueOf("dc=dependency" + sequence + "," + addDN);
        checkEntryHasAttributeValue(
            addDN, "description", "test", 10, "The modification was not replayed on entry " + addDN);
      }
 
      /*
       * SECOND PART
       *
       * Now check that the dependencies between delete are correctly
       * managed.
       *
       * disable the domain while we publish the delete message to
       * to replication server so that when we enable it it receives the
       * delete operation in bulk.
       */
 
      domain.disable();
      Thread.sleep(2000);  // necessary because disable does not wait
                           // for full termination of all threads. (issue 1571)
 
      DN deleteDN = addDN;
      while (sequence-->1)
      {
        broker.publish(delMsg(deleteDN, sequence + 1, gen));
        deleteDN = deleteDN.parent();
      }
 
      domain.enable();
 
      // check that entry just below the base entry was deleted.
      // (we can't delete the base entry because some other tests might
      // have added other children)
      DN node1 = DN.valueOf("dc=dependency1," + TEST_ROOT_DN_STRING);
      Entry baseEntry = getEntry(node1, 30000, false);
      assertNull(baseEntry,
                 "The last entry of the DEL sequence was not deleted.");
    }
    finally
    {
      remove(replServer);
      if (domain != null)
      {
        MultimasterReplication.deleteDomain(baseDN);
      }
    }
  }
 
  private AddMsg addMsg(DN addDN, Entry entry, int uniqueId, int parentId, CSNGenerator gen)
  {
    return new AddMsg(gen.newCSN(), addDN, stringUID(uniqueId), stringUID(parentId),
        entry.getObjectClassAttribute(), entry.getAllAttributes(), null);
  }
 
  private ModifyMsg modifyMsg(DN dn, int entryUUID, List<Modification> mods, CSNGenerator gen)
  {
    return new ModifyMsg(gen.newCSN(), dn, mods, stringUID(entryUUID));
  }
 
  private DeleteMsg delMsg(DN delDN, int entryUUID, CSNGenerator gen)
  {
    return new DeleteMsg(delDN, gen.newCSN(), stringUID(entryUUID));
  }
 
  private ModifyDNMsg modDNMsg(DN dn, String newRDN, int entryUUID, int newSuperiorEntryUUID, CSNGenerator gen)
  {
    return new ModifyDNMsg(dn, gen.newCSN(), stringUID(entryUUID), stringUID(newSuperiorEntryUUID), true, null, newRDN);
  }
 
  /**
   * Check the dependency between moddn and delete operation
   * when an entry is renamed to a new dn and then deleted.
   * Disabled: need investigations to fix random failures
   */
  @Test(enabled=false)
  public void moddnDelDependencyTest() throws Exception
  {
    ReplicationServer replServer = null;
    LDAPReplicationDomain domain = null;
    DN baseDN = TEST_ROOT_DN;
    int brokerId = 2;
    int serverId = 1;
    int replServerId = 82;
 
    cleanDB();
 
    try
    {
      // Create replication server, replication domain and broker.
      Entry entry = TestCaseUtils.makeEntry(
          "dn:" + TEST_ROOT_DN_STRING,
          "objectClass: top",
          "objectClass: organization");
 
      CSNGenerator gen = new CSNGenerator(brokerId, 0L);
      int renamedEntryUuid = 100;
 
      replServer = newReplicationServer(replServerId, 200, "dependencyTestModdnDelDependencyTestDb");
 
      // configure and start replication of TEST_ROOT_DN_STRING on the server
      Thread.sleep(2000);
      domain = startNewLDAPReplicationDomain(replServer, baseDN, serverId, 100000);
 
      ReplicationBroker broker = openReplicationSession(
          baseDN, brokerId, 1000, replServer.getReplicationPort(), 1000, CLEAN_DB_GENERATION_ID);
 
      // add an entry to play with.
      entry.removeAttribute(getEntryUUIDAttributeType());
      entry.addAttribute(Attributes.create("entryuuid",
                         stringUID(renamedEntryUuid)),
                         new LinkedList<ByteString>());
      DN addDN = DN.valueOf("dc=moddndel" + "," + TEST_ROOT_DN_STRING);
      broker.publish(addMsg(addDN, entry, renamedEntryUuid, 1, gen));
 
      // check that the entry was correctly added
      checkEntryHasAttributeValue(addDN, "entryuuid", stringUID(renamedEntryUuid), 30, "The initial entry add failed");
 
      // disable the domain to make sure that the messages are all sent in a row.
      domain.disable();
 
      // rename and delete the entry.
      broker.publish(modDNMsg(addDN, "dc=new_name", renamedEntryUuid, 1, gen));
      DN delDN = DN.valueOf("dc=new_name" + "," + TEST_ROOT_DN_STRING);
      broker.publish(delMsg(delDN, renamedEntryUuid, gen));
 
      // enable back the domain to trigger message replay.
      domain.enable();
 
      // check that entry does not exist anymore.
      checkEntryHasNoSuchAttributeValue(DN.valueOf("dc=new_name" + "," + TEST_ROOT_DN_STRING), "entryuuid",
          stringUID(renamedEntryUuid), 30, "The delete dependencies was not correctly enforced");
    }
    finally
    {
      remove(replServer);
      if (domain != null)
      {
        MultimasterReplication.deleteDomain(baseDN);
      }
    }
  }
 
  /**
   * Clean the database and replace with a single entry.
   *
   * @throws FileNotFoundException
   * @throws IOException
   * @throws Exception
   */
  private void cleanDB() throws FileNotFoundException, IOException, Exception
  {
    // Clear backend
    TestCaseUtils.initializeTestBackend(false);
 
    // Create top entry with uuid
    Entry topEntry = TestCaseUtils.makeEntry(
        "dn:" + TEST_ROOT_DN_STRING,
         "objectClass: top",
         "objectClass: organization",
         "o: test",
         "entryuuid: " + stringUID(1));
 
    MemoryBackend memoryBackend =
        (MemoryBackend) TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackendById(TEST_BACKEND_ID);
    memoryBackend.addEntry(topEntry, null);
  }
 
 
  /**
   * Check that after a sequence of add/del/add done on the same DN
   * the second entry is in the database.
   * The unique id of the entry is used to check that the correct entry
   * has been added.
   * To increase the risks of failures a loop of add/del/add is done.
   */
  @Test(enabled=true, groups="slow")
  public void addDelAddDependencyTest() throws Exception
  {
    ReplicationServer replServer = null;
    LDAPReplicationDomain domain = null;
    DN baseDN = TEST_ROOT_DN;
    int brokerId = 2;
    int serverId = 1;
    int replServerId = 83;
    int addSequenceLength = 30;
 
    cleanDB();
 
    try
    {
      Entry entry = TestCaseUtils.makeEntry(
          "dn:" + TEST_ROOT_DN_STRING,
          "objectClass: top",
          "objectClass: organization");
 
      replServer = newReplicationServer(
          replServerId, 5 * addSequenceLength + 100, "dependencyTestAddDelAddDependencyTestDb");
 
      ReplicationBroker broker = openReplicationSession(
          baseDN, brokerId, 100, replServer.getReplicationPort(), 1000, CLEAN_DB_GENERATION_ID);
 
      // send a sequence of add/del/add operations
      CSNGenerator gen = new CSNGenerator(brokerId, 0L);
 
      int sequence;
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        // add the entry a first time
        entry.removeAttribute(getEntryUUIDAttributeType());
        entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
                           new LinkedList<ByteString>());
        DN addDN = DN.valueOf("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING);
        broker.publish(addMsg(addDN, entry, sequence + 1, 1, gen));
        broker.publish(delMsg(addDN, sequence + 1, gen));
 
        // add again the entry with a new entryuuid.
        entry.removeAttribute(getEntryUUIDAttributeType());
        entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1025)),
                           new LinkedList<ByteString>());
        broker.publish(addMsg(addDN, entry, sequence + 1025, 1, gen));
      }
 
      domain = startNewLDAPReplicationDomain(replServer, baseDN, serverId, -1);
 
      // check that all entries have been deleted and added
      // again by checking that they do have the correct entryuuid
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        String addDn = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING;
        checkEntryHasAttributeValue(DN.valueOf(addDn), "entryuuid", stringUID(sequence + 1025), 30,
            "The second add was not replayed on entry " + addDn);
      }
 
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        DN deleteDN = DN.valueOf("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING);
        broker.publish(delMsg(deleteDN, sequence + 1025, gen));
      }
 
      // check that the database was cleaned successfully
      DN node1 = DN.valueOf("dc=dependency1," + TEST_ROOT_DN_STRING);
      Entry baseEntry = getEntry(node1, 30000, false);
      assertNull(baseEntry,
        "The entry were not removed succesfully after test completion.");
    }
    finally
    {
      remove(replServer);
      if (domain != null)
      {
        MultimasterReplication.deleteDomain(baseDN);
      }
    }
  }
 
  private ReplicationServer newReplicationServer(int replServerId, int windowSize, String dirName) throws Exception
  {
    int replServerPort = TestCaseUtils.findFreePort();
    return new ReplicationServer(new ReplServerFakeConfiguration(
        replServerPort, dirName, 0, replServerId, 0, windowSize, null));
  }
 
  private LDAPReplicationDomain startNewLDAPReplicationDomain(ReplicationServer replServer, DN baseDN, int serverId,
      int heartBeatInterval) throws ConfigException
  {
    SortedSet<String> replServers = newTreeSet("localhost:" + replServer.getReplicationPort());
    DomainFakeCfg domainConf = new DomainFakeCfg(baseDN, serverId, replServers);
    if (heartBeatInterval > 0)
    {
      domainConf.setHeartbeatInterval(heartBeatInterval);
    }
    LDAPReplicationDomain domain = MultimasterReplication.createNewDomain(domainConf);
    domain.start();
    return domain;
  }
 
  /**
   * Check that the dependency of moddn operation are working by
   * issuing a set of Add operation followed by a modrdn of the added entry.
   */
  @Test(enabled=true, groups="slow")
  public void addModdnDependencyTest() throws Exception
  {
    ReplicationServer replServer = null;
    LDAPReplicationDomain domain = null;
    DN baseDN = TEST_ROOT_DN;
    int brokerId = 2;
    int serverId = 1;
    int replServerId = 84;
    int addSequenceLength = 51 * 10; //exceed late queue threshold in org.opends.server.replication.server.MessageHandler
 
    cleanDB();
 
    try
    {
      Entry entry = TestCaseUtils.makeEntry(
          "dn:" + TEST_ROOT_DN_STRING,
          "objectClass: top",
          "objectClass: organization");
 
      replServer = newReplicationServer(
          replServerId, 5 * addSequenceLength + 100, "dependencyTestAddModdnDependencyTestDb");
 
      ReplicationBroker broker = openReplicationSession(
          baseDN, brokerId, 100, replServer.getReplicationPort(), 1000, CLEAN_DB_GENERATION_ID);
 
 
      DN addDN = TEST_ROOT_DN;
      CSNGenerator gen = new CSNGenerator(brokerId, 0L);
 
      // send a sequence of add/modrdn operations
      int sequence;
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        // add the entry
        entry.removeAttribute(getEntryUUIDAttributeType());
        entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
                           new LinkedList<ByteString>());
        addDN = DN.valueOf("dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING);
        broker.publish(addMsg(addDN, entry, sequence + 1, 1, gen));
 
        // rename the entry
        broker.publish(modDNMsg(addDN, "dc=new_dep" + sequence, sequence + 1, 1, gen));
      }
 
      // configure and start replication of TEST_ROOT_DN_STRING on the server
      domain = startNewLDAPReplicationDomain(replServer, baseDN, serverId, -1);
 
      // check that all entries have been renamed
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        addDN = DN.valueOf("dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING);
        Entry baseEntry = getEntry(addDN, 30000, true);
        assertNotNull(baseEntry,
          "The rename was not applied correctly on :" + addDN);
      }
 
      // delete the entries to clean the database.
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        addDN = DN.valueOf("dc=new_dep" + sequence + "," + TEST_ROOT_DN_STRING);
        broker.publish(delMsg(addDN, sequence + 1, gen));
      }
    }
    finally
    {
      remove(replServer);
      if (domain != null)
      {
        MultimasterReplication.deleteDomain(baseDN);
      }
    }
  }
 
  /**
   * Builds and return a uuid from an integer.
   * This methods assume that unique integers are used and does not make any
   * unicity checks. It is only responsible for generating a uid with a
   * correct syntax.
   */
  private String stringUID(int i)
  {
    return String.format("11111111-1111-1111-1111-%012x", i);
  }
 
  /**
   * Check that a sequence of dependents adds and mods is correctly ordered:
   * Using a deep dit :
   *    TEST_ROOT_DN_STRING
   *       |
   *    dc=dependency1
   *       |
   *    dc=dependency2
   *       |
   *    dc=dependency3
   *       |
   *
   *       |
   *    dc=dependencyN
   *
   * This test sends a sequence of ADD operations to build such a dit.
   * But every 4 entry is sent as if from a different ReplicaID.
   * It expects all entries under each other (no conflict due to missing parent).
   * This test was built to exercise OPENDJ-3343
   *
   */
  @Test(enabled=false)
  public void addMultipleServersDependencyTest() throws Exception
  {
    ReplicationServer replServer = null;
    LDAPReplicationDomain domain = null;
    DN baseDN = TEST_ROOT_DN;
    int brokerId = 2;
    int serverId = 1;
    int replServerId = 81;
    int addSequenceLength = 30;
 
 
    cleanDB();
 
    try
    {
      /*
       * Check that a sequence of dependent ADD is correctly ordered.
       *
       * - Create replication server
       * - Send sequence of ADD messages to the replication server
       * - Configure replication server
       * - check that the last entry has been correctly added
       */
      Entry entry = TestCaseUtils.makeEntry(
              "dn:" + TEST_ROOT_DN_STRING,
              "objectClass: top",
              "objectClass: organization",
              "entryuuid: " + stringUID(1));
 
      replServer = newReplicationServer(
              replServerId, addSequenceLength * 5 + 100, "dependencyTestAddModDelDependencyTestDb");
 
      ReplicationBroker broker = openReplicationSession(
              baseDN, brokerId, 1000, replServer.getReplicationPort(), 1000, CLEAN_DB_GENERATION_ID);
 
      Thread.sleep(2000);
 
      // send a sequence of add operation
      DN addDN = TEST_ROOT_DN;
      CSNGenerator gen = new CSNGenerator(brokerId, 0L);
      CSNGenerator gen2 = new CSNGenerator(brokerId + 10, 0L);
      ArrayList<ByteString> dupValues = new ArrayList<>();
 
      int sequence;
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        entry.removeAttribute(getEntryUUIDAttributeType());
        entry.removeAttribute(getDescriptionAttributeType());
        entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)), (Collection<ByteString>)dupValues);
        entry.addAttribute(Attributes.create("description", "test" + sequence), (Collection<ByteString>)dupValues);
        addDN = DN.valueOf("dc=dependency" + sequence + "," + addDN);
        // Every 4 entry has a CSN from a different ID
        broker.publish(addMsg(addDN, entry, sequence + 1, sequence, sequence %4 == 0 ? gen2 : gen));
      }
 
      // configure and start replication of TEST_ROOT_DN_STRING on the server
      domain = startNewLDAPReplicationDomain(replServer, baseDN, serverId, 100000);
 
      sleep(10000);
 
      // Check that all the entries have been replayed properly (no conflict)
      // (all the entries should have a description)
      addDN = TEST_ROOT_DN;
 
      // This is just debugging output to visualize the problem
      dumpAllEntries(addDN);
 
      for (sequence = 1; sequence<=addSequenceLength; sequence ++)
      {
        addDN = DN.valueOf("dc=dependency" + sequence + "," + addDN);
        Entry e = getEntry(addDN, 10000, true);
        assertNotNull(e, "The following entry was not added properly: " + addDN);
        // checkEntryHasAttributeValue(
        //        addDN, "description", "test" + sequence, 10, "Replication Error with entry " + addDN);
      }
    }
    finally
    {
      remove(replServer);
      if (domain != null)
      {
        MultimasterReplication.deleteDomain(baseDN);
      }
    }
  }
 
  private void dumpAllEntries(DN aDN) throws DirectoryException
  {
    final SearchRequest request = newSearchRequest(aDN, SearchScope.WHOLE_SUBTREE, "&");
    InternalSearchOperation searchOperation = connection.processSearch(request);
    ResultCode res = searchOperation.getResultCode();
    assertEquals(res, ResultCode.SUCCESS, "Error while searching all entries for " + aDN);
    for (Entry entry : searchOperation.getSearchEntries())
    {
      System.out.println(entry.toString());
    }
  }
}