Updated Branches:
  refs/heads/4.2 a310815aa -> 32d076ebc

CLOUDSTACK-3826: Automation: Fix test_vpc_routers

1. You cannot check routers after your destroy them
2. You cannot use the old value in checking migration status.
3. You cannot upgrade VR to a non-system offering.


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

Branch: refs/heads/4.2
Commit: 32d076ebcc2c16d1fea6ea4a4796ea0e688a8299
Parents: a310815
Author: Sheng Yang <[email protected]>
Authored: Tue Jul 30 16:25:39 2013 -0700
Committer: Sheng Yang <[email protected]>
Committed: Tue Jul 30 16:52:29 2013 -0700

----------------------------------------------------------------------
 test/integration/component/test_vpc_routers.py | 195 ++++++++++----------
 1 file changed, 99 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/32d076eb/test/integration/component/test_vpc_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_routers.py 
b/test/integration/component/test_vpc_routers.py
index 43116b0..be141fc 100644
--- a/test/integration/component/test_vpc_routers.py
+++ b/test/integration/component/test_vpc_routers.py
@@ -57,6 +57,7 @@ class Services:
                                     "cpunumber": 1,
                                     "cpuspeed": 100,
                                     "memory": 256,
+                                    "issystem": 'true',
                                     },
 
                          "network_offering": {
@@ -338,8 +339,9 @@ class TestVPCRoutersBasic(cloudstackTestCase):
                             "Check list response returns a valid list"
                         )
         
+        router.hostid = router_response[0].hostid
         self.assertEqual(router.hostid, host.id, "Migration to host %s failed. 
The router host is"
-                         "still %s" % (host.id, router.hostid))
+                         " still %s" % (host.id, router.hostid))
         return
 
     @attr(tags=["advanced", "intervlan"])
@@ -470,45 +472,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
 
 
     @attr(tags=["advanced", "intervlan"])
-    def test_03_destroy_router_after_creating_vpc(self):
-        """ Test to destroy the router after creating a VPC
-           """
-        # Validate the following
-           # 1. Create a VPC with cidr - 10.1.1.1/16
-           # 2. Destroy the VPC Virtual Router which is created as a result of 
VPC creation.
-        self.validate_vpc_offering(self.vpc_off)
-        self.validate_vpc_network(self.vpc)
-        routers = Router.list(
-                              self.apiclient,
-                              account=self.account.name,
-                              domainid=self.account.domainid,
-                              listall=True
-                              )
-        self.assertEqual(
-                         isinstance(routers, list),
-                         True,
-                         "List Routers should return a valid list"
-                         )
-     
-        Router.destroy( self.apiclient,
-                       id=routers[0].id
-                     )
-               
-        routers = Router.list(
-                              self.apiclient,
-                              account=self.account.name,
-                              domainid=self.account.domainid,
-                              listall=True
-                              )
-        self.assertEqual(
-                         isinstance(routers, list),
-                         False,
-                         "List Routers should be empty"
-                         )
-        return
-
-    @attr(tags=["advanced", "intervlan"])
-    def test_04_migrate_router_after_creating_vpc(self):
+    def test_03_migrate_router_after_creating_vpc(self):
         """ Test migration of router to another host after creating VPC """
 
         self.validate_vpc_offering(self.vpc_off)
@@ -529,7 +493,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
         return
 
     @attr(tags=["advanced", "intervlan"])
-    def test_05_change_service_offerring_vpc(self):
+    def test_04_change_service_offerring_vpc(self):
         """ Tests to change service offering of the Router after
             creating a vpc
         """
@@ -589,6 +553,44 @@ class TestVPCRoutersBasic(cloudstackTestCase):
                         ) 
         return
 
+    @attr(tags=["advanced", "intervlan"])
+    def test_05_destroy_router_after_creating_vpc(self):
+        """ Test to destroy the router after creating a VPC
+           """
+        # Validate the following
+           # 1. Create a VPC with cidr - 10.1.1.1/16
+           # 2. Destroy the VPC Virtual Router which is created as a result of 
VPC creation.
+        self.validate_vpc_offering(self.vpc_off)
+        self.validate_vpc_network(self.vpc)
+        routers = Router.list(
+                              self.apiclient,
+                              account=self.account.name,
+                              domainid=self.account.domainid,
+                              listall=True
+                              )
+        self.assertEqual(
+                         isinstance(routers, list),
+                         True,
+                         "List Routers should return a valid list"
+                         )
+     
+        Router.destroy( self.apiclient,
+                       id=routers[0].id
+                     )
+               
+        routers = Router.list(
+                              self.apiclient,
+                              account=self.account.name,
+                              domainid=self.account.domainid,
+                              listall=True
+                              )
+        self.assertEqual(
+                         isinstance(routers, list),
+                         False,
+                         "List Routers should be empty"
+                         )
+        return
+
 class TestVPCRouterOneNetwork(cloudstackTestCase):
 
     @classmethod
@@ -981,6 +983,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
                             "Check list response returns a valid list"
                         )
         
+        router.hostid = router_response[0].hostid
         self.assertEqual(router.hostid, host.id, "Migration to host %s failed. 
The router host is"
                          "still %s" % (host.id, router.hostid))
         return
