Add more debug logging for DTCL registration/notification code paths
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / sharding / DistributedShardedDOMDataTreeTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.sharding;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.mockito.Matchers.anyCollection;
14 import static org.mockito.Matchers.anyMap;
15 import static org.mockito.Mockito.doNothing;
16 import static org.mockito.Mockito.doReturn;
17 import static org.mockito.Mockito.mock;
18 import static org.mockito.Mockito.timeout;
19 import static org.mockito.Mockito.verify;
20 import static org.mockito.Mockito.verifyNoMoreInteractions;
21 import static org.opendaylight.controller.cluster.datastore.IntegrationTestKit.findLocalShard;
22 import static org.opendaylight.controller.cluster.datastore.IntegrationTestKit.waitUntilShardIsDown;
23
24 import akka.actor.ActorRef;
25 import akka.actor.ActorSystem;
26 import akka.actor.Address;
27 import akka.actor.AddressFromURIString;
28 import akka.cluster.Cluster;
29 import akka.testkit.JavaTestKit;
30 import com.google.common.base.Optional;
31 import com.google.common.collect.Lists;
32 import com.google.common.util.concurrent.CheckedFuture;
33 import com.typesafe.config.ConfigFactory;
34 import java.util.ArrayList;
35 import java.util.Collection;
36 import java.util.Collections;
37 import java.util.List;
38 import java.util.Map;
39 import java.util.Set;
40 import java.util.concurrent.CompletionStage;
41 import org.junit.After;
42 import org.junit.Assert;
43 import org.junit.Before;
44 import org.junit.Test;
45 import org.mockito.ArgumentCaptor;
46 import org.mockito.Captor;
47 import org.mockito.Mockito;
48 import org.mockito.MockitoAnnotations;
49 import org.opendaylight.controller.cluster.ActorSystemProvider;
50 import org.opendaylight.controller.cluster.access.concepts.MemberName;
51 import org.opendaylight.controller.cluster.datastore.AbstractTest;
52 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
53 import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder;
54 import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
55 import org.opendaylight.controller.cluster.datastore.IntegrationTestKit;
56 import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils;
57 import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
58 import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
59 import org.opendaylight.controller.cluster.sharding.DistributedShardFactory.DistributedShardRegistration;
60 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
61 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
62 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
63 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
64 import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
65 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
66 import org.opendaylight.mdsal.dom.api.DOMDataTreeListener;
67 import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
68 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
69 import org.opendaylight.yangtools.yang.common.QName;
70 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
71 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
72 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
73 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
74 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
75 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
76 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
77 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
78 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
79 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
80 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
81 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
82 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
83 import org.slf4j.Logger;
84 import org.slf4j.LoggerFactory;
85
86 public class DistributedShardedDOMDataTreeTest extends AbstractTest {
87
88     private static final Logger LOG = LoggerFactory.getLogger(DistributedShardedDOMDataTreeRemotingTest.class);
89
90     private static final Address MEMBER_1_ADDRESS =
91             AddressFromURIString.parse("akka.tcp://cluster-test@127.0.0.1:2558");
92
93     private static final DOMDataTreeIdentifier TEST_ID =
94             new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
95
96     private static final DOMDataTreeIdentifier INNER_LIST_ID =
97             new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
98                     YangInstanceIdentifier.create(getOuterListIdFor(0).getPathArguments())
99                             .node(TestModel.INNER_LIST_QNAME));
100     private static final Set<MemberName> SINGLE_MEMBER = Collections.singleton(AbstractTest.MEMBER_NAME);
101
102     private static final String MODULE_SHARDS_CONFIG = "module-shards-cars-member-1.conf";
103
104     private ActorSystem leaderSystem;
105
106     private final Builder leaderDatastoreContextBuilder =
107             DatastoreContext.newBuilder()
108                     .shardHeartbeatIntervalInMillis(100)
109                     .shardElectionTimeoutFactor(2)
110                     .logicalStoreType(
111                             org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION);
112
113     private DistributedDataStore leaderDistributedDataStore;
114     private DistributedDataStore operDistributedDatastore;
115     private IntegrationTestKit leaderTestKit;
116
117     private DistributedShardedDOMDataTree leaderShardFactory;
118
119     @Captor
120     private ArgumentCaptor<Collection<DataTreeCandidate>> captorForChanges;
121     @Captor
122     private ArgumentCaptor<Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>>> captorForSubtrees;
123
124     private ActorSystemProvider leaderSystemProvider;
125
126     @Before
127     public void setUp() {
128         MockitoAnnotations.initMocks(this);
129
130         InMemoryJournal.clear();
131         InMemorySnapshotStore.clear();
132
133         leaderSystem = ActorSystem.create("cluster-test", ConfigFactory.load().getConfig("Member1"));
134         Cluster.get(leaderSystem).join(MEMBER_1_ADDRESS);
135
136         leaderSystemProvider = Mockito.mock(ActorSystemProvider.class);
137         doReturn(leaderSystem).when(leaderSystemProvider).getActorSystem();
138     }
139
140     @After
141     public void tearDown() throws Exception {
142         if (leaderDistributedDataStore != null) {
143             leaderDistributedDataStore.close();
144         }
145
146         if (operDistributedDatastore != null) {
147             operDistributedDatastore.close();
148         }
149
150         JavaTestKit.shutdownActorSystem(leaderSystem);
151
152         InMemoryJournal.clear();
153         InMemorySnapshotStore.clear();
154     }
155
156     private void initEmptyDatastores() throws Exception {
157         leaderTestKit = new IntegrationTestKit(leaderSystem, leaderDatastoreContextBuilder);
158
159         leaderDistributedDataStore = leaderTestKit.setupDistributedDataStore(
160                 "config", MODULE_SHARDS_CONFIG, "empty-modules.conf", true,
161                 SchemaContextHelper.distributedShardedDOMDataTreeSchemaContext());
162
163         operDistributedDatastore = leaderTestKit.setupDistributedDataStore(
164                 "operational", MODULE_SHARDS_CONFIG, "empty-modules.conf",true,
165                 SchemaContextHelper.distributedShardedDOMDataTreeSchemaContext());
166
167         leaderShardFactory = new DistributedShardedDOMDataTree(leaderSystemProvider,
168                 operDistributedDatastore,
169                 leaderDistributedDataStore);
170
171         leaderShardFactory.init();
172     }
173
174
175     @Test
176     public void testWritesIntoDefaultShard() throws Exception {
177         initEmptyDatastores();
178
179         final DOMDataTreeIdentifier configRoot =
180                 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
181
182         final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(configRoot));
183
184         final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(true);
185         final DOMDataTreeWriteCursor cursor =
186                 tx.createCursor(new DOMDataTreeIdentifier(
187                         LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY));
188         Assert.assertNotNull(cursor);
189
190         final ContainerNode test =
191                 ImmutableContainerNodeBuilder.create()
192                         .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
193
194         cursor.write(test.getIdentifier(), test);
195         cursor.close();
196
197         tx.submit().checkedGet();
198     }
199
200     @Test
201     public void testSingleNodeWrites() throws Exception {
202         initEmptyDatastores();
203
204         final DistributedShardRegistration shardRegistration = waitOnAsyncTask(
205                 leaderShardFactory.createDistributedShard(TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
206                 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
207
208         leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
209                 ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()));
210
211         final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(TEST_ID));
212
213         final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(true);
214         final DOMDataTreeWriteCursor cursor = tx.createCursor(TEST_ID);
215         Assert.assertNotNull(cursor);
216         final YangInstanceIdentifier nameId =
217                 YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(TestModel.NAME_QNAME).build();
218         final LeafNode<String> valueToCheck = ImmutableLeafNodeBuilder.<String>create().withNodeIdentifier(
219                 new NodeIdentifier(TestModel.NAME_QNAME)).withValue("Test Value").build();
220         LOG.debug("Writing data {} at {}, cursor {}", nameId.getLastPathArgument(), valueToCheck, cursor);
221         cursor.write(nameId.getLastPathArgument(),
222                 valueToCheck);
223
224         cursor.close();
225         LOG.debug("Got to pre submit");
226
227         tx.submit().checkedGet();
228
229         final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
230         doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
231
232         leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID),
233                 true, Collections.emptyList());
234
235         verify(mockedDataTreeListener, timeout(1000).times(1)).onDataTreeChanged(captorForChanges.capture(),
236                 captorForSubtrees.capture());
237         final List<Collection<DataTreeCandidate>> capturedValue = captorForChanges.getAllValues();
238
239         final Optional<NormalizedNode<?, ?>> dataAfter =
240                 capturedValue.get(0).iterator().next().getRootNode().getDataAfter();
241
242         final NormalizedNode<?,?> expected = ImmutableContainerNodeBuilder.create()
243                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).withChild(valueToCheck).build();
244         assertEquals(expected, dataAfter.get());
245
246         verifyNoMoreInteractions(mockedDataTreeListener);
247
248         shardRegistration.close().toCompletableFuture().get();
249
250     }
251
252     @Test
253     public void testMultipleWritesIntoSingleMapEntry() throws Exception {
254         initEmptyDatastores();
255
256         final DistributedShardRegistration shardRegistration = waitOnAsyncTask(
257                 leaderShardFactory.createDistributedShard(TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
258                 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
259
260         leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
261                 ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()));
262
263         LOG.warn("Got after waiting for nonleader");
264         final ActorRef leaderShardManager = leaderDistributedDataStore.getActorContext().getShardManager();
265
266         leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
267                 ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
268
269         final YangInstanceIdentifier oid1 = getOuterListIdFor(0);
270         final DOMDataTreeIdentifier outerListPath = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, oid1);
271
272         final DistributedShardRegistration outerListShardReg = waitOnAsyncTask(
273                 leaderShardFactory.createDistributedShard(outerListPath, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
274                 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
275
276         leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
277                 ClusterUtils.getCleanShardName(outerListPath.getRootIdentifier()));
278
279         final DOMDataTreeProducer shardProducer = leaderShardFactory.createProducer(
280                 Collections.singletonList(outerListPath));
281
282         final DOMDataTreeCursorAwareTransaction tx = shardProducer.createTransaction(false);
283         final DOMDataTreeWriteCursor cursor =
284                 tx.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, oid1));
285         assertNotNull(cursor);
286
287         MapNode innerList = ImmutableMapNodeBuilder
288                 .create()
289                 .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
290                 .build();
291
292         cursor.write(new NodeIdentifier(TestModel.INNER_LIST_QNAME), innerList);
293         cursor.close();
294         tx.submit().checkedGet();
295
296         final ArrayList<CheckedFuture<Void, TransactionCommitFailedException>> futures = new ArrayList<>();
297         for (int i = 0; i < 1000; i++) {
298             final Collection<MapEntryNode> innerListMapEntries = createInnerListMapEntries(1000, "run-" + i);
299             for (final MapEntryNode innerListMapEntry : innerListMapEntries) {
300                 final DOMDataTreeCursorAwareTransaction tx1 = shardProducer.createTransaction(false);
301                 final DOMDataTreeWriteCursor cursor1 = tx1.createCursor(
302                         new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
303                                 oid1.node(new NodeIdentifier(TestModel.INNER_LIST_QNAME))));
304                 cursor1.write(innerListMapEntry.getIdentifier(), innerListMapEntry);
305                 cursor1.close();
306                 futures.add(tx1.submit());
307             }
308         }
309
310         futures.get(futures.size() - 1).checkedGet();
311
312         final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
313         doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
314
315         leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_LIST_ID),
316                 true, Collections.emptyList());
317
318         verify(mockedDataTreeListener, timeout(1000).times(1)).onDataTreeChanged(captorForChanges.capture(),
319                 captorForSubtrees.capture());
320         verifyNoMoreInteractions(mockedDataTreeListener);
321         final List<Collection<DataTreeCandidate>> capturedValue = captorForChanges.getAllValues();
322
323         final NormalizedNode<?,?> expected =
324                 ImmutableMapNodeBuilder
325                         .create()
326                         .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
327                                 // only the values from the last run should be present
328                         .withValue(createInnerListMapEntries(1000, "run-999"))
329                         .build();
330
331         assertEquals("List values dont match the expected values from the last run",
332                 expected, capturedValue.get(0).iterator().next().getRootNode().getDataAfter().get());
333
334     }
335
336     // top level shard at TEST element, with subshards on each outer-list map entry
337     @Test
338     public void testMultipleShardLevels() throws Exception {
339         initEmptyDatastores();
340
341         final DistributedShardRegistration testShardReg = waitOnAsyncTask(
342                 leaderShardFactory.createDistributedShard(TEST_ID, SINGLE_MEMBER),
343                 DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
344
345         final ArrayList<DistributedShardRegistration> registrations = new ArrayList<>();
346         final int listSize = 5;
347         for (int i = 0; i < listSize; i++) {
348             final YangInstanceIdentifier entryYID = getOuterListIdFor(i);
349             final CompletionStage<DistributedShardRegistration> future = leaderShardFactory.createDistributedShard(
350                     new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, entryYID), SINGLE_MEMBER);
351
352             registrations.add(waitOnAsyncTask(future, DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION));
353         }
354
355         final DOMDataTreeIdentifier rootId =
356                 new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
357         final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singletonList(
358                 rootId));
359
360         DOMDataTreeCursorAwareTransaction transaction = producer.createTransaction(false);
361
362         DOMDataTreeWriteCursor cursor = transaction.createCursor(rootId);
363         assertNotNull(cursor);
364
365         final MapNode outerList =
366                 ImmutableMapNodeBuilder.create()
367                         .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME)).build();
368
369         final ContainerNode testNode =
370                 ImmutableContainerNodeBuilder.create()
371                         .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
372                         .withChild(outerList)
373                         .build();
374
375         cursor.write(testNode.getIdentifier(), testNode);
376
377         cursor.close();
378         transaction.submit().checkedGet();
379
380         final DOMDataTreeListener mockedDataTreeListener = mock(DOMDataTreeListener.class);
381         doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap());
382
383         final MapNode wholeList = ImmutableMapNodeBuilder.create(outerList)
384                 .withValue(createOuterEntries(listSize, "testing-values")).build();
385
386         transaction = producer.createTransaction(false);
387         cursor = transaction.createCursor(TEST_ID);
388         assertNotNull(cursor);
389
390         cursor.write(wholeList.getIdentifier(), wholeList);
391         cursor.close();
392
393         transaction.submit().checkedGet();
394
395         leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID),
396                 true, Collections.emptyList());
397
398         verify(mockedDataTreeListener, timeout(35000).atLeast(2)).onDataTreeChanged(captorForChanges.capture(),
399                 captorForSubtrees.capture());
400         verifyNoMoreInteractions(mockedDataTreeListener);
401         final List<Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>>> allSubtrees = captorForSubtrees.getAllValues();
402
403         final Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> lastSubtree = allSubtrees.get(allSubtrees.size() - 1);
404
405         final NormalizedNode<?, ?> actual = lastSubtree.get(TEST_ID);
406         assertNotNull(actual);
407
408         final NormalizedNode<?, ?> expected =
409                 ImmutableContainerNodeBuilder.create()
410                         .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
411                         .withChild(ImmutableMapNodeBuilder.create(outerList)
412                                 .withValue(createOuterEntries(listSize, "testing-values")).build())
413                         .build();
414
415
416         for (final DistributedShardRegistration registration : registrations) {
417             waitOnAsyncTask(registration.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
418         }
419
420         waitOnAsyncTask(testShardReg.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
421
422         assertEquals(expected, actual);
423     }
424
425     @Test
426     public void testMultipleRegistrationsAtOnePrefix() throws Exception {
427         initEmptyDatastores();
428
429         for (int i = 0; i < 10; i++) {
430             LOG.debug("Round {}", i);
431             final DistributedShardRegistration reg1 = waitOnAsyncTask(leaderShardFactory.createDistributedShard(
432                     TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)),
433                     DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
434
435             leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(),
436                     ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
437
438             assertNotNull(findLocalShard(leaderDistributedDataStore.getActorContext(),
439                     ClusterUtils.getCleanShardName(TestModel.TEST_PATH)));
440
441             waitOnAsyncTask(reg1.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION);
442
443             waitUntilShardIsDown(leaderDistributedDataStore.getActorContext(),
444                     ClusterUtils.getCleanShardName(TestModel.TEST_PATH));
445         }
446     }
447
448     private static Collection<MapEntryNode> createOuterEntries(final int amount, final String valuePrefix) {
449         final Collection<MapEntryNode> ret = new ArrayList<>();
450         for (int i = 0; i < amount; i++) {
451             ret.add(ImmutableNodes.mapEntryBuilder()
452                     .withNodeIdentifier(new NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME,
453                             QName.create(TestModel.OUTER_LIST_QNAME, "id"), i))
454                     .withChild(ImmutableNodes
455                             .leafNode(QName.create(TestModel.OUTER_LIST_QNAME, "id"), i))
456                     .withChild(createWholeInnerList(amount, "outer id: " + i + " " + valuePrefix))
457                     .build());
458         }
459
460         return ret;
461     }
462
463     private static MapNode createWholeInnerList(final int amount, final String valuePrefix) {
464         return ImmutableMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
465                 .withValue(createInnerListMapEntries(amount, valuePrefix)).build();
466     }
467
468     private static Collection<MapEntryNode> createInnerListMapEntries(final int amount, final String valuePrefix) {
469         final Collection<MapEntryNode> ret = new ArrayList<>();
470         for (int i = 0; i < amount; i++) {
471             ret.add(ImmutableNodes.mapEntryBuilder()
472                     .withNodeIdentifier(new NodeIdentifierWithPredicates(TestModel.INNER_LIST_QNAME,
473                             QName.create(TestModel.INNER_LIST_QNAME, "name"), Integer.toString(i)))
474                     .withChild(ImmutableNodes
475                             .leafNode(QName.create(TestModel.INNER_LIST_QNAME, "value"), valuePrefix + "-" + i))
476                     .build());
477         }
478
479         return ret;
480     }
481
482     private static YangInstanceIdentifier getOuterListIdFor(final int id) {
483         return TestModel.OUTER_LIST_PATH.node(new NodeIdentifierWithPredicates(
484                 TestModel.OUTER_LIST_QNAME, QName.create(TestModel.OUTER_LIST_QNAME, "id"), id));
485     }
486 }