X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2Fbugfix%2FDOMCodecBug01Test.java;h=5a98767ff863bc2f446db8566a6ff5505a8312dc;hb=a158ee12b65d80611aa7f2a34ab962ea795dccec;hp=4e7628fd06cc87254c2ce2df71a7b844070678d6;hpb=4e6f0838e508e0dce5dfa62faa29b43e979f5ef8;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug01Test.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug01Test.java index 4e7628fd06..5a98767ff8 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug01Test.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug01Test.java @@ -1,22 +1,22 @@ package org.opendaylight.controller.sal.binding.test.bugfix; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.Future; + + + import org.junit.Test; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder; @@ -24,21 +24,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -46,7 +46,6 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -68,17 +67,7 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest { private static final Map NODE_KEY_BI = Collections. singletonMap(NODE_ID_QNAME, NODE_ID); - private static final InstanceIdentifier NODES_INSTANCE_ID_BA = InstanceIdentifier.builder() // - .node(Nodes.class) // - .toInstance(); - - private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODES_INSTANCE_ID_BI = // - org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // - .node(Nodes.QNAME) // - .toInstance(); - - private static final InstanceIdentifier NODE_INSTANCE_ID_BA = InstanceIdentifier.builder() // - .node(Nodes.class) // + private static final InstanceIdentifier NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) // .child(Node.class, NODE_KEY).toInstance(); private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = // @@ -99,9 +88,8 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest { .nodeWithKey(Flow.QNAME, FLOW_KEY_BI) // .toInstance(); private static final InstanceIdentifier FLOW_INSTANCE_ID_BA = // - InstanceIdentifier.builder() // - .node(Flows.class) // - .node(Flow.class, FLOW_KEY) // + InstanceIdentifier.builder(Flows.class) // + .child(Flow.class, FLOW_KEY) // .toInstance(); @@ -142,6 +130,7 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest { ListenableFuture task3Future = listenablePool.submit(task3); + @SuppressWarnings("unchecked") ListenableFuture> compositeFuture = Futures.allAsList(task1Future,task2Future,task3Future); Thread.sleep(500); @@ -161,7 +150,7 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest { assertEquals(TransactionStatus.COMMITED, ret2.getResult()); // Data are not in the store. - assertNull(baDataService.readOperationalData(FLOW_INSTANCE_ID_BA)); + assertNull(baDataService.readConfigurationData(FLOW_INSTANCE_ID_BA)); } @@ -180,17 +169,18 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest { flow.setKey(FLOW_KEY); flow.setMatch(match.build()); flow.setNode(NODE_REF); - - InstructionsBuilder instructions = new InstructionsBuilder(); InstructionBuilder instruction = new InstructionBuilder(); + + instruction.setOrder(10); ApplyActionsBuilder applyActions = new ApplyActionsBuilder(); List actionList = new ArrayList<>(); PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder(); popMplsAction.setEthernetType(34); - actionList.add(new ActionBuilder().setAction(popMplsAction.build()).build()); + actionList.add(new ActionBuilder().setAction(popMplsAction.build()).setOrder(10).build()); applyActions.setAction(actionList ); + instruction.setInstruction(applyActions.build()); @@ -205,13 +195,29 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest { assertNotNull(ret); assertEquals(TransactionStatus.COMMITED, ret.getResult()); } + + private void createFlow2() throws Exception { + DataModificationTransaction modification = baDataService.beginTransaction(); + long id = 123; + FlowKey key = new FlowKey(id, new NodeRef(NODE_INSTANCE_ID_BA)); + InstanceIdentifier path1; + FlowBuilder flow = new FlowBuilder(); + flow.setKey(key); + MatchBuilder match = new MatchBuilder(); + match.setLayer4Match(new TcpMatchBuilder().build()); + flow.setMatch(match.build()); + + System.out.println("Putting the configuration Data................"); + path1 = InstanceIdentifier.builder(Flows.class).child(Flow.class, key).toInstance(); + // DataObject cls = (DataObject) modification.readConfigurationData(path1); + modification.putConfigurationData(path1, flow.build()); + modification.commit(); - private class CreateFlowTask implements Callable { + } - final Object startSyncObject; + private class CreateFlowTask implements Callable { public CreateFlowTask(Object startSync) { - startSyncObject = startSync; } @Override @@ -220,6 +226,7 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest { //startSyncObject.wait(); //Thread.sleep(500); createFlow(); + createFlow2(); } catch (Exception e) { throw new RuntimeException(e); } @@ -228,10 +235,10 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest { } private void verifyDataAreStoredProperly() { - CompositeNode biFlow = biDataService.readConfigurationData(FLOW_INSTANCE_ID_BI); + CompositeNode biFlows = biDataService.readConfigurationData(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.of(Flows.QNAME)); + assertNotNull(biFlows); + CompositeNode biFlow = biFlows.getFirstCompositeByName(Flow.QNAME); assertNotNull(biFlow); - CompositeNode biMatch = biFlow.getFirstCompositeByName(QName.create(Flow.QNAME, Match.QNAME.getLocalName())); - assertNotNull(biMatch); }