Fix unit tests and code to support schema-enforcement by yangtools. 14/13214/3
authorThomas Bachman <tbachman@yahoo.com>
Fri, 28 Nov 2014 21:23:38 +0000 (16:23 -0500)
committerThomas Bachman <tbachman@yahoo.com>
Sat, 29 Nov 2014 03:30:00 +0000 (22:30 -0500)
A recent change in yangtools requires fixing tests and code
that did not honor the schema required by the yang data type.
This patch fixes those errors.  This also addresses an incomplete
UUID that was added in a previous patch to the use-cases.

Change-Id: I783f597de12fe1810e6e67d6345e4467fe7db065
Signed-off-by: Thomas Bachman <tbachman@yahoo.com>
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/DestinationMapper.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/PortSecurity.java
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/flow/PortSecurityTest.java
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/IdentityTest.java
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/L2EprContextTest.java
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/renderer/opflex/MessageUtilsTest.java
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/PolicyResolverTest.java
util/use-cases/2-client-1-provider/policy_config.py

index e1e527276479abf76266debfcd226ddb33279cae..1d8c9bf93fd239f4986ccfc5164e1caf18d30165 100644 (file)
@@ -208,7 +208,7 @@ public class DestinationMapper extends FlowTable {
                         .setEthernetMatch(ethernetMatch(null, null, ARP))
                         .setLayer3Match(new ArpMatchBuilder()
                             .setArpOp(Integer.valueOf(1))
-                            .setArpTargetTransportAddress(new Ipv4Prefix(ikey))
+                            .setArpTargetTransportAddress(new Ipv4Prefix(ikey+"/32"))
                             .build());
                     addNxRegMatch(mb, RegMatch.of(NxmNxReg6.class,
                                                   Long.valueOf(l3Id)));
@@ -411,13 +411,13 @@ public class DestinationMapper extends FlowTable {
             Long etherType = null;
             String ikey = null;
             if (l3a.getIpAddress().getIpv4Address() != null) {
-                ikey = l3a.getIpAddress().getIpv4Address().getValue();
+                ikey = l3a.getIpAddress().getIpv4Address().getValue() + "/32";
                 etherType = IPv4;
                 m = new Ipv4MatchBuilder()
                     .setIpv4Destination(new Ipv4Prefix(ikey))
                     .build();
             } else if (l3a.getIpAddress().getIpv6Address() != null) {
-                ikey = l3a.getIpAddress().getIpv6Address().getValue();
+                ikey = l3a.getIpAddress().getIpv6Address().getValue() + "/128";
                 etherType = IPv6;
                 m = new Ipv6MatchBuilder()
                     .setIpv6Destination(new Ipv6Prefix(ikey))
index b2c37676af91f62c33d30cf25961a3ed96e02ec8..4aa3354020157c4b67f6d4ffee26e746776883c8 100644 (file)
@@ -155,7 +155,7 @@ public class PortSecurity extends FlowTable {
             Long etherType = null;
             String ikey = null;
             if (l3.getIpAddress().getIpv4Address() != null) {
-                ikey = l3.getIpAddress().getIpv4Address().getValue();
+                ikey = l3.getIpAddress().getIpv4Address().getValue()+"/32";
                 if (arp) {
                     m = new ArpMatchBuilder()
                         .setArpSourceTransportAddress(new Ipv4Prefix(ikey))
@@ -169,7 +169,7 @@ public class PortSecurity extends FlowTable {
                 }
             } else if (l3.getIpAddress().getIpv6Address() != null) {
                 if (arp) continue;
-                ikey = l3.getIpAddress().getIpv6Address().getValue();
+                ikey = l3.getIpAddress().getIpv6Address().getValue()+"/128";
                 m = new Ipv6MatchBuilder()
                     .setIpv6Source(new Ipv6Prefix(ikey))
                     .build();
index de066cda3a022704b0abadd4b42536a9f824f367..67c2c598f8e61ff36285a87c40d7a1bcc88ba30e 100644 (file)
@@ -193,15 +193,15 @@ public class PortSecurityTest extends FlowTableTest {
                 ((f.getMatch().getLayer3Match() != null &&
                   f.getMatch().getLayer3Match() instanceof Ipv4Match &&
                   Objects.equals(ep.getL3Address().get(0).getIpAddress().getIpv4Address().getValue(),
-                                 ((Ipv4Match)f.getMatch().getLayer3Match()).getIpv4Source().getValue())) ||
+                                 ((Ipv4Match)f.getMatch().getLayer3Match()).getIpv4Source().getValue().split("/")[0])) ||
                  (f.getMatch().getLayer3Match() != null &&
                   f.getMatch().getLayer3Match() instanceof ArpMatch &&
                   Objects.equals(ep.getL3Address().get(0).getIpAddress().getIpv4Address().getValue(),
-                                 ((ArpMatch)f.getMatch().getLayer3Match()).getArpSourceTransportAddress().getValue())) ||
+                                 ((ArpMatch)f.getMatch().getLayer3Match()).getArpSourceTransportAddress().getValue().split("/")[0])) ||
                  (f.getMatch().getLayer3Match() != null &&
                   f.getMatch().getLayer3Match() instanceof Ipv6Match &&
                   Objects.equals(ep.getL3Address().get(1).getIpAddress().getIpv6Address().getValue(),
-                                 ((Ipv6Match)f.getMatch().getLayer3Match()).getIpv6Source().getValue())))) {
+                                 ((Ipv6Match)f.getMatch().getLayer3Match()).getIpv6Source().getValue().split("/")[0])))) {
                 count += 1;
                 assertEquals(FlowUtils.gotoTableInstructions((short)(table.getTableId()+1)),
                              f.getInstructions());
index ef41a6981a8bd1047a64ba86c635e14b94da6eea..e07f4a94f5bbc529c1ad1aff378b62ed966b5af8 100644 (file)
@@ -45,7 +45,7 @@ public class IdentityTest {
     private static final String TEST_MAC6 = "0xaa-0xBB-0xCC-0xdd-0xEE-0xFF";
     private static final String TEST_MAC7 = "1:22:3:44:5:66";
     private static final String TEST_MAC8 = "1-22-3-44-5-66";
-    private static final String TEST_CONTEXT = "foo";
+    private static final String TEST_CONTEXT = "9AC3DB0E-C47A-4409-B1AD-BDE647A29440";
 
     @Test
     public void testL3Identity() throws Exception {
@@ -65,46 +65,11 @@ public class IdentityTest {
 
     @Test
     public void testL2Identity() throws Exception {
-        id = new Identity(TEST_MAC1);
-        id.setContext(TEST_CONTEXT);
-        assertTrue(id.identityAsString().equals(TEST_MAC1));
-        assertTrue(id.getL2Context().getValue().equals(TEST_CONTEXT));
-        assertTrue(id.getL2Identity().getValue().equals(TEST_MAC1));
-
         id = new Identity(TEST_MAC2);
         id.setContext(TEST_CONTEXT);
         assertTrue(id.identityAsString().equals(TEST_MAC2));
         assertTrue(id.getL2Identity().getValue().equals(TEST_MAC2));
 
-        id = new Identity(TEST_MAC3);
-        id.setContext(TEST_CONTEXT);
-        assertTrue(id.identityAsString().equals(TEST_MAC3));
-        assertTrue(id.getL2Identity().getValue().equals(TEST_MAC3));
-
-        id = new Identity(TEST_MAC4);
-        id.setContext(TEST_CONTEXT);
-        assertTrue(id.identityAsString().equals(TEST_MAC4));
-        assertTrue(id.getL2Identity().getValue().equals(TEST_MAC4));
-
-        id = new Identity(TEST_MAC5);
-        id.setContext(TEST_CONTEXT);
-        assertTrue(id.identityAsString().equals(TEST_MAC5));
-        assertTrue(id.getL2Identity().getValue().equals(TEST_MAC5));
-
-        id = new Identity(TEST_MAC6);
-        id.setContext(TEST_CONTEXT);
-        assertTrue(id.identityAsString().equals(TEST_MAC6));
-        assertTrue(id.getL2Identity().getValue().equals(TEST_MAC6));
-
-        id = new Identity(TEST_MAC7);
-        id.setContext(TEST_CONTEXT);
-        assertTrue(id.identityAsString().equals(TEST_MAC7));
-        assertTrue(id.getL2Identity().getValue().equals(TEST_MAC7));
-
-        id = new Identity(TEST_MAC8);
-        id.setContext(TEST_CONTEXT);
-        assertTrue(id.identityAsString().equals(TEST_MAC8));
-        assertTrue(id.getL2Identity().getValue().equals(TEST_MAC8));
     }
 
 }
index 9be8568d0f9d56f3ae6b71d09580a7903c531f16..3c9d6c883ba97e25ef48a108f80c8a24abc0d1c6 100644 (file)
@@ -91,8 +91,9 @@ public class L2EprContextTest implements EprContext.Callback {
 
 
 
-    private static final String TEST_CONTEXT = "foo";
+    private static final String TEST_CONTEXT = "BD27A352-53D4-4D42-9862-F333D86E922D";
     private static final String TEST_ID = "bar";
+    private static final String TEST_MAC = "00:11:22:33:44:55";
 
     @Before
     public void setUp() throws Exception {
@@ -157,7 +158,7 @@ public class L2EprContextTest implements EprContext.Callback {
         when(mockReqParams.getIdentifier()).thenReturn(mockIdentityList);
         when(mockId.getL2Context()).thenReturn(mockL2Context);
         when(mockId.getL2Identity()).thenReturn(mockMac);
-        when(mockIdentityList.get(0)).thenReturn(TEST_ID);
+        when(mockIdentityList.get(0)).thenReturn(TEST_MAC);
         when(mockProvider.newReadOnlyTransaction()).thenReturn(mockReader);
         when(mockReader.read(eq(LogicalDatastoreType.OPERATIONAL),
                 Matchers.<InstanceIdentifier<Endpoint>>any())).thenReturn(mockFuture);
index 0f36bebbed7fd026e2fbf4611a3bee4d21384e5e..ead3cb6927711ccb3e7b907e6833bf33e1b10229 100644 (file)
@@ -107,6 +107,7 @@ public class MessageUtilsTest {
     public static final String EPG_RN = "endpoint-group";
     public static final String TENANT_UUID = "8ca978fa-05bc-4120-b037-f74802d18396";
     public static final String EPG_UUID = "420c5855-0578-4ca5-b3d2-3057e640e55a";
+    public static final String EPG_NAME = "webFarm1";
 
     public static final String TEST_TARGET_NAME1 = "target1";
     public static final String TEST_TARGET_NAME2 = "target2";
@@ -135,7 +136,7 @@ public class MessageUtilsTest {
     private static final String TEST_CONDITION_NAME1 = "condition1";
     private static final String TEST_CAPABILITY_MATCHER_NAME1 = "capability-matcher-name1";
     private static final String TEST_CAPABILITY_NAME1 = "capabilit-name1";
-    private static final String TEST_NETWORK_DOMAIN_ID = "network-domain-id1";
+    private static final String TEST_NETWORK_DOMAIN_ID = "9AF7B4EF-1C5B-4FA9-A769-F368F781C4E6";
     private static final String TEST_QUALITY_NAME1 = "quality-name1";
     private static final String TEST_QUALITY_MATCHER_NAME1 = "quality-matcher-name1";
     private static final String TEST_INTRAGROUP_POLICY_NAME1 = "intragroup-policy1";
@@ -532,7 +533,7 @@ public class MessageUtilsTest {
 
         epgb.setIntraGroupPolicy(IntraGroupPolicy.Allow);
         epgb.setNetworkDomain(new NetworkDomainId(TEST_NETWORK_DOMAIN_ID));
-        epgb.setName(new Name(EPG_UUID));
+        epgb.setName(new Name(EPG_NAME));
         epgb.setId(new EndpointGroupId(EPG_UUID));
 
         EndpointGroup epg = epgb.build();
index eb9267ea0c802abab0aaa270d6c95247c18f7a25..18385c6c2fcd46ef88710ab8efba6f8e696e89b1 100644 (file)
@@ -156,7 +156,7 @@ public class PolicyResolverTest {
         .setOrder(Integer.valueOf(3))
         .build();
     Subject s3 = new SubjectBuilder()
-        .setName(new SubjectName("3"))
+        .setName(new SubjectName("s3"))
         .setRule(ImmutableList.of(rule3))
         .setOrder(Integer.valueOf(3))
         .build();
index eea021558fc82219e6078c897dc1771acbf573e6..e806363577c6d2c76f45e72bf77c32360af1d850 100644 (file)
@@ -77,7 +77,7 @@ endpointGroups = [
                    {'name':'client2',
                     'providesContracts' : [], #List of contract names provided
                     'consumesContracts' : ['pingall+web'],
-                    'id' : '6c787c-156a-49ed-8546-547bdccf283c',
+                    'id' : '5e6c787c-156a-49ed-8546-547bdccf283c',
                     },
                   {'name':'webserver',
                     'providesContracts' : ['pingall+web'], #List of contract names provided