@@ -1149,9 +1152,9 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
         return
 
     @attr(tags=["advanced", "intervlan"])
-    def test_03_destroy_router_after_addition_of_one_guest_network(self):
-        """ Test destroy of router after addition of one guest network
-        """
+    def test_03_migrate_router_after_addition_of_one_guest_network(self):
+        """ Test migrate of router after addition of one guest network
+           """
         # Validations
            #1. Create a VPC with cidr - 10.1.1.1/16
         #2. Add network1(10.1.1.1/24) to this VPC. 
@@ -1177,7 +1180,6 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
                         True,
                         "List static route should return a valid response"
                         )
-
         routers = Router.list(
                               self.apiclient,
                               account=self.account.name,
@@ -1189,27 +1191,12 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
                          True,
                          "List Routers should return a valid list"
                          )
-     
-        Router.destroy( self.apiclient,
-                       id=routers[0].id
-                     )
-               
-        routers = Router.list(
-                              self.apiclient,
-                              account=self.account.name,
-                              domainid=self.account.domainid,
-                              listall=True
-                              )
-        self.assertEqual(
-                         isinstance(routers, list),
-                         False,
-                         "List Routers should be empty"
-                         )
+        self.migrate_router(routers[0])
         return
 
     @attr(tags=["advanced", "intervlan"])
-    def test_04_migrate_router_after_addition_of_one_guest_network(self):
-        """ Test migrate of router after addition of one guest network
+    def test_04_chg_srv_off_router_after_addition_of_one_guest_network(self):
+        """ Test to change service offering of router after addition of one 
guest network
            """
         # Validations
            #1. Create a VPC with cidr - 10.1.1.1/16
@@ -1236,6 +1223,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
                         True,
                         "List static route should return a valid response"
                         )
+ 
         routers = Router.list(
                               self.apiclient,
                               account=self.account.name,
@@ -1247,13 +1235,47 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
                          True,
                          "List Routers should return a valid list"
                          )
-        self.migrate_router(routers[0])
+        
+        #Stop the router
+        router = routers[0]
+        self.debug("Stopping the router with ID: %s" % router.id)
+        cmd = stopRouter.stopRouterCmd()
+        cmd.id = router.id
+        self.apiclient.stopRouter(cmd)
+
+        service_offering = ServiceOffering.create(
+                                                  self.apiclient,
+                                                  
self.services["service_offering_new"]
+                                                 )
+        self.debug("Changing service offering for the Router %s" % router.id)
+        try: 
+            router = Router.change_service_offering(self.apiclient,
+                                                          router.id,
+                                                          service_offering.id
+                                                         )
+        except:
+            self.fail("Changing service offering failed")
+ 
+        self.debug("Router %s" % router)  
+        routers = Router.list(
+                              self.apiclient,
+                              account=self.account.name,
+                              domainid=self.account.domainid,
+                              listall=True
+                              )
+        router = routers[0]
+        self.assertEqual(
+                         router.serviceofferingid,
+                         service_offering.id,
+                         "Changing service offering failed as id is %s and 
expected"
+                         "is %s" % (router.serviceofferingid, 
service_offering.id)
+                        ) 
         return
 
     @attr(tags=["advanced", "intervlan"])
-    def test_05_chg_srv_off_router_after_addition_of_one_guest_network(self):
-        """ Test to change service offering of router after addition of one 
guest network
-           """
+    def test_05_destroy_router_after_addition_of_one_guest_network(self):
+        """ Test destroy of router after addition of one guest network
+        """
         # Validations
            #1. Create a VPC with cidr - 10.1.1.1/16
         #2. Add network1(10.1.1.1/24) to this VPC. 
@@ -1279,7 +1301,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
                         True,
                         "List static route should return a valid response"
                         )
- 
+
         routers = Router.list(
                               self.apiclient,
                               account=self.account.name,
@@ -1291,39 +1313,20 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
                          True,
                          "List Routers should return a valid list"
                          )
-        
-        #Stop the router
-        router = routers[0]
-        self.debug("Stopping the router with ID: %s" % router.id)
-        cmd = stopRouter.stopRouterCmd()
-        cmd.id = router.id
-        self.apiclient.stopRouter(cmd)
-
-        service_offering = ServiceOffering.create(
-                                                  self.apiclient,
-                                                  
self.services["service_offering_new"]
-                                                 )
-        self.debug("Changing service offering for the Router %s" % router.id)
-        try: 
-            router = Router.change_service_offering(self.apiclient,
-                                                          router.id,
-                                                          service_offering.id
-                                                         )
-        except:
-            self.fail("Changing service offering failed")
- 
-        self.debug("Router %s" % router)  
+     
+        Router.destroy( self.apiclient,
+                       id=routers[0].id
+                     )
+               
         routers = Router.list(
                               self.apiclient,
                               account=self.account.name,
                               domainid=self.account.domainid,
                               listall=True
                               )
-        router = routers[0]
         self.assertEqual(
-                         router.serviceofferingid,
-                         service_offering.id,
-                         "Changing service offering failed as id is %s and 
expected"
-                         "is %s" % (router.serviceofferingid, 
service_offering.id)
-                        ) 
+                         isinstance(routers, list),
+                         False,
+                         "List Routers should be empty"
+                         )
         return

Reply via email to