Merge "increased test coverage of config-persister"
authorEd Warnicke <eaw@cisco.com>
Mon, 13 Jan 2014 13:47:55 +0000 (13:47 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 13 Jan 2014 13:47:55 +0000 (13:47 +0000)
16 files changed:
opendaylight/commons/opendaylight/pom.xml
opendaylight/distribution/opendaylight/pom.xml
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/flow/FlowTransaction.xtend
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/group/GroupTransaction.xtend
opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/frm/meter/MeterTransaction.xtend
opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-action-types.yang
opendaylight/md-sal/model/model-flow-service/src/main/yang/packet-processing.yang
opendaylight/md-sal/model/model-topology/pom.xml
opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology-inventory.yang
opendaylight/md-sal/model/model-topology/src/main/yang/opendaylight-topology.yang
opendaylight/md-sal/model/model-topology/src/main/yang/topology-view.yang
opendaylight/md-sal/sal-dom-broker/pom.xml
opendaylight/md-sal/sal-netconf-connector/pom.xml
opendaylight/md-sal/sal-remoterpc-connector/implementation/pom.xml
opendaylight/md-sal/sal-rest-connector/pom.xml
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DeleteRestCallTest.java [new file with mode: 0644]

index 8933b14..24b1ed9 100644 (file)
@@ -61,6 +61,7 @@
     <osgi.core.version>5.0.0</osgi.core.version>
     <ietf-inet-types.version>2010.09.24.2-SNAPSHOT</ietf-inet-types.version>
     <ietf-yang-types.version>2010.09.24.2-SNAPSHOT</ietf-yang-types.version>
+    <ietf-topology.version>2013.10.21.0-SNAPSHOT</ietf-topology.version>
     <opendaylight-l2-types.version>2013.08.27.1</opendaylight-l2-types.version>
     <yang-ext.version>2013.09.07.1</yang-ext.version>
     <javassist.version>3.17.1-GA</javassist.version>
        <artifactId>ietf-yang-types</artifactId>
        <version>${ietf-yang-types.version}</version>
       </dependency>
+      <dependency>
+       <groupId>org.opendaylight.yangtools.model</groupId>
+       <artifactId>ietf-topology</artifactId>
+       <version>${ietf-topology.version}</version>
+      </dependency>
       <dependency>
        <groupId>org.opendaylight.yangtools.model</groupId>
        <artifactId>opendaylight-l2-types</artifactId>
index 6fca9db..f1eca41 100644 (file)
         <dependency>
          <groupId>org.opendaylight.yangtools.model</groupId>
          <artifactId>ietf-topology</artifactId>
-         <version>2013.07.12.2-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
index 6fcadea..dc2a7ee 100644 (file)
@@ -16,14 +16,16 @@ import org.opendaylight.yangtools.yang.binding.DataObject
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
 
 class FlowTransaction extends AbstractTransaction {
     
     @Property
-    val SalFlowService salFlowService;
+    val SalFlowService salFlowService;   
+    
     
     new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,SalFlowService salFlowService) {
-        super(modification)
+        super(modification)        
         _salFlowService = salFlowService;
     }
     
@@ -33,9 +35,10 @@ class FlowTransaction extends AbstractTransaction {
             val tableInstanceId = instanceId.firstIdentifierOf(Table);
             val nodeInstanceId = instanceId.firstIdentifierOf(Node);
             val builder = new RemoveFlowInputBuilder(flow);
-            builder.setFlowRef(new FlowRef(instanceId));
+            builder.setFlowRef(new FlowRef(instanceId));            
             builder.setNode(new NodeRef(nodeInstanceId));
             builder.setFlowTable(new FlowTableRef(tableInstanceId));
+            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
             _salFlowService.removeFlow(builder.build());            
         }
     }
