Merge "bug1273 - POM restructuring changes for weekly automated releases - introduced...
authorRobert Varga <rovarga@cisco.com>
Thu, 3 Jul 2014 14:00:55 +0000 (14:00 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 3 Jul 2014 14:00:55 +0000 (14:00 +0000)
commons/parent/pom.xml
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPMessageHeaderDecoder.java
pcep/topology-provider-config/pom.xml
pcep/topology-provider-config/src/main/java/org/opendaylight/controller/config/yang/pcep/topology/provider/PCEPTopologyProviderModule.java
pcep/topology-provider-config/src/test/java/org/opendaylight/controller/config/yang/pcep/topology/provider/PCEPTopologyProviderModuleTest.java
tcp-md5/jni/pom.xml
tcp-md5/jni/src/test/java/org/opendaylight/bgpcep/tcpmd5/jni/NativeTestSupport.java [new file with mode: 0644]

index e28e76c1a9731558f7bd936e1eef4a4c9fee1c18..b9940f5b1dd56e75cb7e4963111f087ad8eb7207 100644 (file)
                 <scope>test</scope>
                 <type>test-jar</type>
            </dependency>
-
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>tcpmd5-jni-cfg</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>tcpmd5-jni</artifactId>
+                <type>test-jar</type>
+                <scope>test</scope>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>ch.qos.logback</groupId>
                 <artifactId>logback-classic</artifactId>
index a540cfb5e8701add4eaf06a6fcccce0eec034380..13b3ec154830d705a203e9ed579c44c7f4fd8347 100644 (file)
@@ -14,8 +14,8 @@ import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
  */
 public class PCEPMessageHeaderDecoder extends LengthFieldBasedFrameDecoder {
 
-    // min 4, max 4096
-    private static final int MAX_FRAME_SIZE = 65528;
+    // min 4, max 65535
+    private static final int MAX_FRAME_SIZE = 65535;
 
     private static final int VERSION_FLAGS_SIZE = 1;
 
index db5f11249136ee4edfd28766f7d4cd903e88eb93..e134a0cb8120dd160e635e0d43fff81cfa49ccaa 100644 (file)
@@ -8,7 +8,8 @@
  and is available at http://www.eclipse.org/legal/epl-v10.html
 -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
     <scm>
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>ietf-inet-types</artifactId>
         </dependency>
-
         <!--test dependencies -->
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>config-manager</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>config-util</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>mockito-configuration</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>netty-timer-config</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>pcep-impl-config</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>netty-threadgroup-config</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <groupId>${project.groupId}</groupId>
             <artifactId>pcep-ietf-stateful02</artifactId>
             <type>test-jar</type>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>programming-impl-config</artifactId>
             <type>test-jar</type>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>pcep-impl-config</artifactId>
             <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>tcpmd5-jni-cfg</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>tcpmd5-jni</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 
index c31f49f37c83a920b0e10b87ead5cd10b9a66b31..1a3aa5fa6aecf10fb7cf965f216bc0bd21e4c870 100644 (file)
@@ -18,22 +18,13 @@ package org.opendaylight.controller.config.yang.pcep.topology.provider;
 
 import com.google.common.base.Charsets;
 import com.google.common.net.InetAddresses;
-
-import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.concurrent.ExecutionException;
-
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
 import org.opendaylight.bgpcep.pcep.topology.provider.PCEPTopologyProvider;
 import org.opendaylight.bgpcep.tcpmd5.KeyMapping;
 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleMXBean;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
@@ -77,6 +68,7 @@ public final class PCEPTopologyProviderModule extends
         return ret;
     }
 
+
     private String getAddressString(final IpAddress address) {
         if (address.getIpv4Address() != null) {
             return address.getIpv4Address().getValue();
@@ -88,6 +80,7 @@ public final class PCEPTopologyProviderModule extends
         throw new IllegalArgumentException(String.format("Address %s is invalid", address));
     }
 
+
     @Override
     public void customValidation() {
         JmxAttributeValidationException.checkNotNull(getTopologyId(), "is not set.", topologyIdJmxAttribute);
@@ -105,18 +98,13 @@ public final class PCEPTopologyProviderModule extends
              *  FIXME: this is a use case for Module interfaces, e.g. PCEPDispatcherImplModule
              *         should something like isMd5ServerSupported()
              */
-            final MBeanServer srv = ManagementFactory.getPlatformMBeanServer();
-            Object scf;
-            try {
-                final ObjectName ci = (ObjectName) srv.getAttribute(getDispatcher(), "CurrentImplementation");
-
-                // FIXME: AbstractPCEPDispatcherImplModule.md5ServerChannelFactoryJmxAttribute.getAttributeName()
-                scf = srv.getAttribute(ci, "Md5ServerChannelFactory");
-                JmxAttributeValidationException.checkCondition(scf != null, "password is not compatible with selected dispatcher",
-                        clientJmxAttribute);
-            } catch (AttributeNotFoundException | InstanceNotFoundException | MBeanException | ReflectionException e) {
-                JmxAttributeValidationException.wrap(e, "password support could not be validated", clientJmxAttribute);
-            }
+
+            PCEPDispatcherImplModuleMXBean dispatcherProxy = dependencyResolver.newMXBeanProxy(getDispatcher(),
+                    PCEPDispatcherImplModuleMXBean.class);
+            boolean md5ServerSupported = dispatcherProxy.getMd5ServerChannelFactory() != null;
+            JmxAttributeValidationException.checkCondition(md5ServerSupported,
+                    "password is not compatible with selected dispatcher", clientJmxAttribute);
+
         }
     }
 
index 752274fec2f8d0adb8ebccf2ff7894ea62eb9f80..93923d0801fb2a03b02ecf2a49324b0da2c7ef6e 100644 (file)
@@ -11,24 +11,30 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleTest.createDispatcherInstance;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.Random;
-
+import javax.management.InstanceAlreadyExistsException;
 import javax.management.ObjectName;
-
 import org.junit.Test;
+import org.opendaylight.bgpcep.tcpmd5.jni.NativeTestSupport;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleFactory;
+import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleMXBean;
 import org.opendaylight.controller.config.yang.pcep.impl.PCEPSessionProposalFactoryImplModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.stateful02.cfg.Stateful02PCEPSessionProposalFactoryModuleFactory;
 import org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerTest;
+import org.opendaylight.controller.config.yang.tcpmd5.jni.cfg.NativeKeyAccessFactoryModuleFactory;
+import org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.MD5ServerChannelFactoryModuleFactory;
+import org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.MD5ServerChannelFactoryModuleMXBean;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.tcpmd5.cfg.rev140427.Rfc2385Key;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 
 public class PCEPTopologyProviderModuleTest extends AbstractInstructionSchedulerTest {
@@ -44,7 +50,7 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
     @Test
     public void testValidationExceptionListenAddressNotSet() throws Exception {
         try {
-            createInstance(null, LISTEN_PORT, TOPOLOGY_ID);
+            createInstance(null, LISTEN_PORT, TOPOLOGY_ID, false);
             fail();
         } catch (ValidationException e) {
             assertTrue(e.getMessage().contains("ListenAddress is not set"));
@@ -54,7 +60,7 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
     @Test
     public void testValidationExceptionListenPortNotSet() throws Exception {
         try {
-            createInstance(LISTEN_ADDRESS, null, TOPOLOGY_ID);
+            createInstance(LISTEN_ADDRESS, null, TOPOLOGY_ID, false);
             fail();
         } catch (ValidationException e) {
             assertTrue(e.getMessage().contains("ListenPort is not set"));
@@ -64,7 +70,7 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
     @Test
     public void testValidationExceptionTopologyIdNotSet() throws Exception {
         try {
-            createInstance(LISTEN_ADDRESS, LISTEN_PORT, null);
+            createInstance(LISTEN_ADDRESS, LISTEN_PORT, null, false);
             fail();
         } catch (ValidationException e) {
             assertTrue(e.getMessage().contains("TopologyId is not set"));
@@ -73,14 +79,14 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
 
     @Test
     public void testCreateBean() throws Exception {
-        CommitStatus status = createInstance();
+        CommitStatus status = createInstance(false);
         assertBeanCount(1, FACTORY_NAME);
         assertStatus(status, 16, 0, 0);
     }
 
     @Test
     public void testReusingOldInstance() throws Exception {
-        createInstance();
+        createInstance(false);
         ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
         assertBeanCount(1, FACTORY_NAME);
         CommitStatus status = transaction.commit();
@@ -90,7 +96,7 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
 
     @Test
     public void testReconfigure() throws Exception {
-        createInstance();
+        createInstance(false);
         final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
         assertBeanCount(1, FACTORY_NAME);
         final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(
@@ -101,15 +107,44 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
         assertStatus(status, 0, 1, 15);
     }
 
-    private CommitStatus createInstance(final String listenAddress, final PortNumber listenPort, final TopologyId topologyId)
+    @Test
+    public void testCreateBeanWithMD5() throws Exception {
+        NativeTestSupport.assumeSupportedPlatform();
+        CommitStatus status = createInstance(true);
+        assertBeanCount(1, FACTORY_NAME);
+        assertStatus(status, 18, 0, 0);
+    }
+
+    @Test
+    public void testMD5ValidationFailure() throws Exception {
+        NativeTestSupport.assumeSupportedPlatform();
+        createInstance(true);
+        // remove dispatcher's Md5ServerChannelFactory
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        assertBeanCount(1, FACTORY_NAME);
+        final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(
+                transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), PCEPTopologyProviderModuleMXBean.class);
+        ObjectName dispatcherON = mxBean.getDispatcher();
+        PCEPDispatcherImplModuleMXBean dispatcher = transaction.newMXBeanProxy(dispatcherON, PCEPDispatcherImplModuleMXBean.class);
+        dispatcher.setMd5ServerChannelFactory(null);
+        try {
+            transaction.validateConfig();
+            fail();
+        }catch(ValidationException e){
+            assertTrue(e.getMessage(), e.getMessage().contains("Client password is not compatible with selected dispatcher"));
+        }
+    }
+
+    private CommitStatus createInstance(final String listenAddress, final PortNumber listenPort,
+                                        final TopologyId topologyId, boolean addMD5)
             throws Exception {
         ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        createPCEPTopologyProviderModuleInstance(transaction, listenAddress, listenPort, topologyId);
+        createPCEPTopologyProviderModuleInstance(transaction, listenAddress, listenPort, topologyId, addMD5);
         return transaction.commit();
     }
 
-    private CommitStatus createInstance() throws Exception {
-        return createInstance(LISTEN_ADDRESS, getRandomPortNumber(), TOPOLOGY_ID);
+    private CommitStatus createInstance(boolean addMD5) throws Exception {
+        return createInstance(LISTEN_ADDRESS, getRandomPortNumber(), TOPOLOGY_ID, addMD5);
     }
 
     public static ObjectName createPCEPTopologyProviderModuleInstance(final ConfigTransactionJMXClient transaction,
@@ -118,6 +153,7 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
         final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(objectName, PCEPTopologyProviderModuleMXBean.class);
         mxBean.setDataProvider(dataBrokerON);
         mxBean.setDispatcher(createDispatcherInstance(transaction, 5));
+
         mxBean.setListenAddress(new IpAddress(LISTEN_ADDRESS.toCharArray()));
         mxBean.setListenPort(getRandomPortNumber());
         mxBean.setRpcRegistry(bindingBrokerON);
@@ -128,8 +164,20 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
         return objectName;
     }
 
+    private static void addMd5(ConfigTransactionJMXClient transaction, PCEPTopologyProviderModuleMXBean mxBean) throws InstanceAlreadyExistsException {
+        ObjectName jniON = transaction.createModule(NativeKeyAccessFactoryModuleFactory.NAME, NativeKeyAccessFactoryModuleFactory.NAME);
+        ObjectName md5ServerChannelFactoryON = transaction.createModule(MD5ServerChannelFactoryModuleFactory.NAME, MD5ServerChannelFactoryModuleFactory.NAME);
+        MD5ServerChannelFactoryModuleMXBean md5Factory = transaction.newMXBeanProxy(md5ServerChannelFactoryON, MD5ServerChannelFactoryModuleMXBean.class);
+        md5Factory.setServerKeyAccessFactory(jniON);
+
+
+        ObjectName dispatcherON = mxBean.getDispatcher();
+        PCEPDispatcherImplModuleMXBean dispatcher = transaction.newMXBeanProxy(dispatcherON, PCEPDispatcherImplModuleMXBean.class);
+        dispatcher.setMd5ServerChannelFactory(md5ServerChannelFactoryON);
+    }
+
     private ObjectName createPCEPTopologyProviderModuleInstance(final ConfigTransactionJMXClient transaction, final String listenAddress,
-            final PortNumber listenPort, final TopologyId topologyId) throws Exception {
+                                                                final PortNumber listenPort, final TopologyId topologyId, boolean addMD5) throws Exception {
         final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
         final ObjectName dataBrokerON = createDataBrokerInstance(transaction);
         final ObjectName notificationBrokerON = createNotificationBrokerInstance(transaction);
@@ -138,6 +186,16 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
         final PCEPTopologyProviderModuleMXBean mxBean = transaction.newMXBeanProxy(objectName, PCEPTopologyProviderModuleMXBean.class);
         mxBean.setDataProvider(dataBrokerON);
         mxBean.setDispatcher(createDispatcherInstance(transaction, 5));
+
+        if (addMD5) {
+            addMd5(transaction, mxBean);
+            // create 1 client
+            Client client = new Client();
+            client.setPassword(Rfc2385Key.getDefaultInstance("foo"));
+            client.setAddress(new IpAddress("127.0.0.1".toCharArray()));
+            mxBean.setClient(Arrays.asList(client));
+        }
+
         mxBean.setListenAddress(listenAddress == null ? null : new IpAddress(listenAddress.toCharArray()));
         mxBean.setListenPort(listenPort);
         mxBean.setRpcRegistry(bindingBrokerON);
@@ -158,6 +216,8 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
         moduleFactories.add(new SimplePCEPExtensionProviderContextModuleFactory());
         moduleFactories.add(new Stateful02TopologySessionListenerModuleFactory());
         moduleFactories.add(new Stateful02PCEPSessionProposalFactoryModuleFactory());
+        moduleFactories.add(new NativeKeyAccessFactoryModuleFactory());
+        moduleFactories.add(new MD5ServerChannelFactoryModuleFactory());
         return moduleFactories;
     }
 
index 696110e5756ceaf2768022fee53e75be93efcc1c..f3ac292a08edd7783d903503bc2dbff643a79067 100644 (file)
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
 
         <pluginManagement>
diff --git a/tcp-md5/jni/src/test/java/org/opendaylight/bgpcep/tcpmd5/jni/NativeTestSupport.java b/tcp-md5/jni/src/test/java/org/opendaylight/bgpcep/tcpmd5/jni/NativeTestSupport.java
new file mode 100644 (file)
index 0000000..c4c3d8e
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.bgpcep.tcpmd5.jni;
+
+import org.junit.Assume;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NativeTestSupport {
+    private static final Logger LOG = LoggerFactory.getLogger(NativeTestSupport.class);
+
+    public static void assumeSupportedPlatform() {
+        try {
+            NativeKeyAccessFactory.getInstance();
+        }catch (NativeSupportUnavailableException e) {
+            LOG.info("Skipping test, this platform is not supported");
+            Assume.assumeNoException(e);
+        }
+    }
+}