cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [33/49] git commit: updated refs/heads/marvin_refactor to 0b5fe9a
Date Sun, 21 Apr 2013 17:03:44 GMT
Fixed VPC api unittests


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

Branch: refs/heads/marvin_refactor
Commit: 2ca7584994585307330182c5aca314692c732e47
Parents: 8d8a0eb
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Fri Apr 19 11:00:43 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Fri Apr 19 11:26:32 2013 -0700

----------------------------------------------------------------------
 server/pom.xml                                     |    1 -
 server/test/com/cloud/vpc/Site2SiteVpnTest.java    |    2 +-
 server/test/com/cloud/vpc/VpcApiUnitTest.java      |  167 ++++----------
 .../test/com/cloud/vpc/VpcTestConfiguration.java   |   73 ++++---
 4 files changed, 91 insertions(+), 152 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ca75849/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index ca56851..7249c55 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -153,7 +153,6 @@
             <exclude>com/cloud/snapshot/*</exclude>
             <exclude>com/cloud/storage/dao/*</exclude>
             <exclude>com/cloud/vm/dao/*</exclude>
-            <exclude>com/cloud/vpc/*</exclude>
             <exclude>com/cloud/api/ListPerfTest.java</exclude>
             <exclude>com/cloud/network/vpn/RemoteAccessVpnTest.java</exclude>
             <exclude>com/cloud/network/security/SecurityGroupManagerImpl2Test.java</exclude>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ca75849/server/test/com/cloud/vpc/Site2SiteVpnTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/Site2SiteVpnTest.java b/server/test/com/cloud/vpc/Site2SiteVpnTest.java
index 8e1b093..083cf25 100644
--- a/server/test/com/cloud/vpc/Site2SiteVpnTest.java
+++ b/server/test/com/cloud/vpc/Site2SiteVpnTest.java
@@ -25,7 +25,7 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations="classpath:/testContext.xml")
+@ContextConfiguration(locations="classpath:/VpcTestContext.xml")
 public class Site2SiteVpnTest {
     private final static Logger s_logger = Logger.getLogger(Site2SiteVpnTest.class);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ca75849/server/test/com/cloud/vpc/VpcApiUnitTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/VpcApiUnitTest.java b/server/test/com/cloud/vpc/VpcApiUnitTest.java
index d4d5b29..e141c96 100644
--- a/server/test/com/cloud/vpc/VpcApiUnitTest.java
+++ b/server/test/com/cloud/vpc/VpcApiUnitTest.java
@@ -23,7 +23,6 @@ import javax.inject.Inject;
 
 import junit.framework.TestCase;
 
-import org.apache.log4j.Logger;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -40,68 +39,18 @@ import com.cloud.utils.component.ComponentContext;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = "classpath:/VpcTestContext.xml")
 public class VpcApiUnitTest extends TestCase{
-    private static final Logger s_logger = Logger.getLogger(VpcApiUnitTest.class);
     @Inject VpcManagerImpl _vpcService = null;
 
-    @Override
     @Before
     public void setUp() throws Exception {
         ComponentContext.initComponentsLifeCycle();
     }
     
-    @Test
-    public void test() {
-        s_logger.debug("Starting test for VpcService interface");
-        //Vpc service methods
-        //getActiveVpc();
-        //deleteVpc();
-        
-        //Vpc manager methods
-        validateNtwkOffForVpc();
-        //destroyVpc();
-       
-    }
-    
-    protected void deleteVpc() {
-        //delete existing offering
-        boolean result = false;
-        String msg = null;
-        try {
-            List<String> svcs = new ArrayList<String>();
-            svcs.add(Service.SourceNat.getName());
-            result = _vpcService.deleteVpc(1);
-        }  catch (Exception ex) {
-            msg = ex.getMessage();
-        } finally {
-            if (result) {
-                s_logger.debug("Delete vpc: Test passed, vpc is deleted");
-            } else {
-                s_logger.error("Delete vpc: TEST FAILED, vpc failed to delete " + msg);
-            }
-        }
-        
-        //delete non-existing offering
-        result = false;
-        msg = null;
-        try {
-            List<String> svcs = new ArrayList<String>();
-            svcs.add(Service.SourceNat.getName());
-            result = _vpcService.deleteVpc(100);
-        }  catch (Exception ex) {
-            msg = ex.getMessage();
-        } finally {
-            if (!result) {
-                s_logger.debug("Delete vpc: Test passed, non existing vpc failed to delete
");
-            } else {
-                s_logger.error("Delete vpc: TEST FAILED, true is returned when try to delete
non existing vpc");
-            }
-        }
-    }
     
-    protected void getActiveVpc() {
+    @Test
+    public void getActiveVpc() {
         //test for active vpc
         boolean result = false;
-        String msg = null;
         Vpc vpc = null;
         try {
             List<String> svcs = new ArrayList<String>();
@@ -111,18 +60,12 @@ public class VpcApiUnitTest extends TestCase{
                 result = true;
             }
         }  catch (Exception ex) {
-            msg = ex.getMessage();
         } finally {
-            if (result) {
-                s_logger.debug("Get active Vpc: Test passed, active vpc is returned");
-            } else {
-                s_logger.error("Get active Vpc: TEST FAILED, active vpc is not returned "
+ msg);
-            }
+            assertTrue("Get active Vpc: TEST FAILED, active vpc is not returned", result);
         }
         
         //test for inactive vpc
         result = false;
-        msg = null;
         vpc = null;
         try {
             List<String> svcs = new ArrayList<String>();
@@ -132,66 +75,43 @@ public class VpcApiUnitTest extends TestCase{
                 result = true;
             }
         }  catch (Exception ex) {
-            msg = ex.getMessage();
         } finally {
-            if (!result) {
-                s_logger.debug("Get active Vpc: Test passed, no vpc is returned");
-            } else {
-                s_logger.error("Get active Vpc: TEST FAILED, non active vpc is returned");
-            }
+            assertFalse("Get active Vpc: TEST FAILED, non active vpc is returned", result);
         }
     }
     
-    protected void destroyVpc() {
-        try {
-            _vpcService.destroyVpc(_vpcService.getVpc(1), new AccountVO(), 1L);
-        } catch (Exception ex) {
-            s_logger.error("Destroy VPC TEST FAILED due to exc ", ex);
-        }
-    }
 
-    protected void validateNtwkOffForVpc() {
+    @Test
+    public void validateNtwkOffForVpc() {
         //validate network offering
         //1) correct network offering
         boolean result = false;
         try {
             _vpcService.validateNtwkOffForNtwkInVpc(2L, 1, "0.0.0.0", "111-", _vpcService.getVpc(1),
"10.1.1.1", new AccountVO());
             result = true;
-            s_logger.debug("Validate network offering: Test passed: the offering is valid
for vpc creation");
         } catch (Exception ex) {
-            s_logger.error("Validate network offering: TEST FAILED due to exc ", ex);
+        } finally {
+            assertTrue("Validate network offering: Test passed: the offering is valid for
vpc creation", result);
         }
         
         //2) invalid offering - source nat is not included
         result = false;
-        String msg = null;
         try {
             _vpcService.validateNtwkOffForNtwkInVpc(2L, 2, "0.0.0.0", "111-", _vpcService.getVpc(1),
"10.1.1.1", new AccountVO());
             result = true;
         } catch (InvalidParameterValueException ex) {
-            msg = ex.getMessage();
         } finally {
-            if (!result) {
-                s_logger.debug("Validate network offering: Test passed: "  + msg);
-            } else {
-                s_logger.error("Validate network offering: TEST FAILED, can't use network
offering without SourceNat service");
-            }
+            assertFalse("Validate network offering: TEST FAILED, can't use network offering
without SourceNat service", result);
         }
         
         //3) invalid offering - conserve mode is off
         result = false;
-        msg = null;
         try {
             _vpcService.validateNtwkOffForNtwkInVpc(2L, 3, "0.0.0.0", "111-", _vpcService.getVpc(1),
"10.1.1.1", new AccountVO());
             result = true;
         } catch (InvalidParameterValueException ex) {
-            msg = ex.getMessage();
         } finally {
-            if (!result) {
-                s_logger.debug("Validate network offering: Test passed: " + msg);
-            } else {
-                s_logger.error("Validate network offering: TEST FAILED, can't use network
offering without conserve mode = true");
-            }
+            assertFalse("Validate network offering: TEST FAILED, can't use network offering
without conserve mode = true", result);
         }
         
         //4) invalid offering - guest type shared
@@ -200,13 +120,8 @@ public class VpcApiUnitTest extends TestCase{
             _vpcService.validateNtwkOffForNtwkInVpc(2L, 4, "0.0.0.0", "111-", _vpcService.getVpc(1),
"10.1.1.1", new AccountVO());
             result = true;
         } catch (InvalidParameterValueException ex) {
-            msg = ex.getMessage();
         } finally {
-            if (!result) {
-                s_logger.debug("Validate network offering: Test passed: " + msg);
-            } else {
-                s_logger.error("Validate network offering: TEST FAILED, can't use network
offering with guest type = Shared");
-            }
+            assertFalse("Validate network offering: TEST FAILED, can't use network offering
with guest type = Shared", result);
         }
         
         //5) Invalid offering - no redundant router support
@@ -215,30 +130,44 @@ public class VpcApiUnitTest extends TestCase{
             _vpcService.validateNtwkOffForNtwkInVpc(2L, 5, "0.0.0.0", "111-", _vpcService.getVpc(1),
"10.1.1.1", new AccountVO());
             result = true;
         } catch (InvalidParameterValueException ex) {
-            msg = ex.getMessage();
         } finally {
-            if (!result) {
-                s_logger.debug("Validate network offering: Test passed: " + msg);
-            } else {
-                s_logger.error("TEST FAILED, can't use network offering with guest type =
Shared");
-            }
-        }
-        
-        //6) Only one network in the VPC can support LB service - negative scenario
-        result = false;
-        try {
-            _vpcService.validateNtwkOffForNtwkInVpc(2L, 6, "0.0.0.0", "111-", _vpcService.getVpc(1),
"10.1.1.1", new AccountVO());
-            result = true;
-            s_logger.debug("Validate network offering: Test passed: the offering is valid
for vpc creation");
-        } catch (InvalidParameterValueException ex) {
-            msg = ex.getMessage();
-        } finally {
-            if (!result) {
-                s_logger.debug("Test passed : " + msg);
-            } else {
-                s_logger.error("Validate network offering: TEST FAILED, can't use network
offering with guest type = Shared");
-            }
+            assertFalse("TEST FAILED, can't use network offering with guest type = Shared",
result);
         }
     }
-
+    
+    
+//    public void destroyVpc() {
+//        boolean result = false;
+//        try {
+//            result = _vpcService.destroyVpc(_vpcService.getVpc(1), new AccountVO(), 1L);
+//        } catch (Exception ex) {
+//            s_logger.debug(ex);
+//        } finally {
+//            assertTrue("Failed to destroy VPC", result);
+//        }
+//    }
+//
+//    public void deleteVpc() {
+//        //delete existing offering
+//        boolean result = false;
+//        try {
+//            List<String> svcs = new ArrayList<String>();
+//            svcs.add(Service.SourceNat.getName());
+//            result = _vpcService.deleteVpc(1);
+//        }  catch (Exception ex) {
+//        } finally {
+//            assertTrue("Delete vpc: TEST FAILED, vpc failed to delete" + result, result);
+//        }
+//        
+//        //delete non-existing offering
+//        result = false;
+//        try {
+//            List<String> svcs = new ArrayList<String>();
+//            svcs.add(Service.SourceNat.getName());
+//            result = _vpcService.deleteVpc(100);
+//        }  catch (Exception ex) {
+//        } finally {
+//            assertFalse("Delete vpc: TEST FAILED, true is returned when try to delete non
existing vpc" + result, result);
+//        }
+//    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ca75849/server/test/com/cloud/vpc/VpcTestConfiguration.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/VpcTestConfiguration.java b/server/test/com/cloud/vpc/VpcTestConfiguration.java
index df73a6c..b1f2f80 100644
--- a/server/test/com/cloud/vpc/VpcTestConfiguration.java
+++ b/server/test/com/cloud/vpc/VpcTestConfiguration.java
@@ -32,6 +32,7 @@ import org.springframework.core.type.filter.TypeFilter;
 import com.cloud.alert.AlertManager;
 import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
 import com.cloud.configuration.dao.ConfigurationDaoImpl;
+import com.cloud.configuration.dao.ResourceCountDaoImpl;
 import com.cloud.configuration.dao.ResourceLimitDaoImpl;
 import com.cloud.dao.EntityManagerImpl;
 import com.cloud.dc.dao.AccountVlanMapDaoImpl;
@@ -44,63 +45,66 @@ import com.cloud.dc.dao.DcDetailsDaoImpl;
 import com.cloud.dc.dao.HostPodDaoImpl;
 import com.cloud.dc.dao.PodVlanDaoImpl;
 import com.cloud.dc.dao.PodVlanMapDaoImpl;
+import com.cloud.dc.dao.VlanDaoImpl;
 import com.cloud.domain.dao.DomainDaoImpl;
 import com.cloud.event.dao.UsageEventDao;
 import com.cloud.host.dao.HostDaoImpl;
 import com.cloud.host.dao.HostDetailsDaoImpl;
 import com.cloud.host.dao.HostTagsDaoImpl;
-import com.cloud.vpc.MockNetworkModelImpl;
+import com.cloud.network.Ipv6AddressManagerImpl;
 import com.cloud.network.StorageNetworkManager;
-import com.cloud.network.dao.IPAddressDaoImpl;
-import com.cloud.network.lb.LoadBalancingRulesManager;
-import com.cloud.network.rules.RulesManager;
-import com.cloud.network.vpc.VpcManagerImpl;
-import com.cloud.network.vpc.dao.PrivateIpDaoImpl;
-import com.cloud.network.vpc.dao.StaticRouteDaoImpl;
-import com.cloud.network.vpc.dao.VpcDao;
-import com.cloud.network.vpc.dao.VpcGatewayDaoImpl;
-import com.cloud.network.vpc.dao.VpcOfferingDao;
-import com.cloud.utils.component.SpringComponentScanUtils;
-import com.cloud.vm.UserVmManager;
-import com.cloud.vm.dao.DomainRouterDaoImpl;
-import com.cloud.vm.dao.NicDaoImpl;
-import com.cloud.vm.dao.UserVmDaoImpl;
-import com.cloud.vm.dao.UserVmDetailsDaoImpl;
-import com.cloud.vm.dao.VMInstanceDaoImpl;
-import com.cloud.vpc.dao.MockNetworkOfferingDaoImpl;
-import com.cloud.vpc.dao.MockNetworkOfferingServiceMapDaoImpl;
-import com.cloud.vpc.dao.MockNetworkServiceMapDaoImpl;
-import com.cloud.vpc.dao.MockVpcOfferingDaoImpl;
-import com.cloud.vpc.dao.MockVpcOfferingServiceMapDaoImpl;
-
-
-import com.cloud.configuration.dao.ResourceCountDaoImpl;
-import com.cloud.dc.dao.VlanDaoImpl;
 import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
 import com.cloud.network.dao.FirewallRulesDaoImpl;
+import com.cloud.network.dao.IPAddressDaoImpl;
 import com.cloud.network.dao.LoadBalancerDaoImpl;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.dao.PhysicalNetworkDaoImpl;
 import com.cloud.network.dao.PhysicalNetworkTrafficTypeDaoImpl;
 import com.cloud.network.dao.RouterNetworkDaoImpl;
 import com.cloud.network.dao.Site2SiteVpnGatewayDaoImpl;
+import com.cloud.network.dao.UserIpv6AddressDaoImpl;
 import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
 import com.cloud.network.element.NetworkElement;
 import com.cloud.network.element.Site2SiteVpnServiceProvider;
+import com.cloud.network.lb.LoadBalancingRulesManager;
+import com.cloud.network.rules.RulesManager;
+import com.cloud.network.vpc.VpcManagerImpl;
+import com.cloud.network.vpc.dao.PrivateIpDaoImpl;
+import com.cloud.network.vpc.dao.StaticRouteDaoImpl;
+import com.cloud.network.vpc.dao.VpcDao;
+import com.cloud.network.vpc.dao.VpcGatewayDaoImpl;
+import com.cloud.network.vpc.dao.VpcOfferingDao;
+import com.cloud.network.vpc.dao.VpcServiceMapDaoImpl;
 import com.cloud.network.vpn.RemoteAccessVpnService;
 import com.cloud.network.vpn.Site2SiteVpnManager;
 import com.cloud.projects.dao.ProjectAccountDaoImpl;
 import com.cloud.projects.dao.ProjectDaoImpl;
 import com.cloud.resourcelimit.ResourceLimitManagerImpl;
+import com.cloud.service.dao.ServiceOfferingDaoImpl;
 import com.cloud.storage.dao.SnapshotDaoImpl;
 import com.cloud.storage.dao.VMTemplateDaoImpl;
 import com.cloud.storage.dao.VMTemplateDetailsDaoImpl;
+import com.cloud.storage.dao.VMTemplateHostDaoImpl;
 import com.cloud.storage.dao.VMTemplateZoneDaoImpl;
 import com.cloud.storage.dao.VolumeDaoImpl;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 import com.cloud.user.AccountManager;
 import com.cloud.user.dao.AccountDaoImpl;
 import com.cloud.user.dao.UserStatisticsDaoImpl;
+import com.cloud.utils.component.SpringComponentScanUtils;
+import com.cloud.vm.UserVmManager;
+import com.cloud.vm.dao.DomainRouterDaoImpl;
+import com.cloud.vm.dao.NicDaoImpl;
+import com.cloud.vm.dao.NicSecondaryIpDaoImpl;
+import com.cloud.vm.dao.UserVmDaoImpl;
+import com.cloud.vm.dao.UserVmDetailsDaoImpl;
+import com.cloud.vm.dao.VMInstanceDaoImpl;
+import com.cloud.vpc.dao.MockNetworkOfferingDaoImpl;
+import com.cloud.vpc.dao.MockNetworkOfferingServiceMapDaoImpl;
+import com.cloud.vpc.dao.MockNetworkServiceMapDaoImpl;
+import com.cloud.vpc.dao.MockVpcDaoImpl;
+import com.cloud.vpc.dao.MockVpcOfferingDaoImpl;
+import com.cloud.vpc.dao.MockVpcOfferingServiceMapDaoImpl;
 
 
 @Configuration
@@ -141,12 +145,18 @@ import com.cloud.user.dao.UserStatisticsDaoImpl;
         SnapshotDaoImpl.class,
         VMInstanceDaoImpl.class,
         VolumeDaoImpl.class,
+        UserIpv6AddressDaoImpl.class,
+        NicSecondaryIpDaoImpl.class,
+        VpcServiceMapDaoImpl.class,
+        ServiceOfferingDaoImpl.class,
+        VMTemplateHostDaoImpl.class,
+        MockVpcDaoImpl.class,
         VMTemplateDaoImpl.class,VMTemplateZoneDaoImpl.class,VMTemplateDetailsDaoImpl.class,DataCenterDaoImpl.class,DataCenterIpAddressDaoImpl.class,DataCenterLinkLocalIpAddressDaoImpl.class,DataCenterVnetDaoImpl.class,PodVlanDaoImpl.class,
         DcDetailsDaoImpl.class,MockNetworkManagerImpl.class,MockVpcVirtualNetworkApplianceManager.class,
         EntityManagerImpl.class,LoadBalancerDaoImpl.class,FirewallRulesCidrsDaoImpl.class,VirtualRouterProviderDaoImpl.class,
         ProjectDaoImpl.class,ProjectAccountDaoImpl.class,MockVpcOfferingDaoImpl.class,
         MockConfigurationManagerImpl.class, MockNetworkOfferingServiceMapDaoImpl.class,
-        MockNetworkServiceMapDaoImpl.class,MockVpcOfferingServiceMapDaoImpl.class,MockNetworkOfferingDaoImpl.class,
MockNetworkModelImpl.class},
+        MockNetworkServiceMapDaoImpl.class,MockVpcOfferingServiceMapDaoImpl.class,MockNetworkOfferingDaoImpl.class,
MockNetworkModelImpl.class, Ipv6AddressManagerImpl.class},
         includeFilters={@Filter(value=VpcTestConfiguration.VpcLibrary.class, type=FilterType.CUSTOM)},
         useDefaultFilters=false
         )
@@ -210,15 +220,16 @@ public class VpcTestConfiguration {
         return Mockito.mock(RemoteAccessVpnService.class);
     }
 
-    @Bean
-    public VpcDao vpcDao() {
-        return Mockito.mock(VpcDao.class);
-    }
+//    @Bean
+//    public VpcDao vpcDao() {
+//        return Mockito.mock(VpcDao.class);
+//    }
 
     @Bean
     public NetworkDao networkDao() {
         return Mockito.mock(NetworkDao.class);
     }
+    
 
     public static class VpcLibrary implements TypeFilter {
         @Override


Mime
View raw message