@@ -50,6 +53,7 @@ class FlowTransaction extends AbstractTransaction {
             builder.setFlowRef(new FlowRef(instanceId));
             val ufb = new UpdatedFlowBuilder(updatedFlow);
             builder.setUpdatedFlow((ufb.build()));
+            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
             val ofb = new OriginalFlowBuilder(originalFlow);
             builder.setOriginalFlow(ofb.build());      
             _salFlowService.updateFlow(builder.build());
@@ -64,6 +68,7 @@ class FlowTransaction extends AbstractTransaction {
             val nodeInstanceId = instanceId.firstIdentifierOf(Node);
             val builder = new AddFlowInputBuilder(flow);
             builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
             builder.setFlowRef(new FlowRef(instanceId));
             builder.setFlowTable(new FlowTableRef(tableInstanceId));
             _salFlowService.addFlow(builder.build());            
index d68ffa0..f79c9b6 100644 (file)
@@ -14,14 +14,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
 import org.opendaylight.yangtools.yang.binding.DataObject
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
 
 class GroupTransaction extends AbstractTransaction {
     
     @Property
     val SalGroupService groupService;
-    
+        
     new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,SalGroupService groupService) {
-        super(modification)
+        super(modification)        
         _groupService = groupService;
     }
     
@@ -31,6 +32,7 @@ class GroupTransaction extends AbstractTransaction {
             val nodeInstanceId = instanceId.firstIdentifierOf(Node);
             val builder = new RemoveGroupInputBuilder(group);
             builder.setNode(new NodeRef(nodeInstanceId));
+            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
             builder.setGroupRef(new GroupRef(instanceId));
             _groupService.removeGroup(builder.build());            
         }
@@ -46,6 +48,7 @@ class GroupTransaction extends AbstractTransaction {
             builder.setGroupRef(new GroupRef(instanceId));
             val ufb = new UpdatedGroupBuilder(updatedGroup);
             builder.setUpdatedGroup((ufb.build()));
+            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
             val ofb = new OriginalGroupBuilder(originalGroup);
             builder.setOriginalGroup(ofb.build());      
             _groupService.updateGroup(builder.build());
@@ -60,6 +63,7 @@ class GroupTransaction extends AbstractTransaction {
             val builder = new AddGroupInputBuilder(group);
             builder.setNode(new NodeRef(nodeInstanceId));
             builder.setGroupRef(new GroupRef(instanceId));
+            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
             _groupService.addGroup(builder.build());            
         }
     }
index d64f251..594a16c 100644 (file)
@@ -14,14 +14,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter
 import org.opendaylight.yangtools.yang.binding.DataObject
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterRef
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
 
 class MeterTransaction extends AbstractTransaction {
     
     @Property
     val SalMeterService salMeterService;
-    
+        
     new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,SalMeterService salMeterService) {
-        super(modification)
+        super(modification)    
         _salMeterService = salMeterService;
     }
     
@@ -32,6 +33,7 @@ class MeterTransaction extends AbstractTransaction {
             val builder = new RemoveMeterInputBuilder(meter);
             builder.setNode(new NodeRef(nodeInstanceId));
             builder.setMeterRef(new MeterRef(instanceId));
+            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
             _salMeterService.removeMeter(builder.build());            
         }
     }
@@ -46,6 +48,7 @@ class MeterTransaction extends AbstractTransaction {
             builder.setMeterRef(new MeterRef(instanceId));
             val ufb = new UpdatedMeterBuilder(updatedMeter);
             builder.setUpdatedMeter((ufb.build()));
+            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
             val ofb = new OriginalMeterBuilder(originalMeter);
             builder.setOriginalMeter(ofb.build());      
             _salMeterService.updateMeter(builder.build());
@@ -60,6 +63,7 @@ class MeterTransaction extends AbstractTransaction {
             val builder = new AddMeterInputBuilder(meter);
             builder.setNode(new NodeRef(nodeInstanceId));
             builder.setMeterRef(new MeterRef(instanceId));
+            builder.setTransactionUri(new Uri(modification.getIdentifier() as String));
             _salMeterService.addMeter(builder.build());            
         }
     }
index 43754a1..3cc490f 100644 (file)
@@ -49,9 +49,7 @@ module opendaylight-action-types {
                     }
                     
                     leaf max-length {
-                        type uint16 {
-                            range "0..65294";
-                        }
+                        type uint16;
                     }
                 }
             }
