@@ -57,6 +57,7 @@ def __init__(self):
5757 "cpunumber" : 1 ,
5858 "cpuspeed" : 100 ,
5959 "memory" : 256 ,
60+ "issystem" : 'true' ,
6061 },
6162
6263 "network_offering" : {
@@ -338,8 +339,9 @@ def migrate_router(self, router):
338339 "Check list response returns a valid list"
339340 )
340341
342+ router .hostid = router_response [0 ].hostid
341343 self .assertEqual (router .hostid , host .id , "Migration to host %s failed. The router host is"
342- "still %s" % (host .id , router .hostid ))
344+ " still %s" % (host .id , router .hostid ))
343345 return
344346
345347 @attr (tags = ["advanced" , "intervlan" ])
@@ -470,45 +472,7 @@ def test_02_reboot_router_after_creating_vpc(self):
470472
471473
472474 @attr (tags = ["advanced" , "intervlan" ])
473- def test_03_destroy_router_after_creating_vpc (self ):
474- """ Test to destroy the router after creating a VPC
475- """
476- # Validate the following
477- # 1. Create a VPC with cidr - 10.1.1.1/16
478- # 2. Destroy the VPC Virtual Router which is created as a result of VPC creation.
479- self .validate_vpc_offering (self .vpc_off )
480- self .validate_vpc_network (self .vpc )
481- routers = Router .list (
482- self .apiclient ,
483- account = self .account .name ,
484- domainid = self .account .domainid ,
485- listall = True
486- )
487- self .assertEqual (
488- isinstance (routers , list ),
489- True ,
490- "List Routers should return a valid list"
491- )
492-
493- Router .destroy ( self .apiclient ,
494- id = routers [0 ].id
495- )
496-
497- routers = Router .list (
498- self .apiclient ,
499- account = self .account .name ,
500- domainid = self .account .domainid ,
501- listall = True
502- )
503- self .assertEqual (
504- isinstance (routers , list ),
505- False ,
506- "List Routers should be empty"
507- )
508- return
509-
510- @attr (tags = ["advanced" , "intervlan" ])
511- def test_04_migrate_router_after_creating_vpc (self ):
475+ def test_03_migrate_router_after_creating_vpc (self ):
512476 """ Test migration of router to another host after creating VPC """
513477
514478 self .validate_vpc_offering (self .vpc_off )
@@ -529,7 +493,7 @@ def test_04_migrate_router_after_creating_vpc(self):
529493 return
530494
531495 @attr (tags = ["advanced" , "intervlan" ])
532- def test_05_change_service_offerring_vpc (self ):
496+ def test_04_change_service_offerring_vpc (self ):
533497 """ Tests to change service offering of the Router after
534498 creating a vpc
535499 """
@@ -589,6 +553,44 @@ def test_05_change_service_offerring_vpc(self):
589553 )
590554 return
591555
556+ @attr (tags = ["advanced" , "intervlan" ])
557+ def test_05_destroy_router_after_creating_vpc (self ):
558+ """ Test to destroy the router after creating a VPC
559+ """
560+ # Validate the following
561+ # 1. Create a VPC with cidr - 10.1.1.1/16
562+ # 2. Destroy the VPC Virtual Router which is created as a result of VPC creation.
563+ self .validate_vpc_offering (self .vpc_off )
564+ self .validate_vpc_network (self .vpc )
565+ routers = Router .list (
566+ self .apiclient ,
567+ account = self .account .name ,
568+ domainid = self .account .domainid ,
569+ listall = True
570+ )
571+ self .assertEqual (
572+ isinstance (routers , list ),
573+ True ,
574+ "List Routers should return a valid list"
575+ )
576+
577+ Router .destroy ( self .apiclient ,
578+ id = routers [0 ].id
579+ )
580+
581+ routers = Router .list (
582+ self .apiclient ,
583+ account = self .account .name ,
584+ domainid = self .account .domainid ,
585+ listall = True
586+ )
587+ self .assertEqual (
588+ isinstance (routers , list ),
589+ False ,
590+ "List Routers should be empty"
591+ )
592+ return
593+
592594class TestVPCRouterOneNetwork (cloudstackTestCase ):
593595
594596 @classmethod
@@ -981,6 +983,7 @@ def migrate_router(self, router):
981983 "Check list response returns a valid list"
982984 )
983985
986+ router .hostid = router_response [0 ].hostid
984987 self .assertEqual (router .hostid , host .id , "Migration to host %s failed. The router host is"
985988 "still %s" % (host .id , router .hostid ))
986989 return
@@ -1149,9 +1152,9 @@ def test_02_reboot_router_after_addition_of_one_guest_network(self):
11491152 return
11501153
11511154 @attr (tags = ["advanced" , "intervlan" ])
1152- def test_03_destroy_router_after_addition_of_one_guest_network (self ):
1153- """ Test destroy of router after addition of one guest network
1154- """
1155+ def test_03_migrate_router_after_addition_of_one_guest_network (self ):
1156+ """ Test migrate of router after addition of one guest network
1157+ """
11551158 # Validations
11561159 #1. Create a VPC with cidr - 10.1.1.1/16
11571160 #2. Add network1(10.1.1.1/24) to this VPC.
@@ -1177,7 +1180,6 @@ def test_03_destroy_router_after_addition_of_one_guest_network(self):
11771180 True ,
11781181 "List static route should return a valid response"
11791182 )
1180-
11811183 routers = Router .list (
11821184 self .apiclient ,
11831185 account = self .account .name ,
@@ -1189,27 +1191,12 @@ def test_03_destroy_router_after_addition_of_one_guest_network(self):
11891191 True ,
11901192 "List Routers should return a valid list"
11911193 )
1192-
1193- Router .destroy ( self .apiclient ,
1194- id = routers [0 ].id
1195- )
1196-
1197- routers = Router .list (
1198- self .apiclient ,
1199- account = self .account .name ,
1200- domainid = self .account .domainid ,
1201- listall = True
1202- )
1203- self .assertEqual (
1204- isinstance (routers , list ),
1205- False ,
1206- "List Routers should be empty"
1207- )
1194+ self .migrate_router (routers [0 ])
12081195 return
12091196
12101197 @attr (tags = ["advanced" , "intervlan" ])
1211- def test_04_migrate_router_after_addition_of_one_guest_network (self ):
1212- """ Test migrate of router after addition of one guest network
1198+ def test_04_chg_srv_off_router_after_addition_of_one_guest_network (self ):
1199+ """ Test to change service offering of router after addition of one guest network
12131200 """
12141201 # Validations
12151202 #1. Create a VPC with cidr - 10.1.1.1/16
@@ -1236,6 +1223,7 @@ def test_04_migrate_router_after_addition_of_one_guest_network(self):
12361223 True ,
12371224 "List static route should return a valid response"
12381225 )
1226+
12391227 routers = Router .list (
12401228 self .apiclient ,
12411229 account = self .account .name ,
@@ -1247,13 +1235,47 @@ def test_04_migrate_router_after_addition_of_one_guest_network(self):
12471235 True ,
12481236 "List Routers should return a valid list"
12491237 )
1250- self .migrate_router (routers [0 ])
1238+
1239+ #Stop the router
1240+ router = routers [0 ]
1241+ self .debug ("Stopping the router with ID: %s" % router .id )
1242+ cmd = stopRouter .stopRouterCmd ()
1243+ cmd .id = router .id
1244+ self .apiclient .stopRouter (cmd )
1245+
1246+ service_offering = ServiceOffering .create (
1247+ self .apiclient ,
1248+ self .services ["service_offering_new" ]
1249+ )
1250+ self .debug ("Changing service offering for the Router %s" % router .id )
1251+ try :
1252+ router = Router .change_service_offering (self .apiclient ,
1253+ router .id ,
1254+ service_offering .id
1255+ )
1256+ except :
1257+ self .fail ("Changing service offering failed" )
1258+
1259+ self .debug ("Router %s" % router )
1260+ routers = Router .list (
1261+ self .apiclient ,
1262+ account = self .account .name ,
1263+ domainid = self .account .domainid ,
1264+ listall = True
1265+ )
1266+ router = routers [0 ]
1267+ self .assertEqual (
1268+ router .serviceofferingid ,
1269+ service_offering .id ,
1270+ "Changing service offering failed as id is %s and expected"
1271+ "is %s" % (router .serviceofferingid , service_offering .id )
1272+ )
12511273 return
12521274
12531275 @attr (tags = ["advanced" , "intervlan" ])
1254- def test_05_chg_srv_off_router_after_addition_of_one_guest_network (self ):
1255- """ Test to change service offering of router after addition of one guest network
1256- """
1276+ def test_05_destroy_router_after_addition_of_one_guest_network (self ):
1277+ """ Test destroy of router after addition of one guest network
1278+ """
12571279 # Validations
12581280 #1. Create a VPC with cidr - 10.1.1.1/16
12591281 #2. Add network1(10.1.1.1/24) to this VPC.
@@ -1279,7 +1301,7 @@ def test_05_chg_srv_off_router_after_addition_of_one_guest_network(self):
12791301 True ,
12801302 "List static route should return a valid response"
12811303 )
1282-
1304+
12831305 routers = Router .list (
12841306 self .apiclient ,
12851307 account = self .account .name ,
@@ -1291,39 +1313,20 @@ def test_05_chg_srv_off_router_after_addition_of_one_guest_network(self):
12911313 True ,
12921314 "List Routers should return a valid list"
12931315 )
1294-
1295- #Stop the router
1296- router = routers [0 ]
1297- self .debug ("Stopping the router with ID: %s" % router .id )
1298- cmd = stopRouter .stopRouterCmd ()
1299- cmd .id = router .id
1300- self .apiclient .stopRouter (cmd )
1301-
1302- service_offering = ServiceOffering .create (
1303- self .apiclient ,
1304- self .services ["service_offering_new" ]
1305- )
1306- self .debug ("Changing service offering for the Router %s" % router .id )
1307- try :
1308- router = Router .change_service_offering (self .apiclient ,
1309- router .id ,
1310- service_offering .id
1311- )
1312- except :
1313- self .fail ("Changing service offering failed" )
1314-
1315- self .debug ("Router %s" % router )
1316+
1317+ Router .destroy ( self .apiclient ,
1318+ id = routers [0 ].id
1319+ )
1320+
13161321 routers = Router .list (
13171322 self .apiclient ,
13181323 account = self .account .name ,
13191324 domainid = self .account .domainid ,
13201325 listall = True
13211326 )
1322- router = routers [0 ]
13231327 self .assertEqual (
1324- router .serviceofferingid ,
1325- service_offering .id ,
1326- "Changing service offering failed as id is %s and expected"
1327- "is %s" % (router .serviceofferingid , service_offering .id )
1328- )
1328+ isinstance (routers , list ),
1329+ False ,
1330+ "List Routers should be empty"
1331+ )
13291332 return
0 commit comments