incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chirad...@apache.org
Subject [13/16] git commit: Network-refactor: fix bugs in components.xml discovered by unit tests Provide injection tests for NetworkManager and FirewallManager
Date Wed, 09 Jan 2013 23:50:00 GMT
Network-refactor: fix bugs in components.xml discovered by unit tests
Provide injection tests for NetworkManager and FirewallManager

Signed-off-by: Chiradeep Vittal <chiradeep@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/728db6c8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/728db6c8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/728db6c8

Branch: refs/heads/network-refactor
Commit: 728db6c8ca4000b74f4d0e945303c2a586a5b061
Parents: 1339650
Author: Chiradeep Vittal <chiradeep@apache.org>
Authored: Wed Jan 9 12:10:51 2013 -0800
Committer: Chiradeep Vittal <chiradeep@apache.org>
Committed: Wed Jan 9 15:49:02 2013 -0800

----------------------------------------------------------------------
 client/tomcatconf/components.xml.in                |   14 +++-
 .../network/element/VpcVirtualRouterElement.java   |    2 +-
 .../test/com/cloud/network/NetworkManagerTest.java |    8 ++
 .../network/firewall/FirewallManagerTest.java      |   67 +++++++++++++++
 server/test/resources/network-mgr-component.xml    |   14 +++-
 5 files changed, 98 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/728db6c8/client/tomcatconf/components.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in
index 48b1e8a..f678f5d 100755
--- a/client/tomcatconf/components.xml.in
+++ b/client/tomcatconf/components.xml.in
@@ -161,47 +161,55 @@ under the License.
         </adapters>
         <adapters key="com.cloud.network.element.FirewallServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.DhcpServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
             <adapter name="ExternalDhcpElement" class="com.cloud.network.element.ExternalDhcpElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
          
         </adapters>
         <adapters key="com.cloud.network.element.UserDataServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.SourceNatServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
             <adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
 
         </adapters>
         <adapters key="com.cloud.network.element.StaticNatServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
             <adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.PortForwardingServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
             <adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.LoadBalancingServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.RemoteAccessVPNServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.Site2SiteVpnServiceProvider">
-            <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"
/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.IpDeployer">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
             <adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.ConnectivityProvider">
             <adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.NetworkACLServiceProvider">
-            <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.VpcProvider">
-            <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
 
         <adapters key="com.cloud.cluster.agentlb.AgentLoadBalancerPlanner">

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/728db6c8/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
index 1bc6b9c..f923ae1 100644
--- a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java
@@ -63,7 +63,7 @@ import com.cloud.vm.VirtualMachineProfile;
 @Local(value = {NetworkElement.class, FirewallServiceProvider.class, 
         DhcpServiceProvider.class, UserDataServiceProvider.class, 
         StaticNatServiceProvider.class, LoadBalancingServiceProvider.class,
-        PortForwardingServiceProvider.class, IpDeployer.class,
+        PortForwardingServiceProvider.class, IpDeployer.class, VpcProvider.class,
         Site2SiteVpnServiceProvider.class, NetworkACLServiceProvider.class})
 public class VpcVirtualRouterElement extends VirtualRouterElement implements VpcProvider,