@@ -59,9 +57,7 @@ module opendaylight-action-types {
             case controller-action-case {
                 container controller-action {
                  leaf max-length {
-                     type uint16 {
-                         range "0..65294";
-                     }
+                     type uint16;
                  }
              }
             }
index bfdf504..00ecdba 100644 (file)
@@ -6,6 +6,8 @@ module packet-processing {
     import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
     import ietf-yang-types {prefix yang;revision-date "2010-09-24";} 
     import opendaylight-l2-types {prefix types;revision-date "2013-08-27";}
+    import opendaylight-match-types {prefix match-type;revision-date "2013-10-26";}
+    import opendaylight-table-types {prefix table-type;revision-date "2013-10-26";}
     
     revision "2013-07-09" {
         description "";
@@ -34,11 +36,44 @@ module packet-processing {
        }
     }
 
+    identity packet-in-reason {
+       description "Base identity for all the available packet in reason"; 
+    }
+    
+    identity no-match {
+       base packet-in-reason;
+       description "No matching flow in the classifier";
+    }
+    
+    identity send-to-controller {
+       base packet-in-reason;
+       description "Explicit instruction to send packet to controller";
+    }
+    
+    identity invalid-ttl {
+       base packet-in-reason;
+       description "Packet with invalid TTL";
+    }
 
     notification packet-received {
        leaf cookie {
                 type cookie;
         }
+        
+        leaf table-id {
+               type table-type:table-id;
+        }
+        
+        leaf packet-in-reason {
+               type identityref {
+                       base packet-in-reason;
+               }
+               }
+        
+        container match {
+                       uses match-type:match;
+        }
+        
         uses raw-packet;
     }
 
@@ -56,4 +91,4 @@ module packet-processing {
                uses raw-packet;
        }
     }
-}
\ No newline at end of file
+}
index c91b9dd..e2ce7a9 100644 (file)
     <packaging>bundle</packaging>
     
     <dependencies>
-    <dependency>
-        <groupId>org.opendaylight.controller.model</groupId>
-        <artifactId>model-inventory</artifactId>
-        <version>1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-        <groupId>org.opendaylight.yangtools.model</groupId>
-        <artifactId>ietf-topology</artifactId>
-        <version>2013.07.12.2-SNAPSHOT</version>
-    </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-inventory</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.model</groupId>
+            <artifactId>ietf-topology</artifactId>
+            <version>2013.10.21.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 </project>
index ceeef45..87de0f5 100644 (file)
@@ -8,7 +8,7 @@ module opendaylight-topology-inventory {
     import ietf-inet-types { prefix "inet"; }
     import opendaylight-inventory {prefix "inv";}
     import opendaylight-topology {prefix "odt";}
-    import network-topology {prefix "topo";}
+    import network-topology {prefix "topo"; revision-date "2013-07-12"; }
 
     organization "TBD";
 
@@ -33,4 +33,4 @@ module opendaylight-topology-inventory {
             type inv:node-connector-ref;
         }
     }
-}
\ No newline at end of file
+}
index 038a1b7..6bbfd4b 100644 (file)
@@ -7,7 +7,7 @@ module opendaylight-topology {
     import yang-ext { prefix "ext"; }
     import ietf-inet-types { prefix "inet"; }
     import opendaylight-inventory {prefix "inv";}
-    import network-topology {prefix "topo";}
+    import network-topology {prefix "topo"; revision-date "2013-07-12"; }
 
     organization "TBD";
 
index 2fecb32..1a10bf6 100644 (file)
@@ -6,7 +6,7 @@ module opendaylight-topology-view  {
 
     import yang-ext { prefix "ext"; }
     import ietf-inet-types { prefix "inet"; }
-    import network-topology {prefix "topo";}
+    import network-topology {prefix "topo"; revision-date "2013-07-12"; }
     import opendaylight-topology {prefix "odl";}
 
     organization "TBD";
@@ -45,4 +45,4 @@ module opendaylight-topology-view  {
         ext:augment-identifier "aggregated-node";
         uses aggregate-node;
     }
-}
\ No newline at end of file
+}
index 4740b0d..10e7946 100644 (file)
             <artifactId>sal-common-impl</artifactId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>sal-common-impl</artifactId>
