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

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.