Site2SiteVpnServiceProvider, NetworkACLServiceProvider{
     private static final Logger s_logger = Logger.getLogger(VpcVirtualRouterElement.class);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/728db6c8/server/test/com/cloud/network/NetworkManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/NetworkManagerTest.java b/server/test/com/cloud/network/NetworkManagerTest.java
index 017adfe..6fdf35f 100644
--- a/server/test/com/cloud/network/NetworkManagerTest.java
+++ b/server/test/com/cloud/network/NetworkManagerTest.java
@@ -20,11 +20,13 @@ package com.cloud.network;
 
 import junit.framework.Assert;
 
+import org.apache.log4j.Logger;
 import org.junit.Test;
 
 import com.cloud.network.element.DhcpServiceProvider;
 import com.cloud.network.element.IpDeployer;
 import com.cloud.network.firewall.FirewallManagerImpl;
+import com.cloud.network.firewall.FirewallManagerTest;
 import com.cloud.network.rules.FirewallManager;
 import com.cloud.utils.component.ComponentLocator;
 import com.cloud.utils.testcase.ComponentSetup;
@@ -32,6 +34,7 @@ import com.cloud.utils.testcase.ComponentTestCase;
 
 @ComponentSetup(managerName="management-server", setupXml="network-mgr-component.xml")
 public class NetworkManagerTest extends ComponentTestCase {
+    private static final Logger s_logger = Logger.getLogger(NetworkManagerTest.class);
 
     @Test
     public void testInjected() {
@@ -42,11 +45,16 @@ public class NetworkManagerTest extends ComponentTestCase {
         Assert.assertNotNull(networkMgr._networkModel);
         
         Assert.assertNotNull(networkMgr._ipDeployers.get("VirtualRouter"));
+        Assert.assertNotNull(networkMgr._ipDeployers.get("VpcVirtualRouter"));
+
         Assert.assertNotNull(networkMgr._dhcpProviders.get("VirtualRouter"));
+        Assert.assertNotNull(networkMgr._dhcpProviders.get("VpcVirtualRouter"));
+
         
         Assert.assertTrue(networkMgr._ipDeployers.get("VirtualRouter") instanceof IpDeployer);
         Assert.assertTrue(networkMgr._dhcpProviders.get("VirtualRouter") instanceof DhcpServiceProvider);
        
+        s_logger.info("Done testing injection of network manager's network elements");
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/728db6c8/server/test/com/cloud/network/firewall/FirewallManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/firewall/FirewallManagerTest.java b/server/test/com/cloud/network/firewall/FirewallManagerTest.java
new file mode 100644
index 0000000..b17741f
--- /dev/null
+++ b/server/test/com/cloud/network/firewall/FirewallManagerTest.java
@@ -0,0 +1,67 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.network.firewall;
+
+
+import junit.framework.Assert;
+
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+import com.cloud.network.element.FirewallServiceProvider;
+import com.cloud.network.element.NetworkACLServiceProvider;
+import com.cloud.network.element.PortForwardingServiceProvider;
+import com.cloud.network.element.StaticNatServiceProvider;
+import com.cloud.network.rules.FirewallManager;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.testcase.ComponentSetup;
+import com.cloud.utils.testcase.ComponentTestCase;
+
+@ComponentSetup(managerName="management-server", setupXml="network-mgr-component.xml")
+public class FirewallManagerTest extends ComponentTestCase {
+    private static final Logger s_logger = Logger.getLogger(FirewallManagerTest.class);
+
+    @Test
+    public void testInjected() {
+        FirewallManagerImpl firewallMgr = (FirewallManagerImpl)ComponentLocator.getCurrentLocator().getManager(FirewallManager.class);
+        Assert.assertTrue(firewallMgr._firewallElements.enumeration().hasMoreElements());
+        Assert.assertTrue(firewallMgr._pfElements.enumeration().hasMoreElements());
+        Assert.assertTrue(firewallMgr._staticNatElements.enumeration().hasMoreElements());
+        Assert.assertTrue(firewallMgr._networkAclElements.enumeration().hasMoreElements());
+        Assert.assertNotNull(firewallMgr._networkModel);
+        
+        Assert.assertNotNull(firewallMgr._firewallElements.get("VirtualRouter"));
+        Assert.assertNotNull(firewallMgr._firewallElements.get("VpcVirtualRouter"));
+        Assert.assertNotNull(firewallMgr._pfElements.get("VirtualRouter"));
+        Assert.assertNotNull(firewallMgr._pfElements.get("VpcVirtualRouter"));
+        Assert.assertNotNull(firewallMgr._staticNatElements.get("VirtualRouter"));
+        Assert.assertNotNull(firewallMgr._staticNatElements.get("VpcVirtualRouter"));
+        Assert.assertNotNull(firewallMgr._networkAclElements.get("VpcVirtualRouter"));
+        Assert.assertNull(firewallMgr._networkAclElements.get("VirtualRouter"));
+
+        
+        Assert.assertTrue(firewallMgr._firewallElements.get("VirtualRouter") instanceof FirewallServiceProvider);
+        Assert.assertTrue(firewallMgr._pfElements.get("VirtualRouter") instanceof PortForwardingServiceProvider);
+        Assert.assertTrue(firewallMgr._staticNatElements.get("VirtualRouter") instanceof
StaticNatServiceProvider);
+        Assert.assertTrue(firewallMgr._networkAclElements.get("VpcVirtualRouter") instanceof
NetworkACLServiceProvider);
+        
+        s_logger.info("Done testing injection of service elements into firewall manager");
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/728db6c8/server/test/resources/network-mgr-component.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/network-mgr-component.xml b/server/test/resources/network-mgr-component.xml
index cc8b643..42d3c2e 100644
--- a/server/test/resources/network-mgr-component.xml
+++ b/server/test/resources/network-mgr-component.xml
@@ -91,47 +91,55 @@ under the License.
         </adapters>
         <adapters key="com.cloud.network.element.FirewallServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.DhcpServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
             <adapter name="ExternalDhcpElement" class="com.cloud.network.element.ExternalDhcpElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.UserDataServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.SourceNatServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
             <!--<adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
  -->
         </adapters>
         <adapters key="com.cloud.network.element.StaticNatServiceProvider">
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
             <!-- <adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
-->
         </adapters>
         <adapters key="com.cloud.network.element.PortForwardingServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
             <!-- <adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
-->
         </adapters>
         <adapters key="com.cloud.network.element.LoadBalancingServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.RemoteAccessVPNServiceProvider">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.Site2SiteVpnServiceProvider">
-            <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"
/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.IpDeployer">
             <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
             <!-- <adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
-->
         </adapters>
         <adapters key="com.cloud.network.element.ConnectivityProvider">
             <!-- <adapter name="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement"/>
-->
         </adapters>
         <adapters key="com.cloud.network.element.NetworkACLServiceProvider">
-            <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
         <adapters key="com.cloud.network.element.VpcProvider">
-            <adapter name="VirtualRouter" class="com.cloud.network.element.VirtualRouterElement"/>
+            <adapter name="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement"/>
         </adapters>
 
         <!--<manager name="OvsTunnelManager" key="com.cloud.network.ovs.OvsTunnelManager"
class="com.cloud.network.ovs.OvsTunnelManagerImpl"/>-->


Mime
View raw message