-            <version>1.0-SNAPSHOT</version>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal-core-spi</artifactId>
index 2323b09..67e2934 100644 (file)
             <scope>test</scope>
             <version>${netconf.version}</version>
         </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>yang-test</artifactId>
-            <scope>test</scope>
-            <version>${netconf.version}</version>
-        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>config-manager</artifactId>
index 6c72a61..d5648a0 100644 (file)
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-data-impl</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-common</artifactId>
-    </dependency>
 
     <!-- Third Party -->
     <dependency>
index 5e798b6..0bd86a3 100644 (file)
@@ -42,7 +42,7 @@
       <artifactId>yang-data-impl</artifactId>
       <version>${yang.version}</version>
     </dependency>
-        <dependency>
+    <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-model-util</artifactId>
       <version>${yang.version}</version>
       <version>2.4</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-       <groupId>org.opendaylight.yangtools</groupId>
-       <artifactId>yang-model-util</artifactId>
-       <version>0.5.9-SNAPSHOT</version>
-    </dependency>
   </dependencies>
 
   <build>
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DeleteRestCallTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DeleteRestCallTest.java
new file mode 100644 (file)
index 0000000..7b164d4
--- /dev/null
@@ -0,0 +1,101 @@
+package org.opendaylight.controller.sal.restconf.impl.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.util.Set;
+import java.util.concurrent.Future;
+import java.util.logging.Level;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.TestProperties;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
+import org.opendaylight.controller.sal.rest.impl.XmlMapper;
+import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
+import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
+import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
+import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+import com.google.common.base.Charsets;
+
+public class DeleteRestCallTest extends JerseyTest {
+
+    private static ControllerContext controllerContext;
+    private static BrokerFacade brokerFacade;
+    private static RestconfImpl restconfImpl;
+    private static final MediaType MEDIA_TYPE_DRAFT02 = new MediaType("application", "yang.data+xml");
+
+    @BeforeClass
+    public static void init() throws FileNotFoundException {
+        Set<Module> allModules = TestUtils.loadModulesFrom("/test-config-data/yang1");
+        assertNotNull(allModules);
+        SchemaContext schemaContext = TestUtils.loadSchemaContext(allModules);
+        controllerContext = ControllerContext.getInstance();
+        controllerContext.setSchemas(schemaContext);
+        brokerFacade = mock(BrokerFacade.class);
+        restconfImpl = RestconfImpl.getInstance();
+        restconfImpl.setBroker(brokerFacade);
+        restconfImpl.setControllerContext(controllerContext);
+    }
+
+    @Test
+    public void testDeleteConfigurationData() throws UnsupportedEncodingException, FileNotFoundException {
+        String uri2 = createUri("/config/", "test-interface:interfaces");
+
+        RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
+                TransactionStatus.COMMITED).build();
+        Future<RpcResult<TransactionStatus>> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+        when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture);
+
+        Response response = target(uri2).request(MEDIA_TYPE_DRAFT02).delete();
+        assertEquals(200, response.getStatus());
+
+        rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(TransactionStatus.FAILED).build();
+        dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build();
+
+        when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture);
+
+        response = target(uri2).request(MEDIA_TYPE_DRAFT02).delete();
+        assertEquals(500, response.getStatus());
+    }
+
+    private String createUri(String prefix, String encodedPart) throws UnsupportedEncodingException {
+        return URI.create(prefix + URLEncoder.encode(encodedPart, Charsets.US_ASCII.name()).toString()).toASCIIString();
+    }
+
+    @Override
+    protected Application configure() {
+        enable(TestProperties.LOG_TRAFFIC);
+        enable(TestProperties.DUMP_ENTITY);
+        enable(TestProperties.RECORD_LOG_LEVEL);
+        set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
+
+        ResourceConfig resourceConfig = new ResourceConfig();
+        resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE,
+                XmlToCompositeNodeProvider.INSTANCE);
+        return resourceConfig;
+    }
+}