CLOUDSTACK-3655: RvR tests fail when handling switchover

During switchover of master->backup->master, the rvr goes through
UNKNOWN, FAULT, MASTER/BACKUP. In case of improper transition the state
is FAULT. Include additional state check in the tests.
(cherry picked from commit 0c699394f246bc2b052a22d88b3f938ba8a72770)
This commit is contained in:
Prasanna Santhanam 2013-07-19 17:34:26 +05:30
parent ae2ee95069
commit 62c54e77a3
2 changed files with 45 additions and 57 deletions

View File

@ -1051,7 +1051,6 @@ class TestRvRRedundancy(cloudstackTestCase):
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Listing routers for network: %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=master_router.id, id=master_router.id,
listall=True listall=True
) )
@ -1060,28 +1059,27 @@ class TestRvRRedundancy(cloudstackTestCase):
True, True,
"list router should return Master and backup routers" "list router should return Master and backup routers"
) )
self.assertEqual( self.assertIn(
routers[0].redundantstate, routers[0].redundantstate,
'UNKNOWN', ['UNKNOWN', 'FAULT'],
"Redundant state of the router should be UNKNOWN" "Redundant state of the master router should be UNKNOWN/FAULT but is %s" % routers[0].redundantstate
) )
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=backup_router.id, id=backup_router.id,
listall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(routers, list), isinstance(routers, list),
True, True,
"list router should return Master and backup routers" "list router should return backup router"
) )
self.assertEqual( self.assertEqual(
routers[0].redundantstate, routers[0].redundantstate,
'MASTER', 'MASTER',
"Redundant state of the router should be MASTER" "Redundant state of the router should be MASTER but is %s" % routers[0].redundantstate
) )
self.debug("Starting the old MASTER router") self.debug("Starting the old MASTER router")
@ -1089,12 +1087,11 @@ class TestRvRRedundancy(cloudstackTestCase):
Router.start(self.apiclient, id=master_router.id) Router.start(self.apiclient, id=master_router.id)
self.debug("old MASTER router started") self.debug("old MASTER router started")
except Exception as e: except Exception as e:
self.fail("Failed to stop master router: %s" % e) self.fail("Failed to start master router: %s" % e)
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the master router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=master_router.id, id=master_router.id,
listall=True listall=True
) )
@ -1106,7 +1103,7 @@ class TestRvRRedundancy(cloudstackTestCase):
self.assertEqual( self.assertEqual(
routers[0].redundantstate, routers[0].redundantstate,
'BACKUP', 'BACKUP',
"Redundant state of the router should be BACKUP" "Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
) )
self.assertEqual( self.assertEqual(
master_router.publicip, master_router.publicip,
@ -1171,10 +1168,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to stop backup router: %s" % e) self.fail("Failed to stop backup router: %s" % e)
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=backup_router.id, id=backup_router.id,
listall=True listall=True
) )
@ -1183,16 +1179,15 @@ class TestRvRRedundancy(cloudstackTestCase):
True, True,
"list router should return Master and backup routers" "list router should return Master and backup routers"
) )
self.assertEqual( self.assertIn(
routers[0].redundantstate, routers[0].redundantstate,
'UNKNOWN', ['UNKNOWN', 'FAULT'],
"Redundant state of the router should be UNKNOWN" "Redundant state of the backup router should be UNKNOWN/FAULT but is %s" % routers[0].redundantstate
) )
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the master router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=master_router.id, id=master_router.id,
listall=True listall=True
) )
@ -1204,7 +1199,7 @@ class TestRvRRedundancy(cloudstackTestCase):
self.assertEqual( self.assertEqual(
routers[0].redundantstate, routers[0].redundantstate,
'MASTER', 'MASTER',
"Redundant state of the router should be MASTER" "Redundant state of the router should be MASTER but is %s" % routers[0].redundantstate
) )
self.debug("Starting the old BACKUP router") self.debug("Starting the old BACKUP router")
@ -1214,10 +1209,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to stop master router: %s" % e) self.fail("Failed to stop master router: %s" % e)
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=backup_router.id, id=backup_router.id,
listall=True listall=True
) )
@ -1229,7 +1223,7 @@ class TestRvRRedundancy(cloudstackTestCase):
self.assertEqual( self.assertEqual(
routers[0].redundantstate, routers[0].redundantstate,
'BACKUP', 'BACKUP',
"Redundant state of the router should be BACKUP" "Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
) )
self.assertEqual( self.assertEqual(
backup_router.publicip, backup_router.publicip,
@ -1288,10 +1282,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to reboot MASTER router: %s" % e) self.fail("Failed to reboot MASTER router: %s" % e)
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the master router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=master_router.id, id=master_router.id,
listall=True listall=True
) )
@ -1303,13 +1296,12 @@ class TestRvRRedundancy(cloudstackTestCase):
self.assertEqual( self.assertEqual(
routers[0].redundantstate, routers[0].redundantstate,
'BACKUP', 'BACKUP',
"Redundant state of the router should be BACKUP" "Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
) )
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=backup_router.id, id=backup_router.id,
listall=True listall=True
) )
@ -1321,7 +1313,7 @@ class TestRvRRedundancy(cloudstackTestCase):
self.assertEqual( self.assertEqual(
routers[0].redundantstate, routers[0].redundantstate,
'MASTER', 'MASTER',
"Redundant state of the router should be MASTER" "Redundant state of the router should be MASTER but is %s" % routers[0].redundantstate
) )
self.assertEqual( self.assertEqual(
master_router.publicip, master_router.publicip,
@ -1374,16 +1366,15 @@ class TestRvRRedundancy(cloudstackTestCase):
master_router = routers[1] master_router = routers[1]
backup_router = routers[0] backup_router = routers[0]
self.debug("Rebooting the backuo router") self.debug("Rebooting the backup router")
try: try:
Router.reboot(self.apiclient, id=backup_router.id) Router.reboot(self.apiclient, id=backup_router.id)
except Exception as e: except Exception as e:
self.fail("Failed to reboot BACKUP router: %s" % e) self.fail("Failed to reboot BACKUP router: %s" % e)
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=backup_router.id, id=backup_router.id,
listall=True listall=True
) )
@ -1395,13 +1386,12 @@ class TestRvRRedundancy(cloudstackTestCase):
self.assertEqual( self.assertEqual(
routers[0].redundantstate, routers[0].redundantstate,
'BACKUP', 'BACKUP',
"Redundant state of the router should be BACKUP" "Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
) )
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the master router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=master_router.id, id=master_router.id,
listall=True listall=True
) )
@ -1413,7 +1403,7 @@ class TestRvRRedundancy(cloudstackTestCase):
self.assertEqual( self.assertEqual(
routers[0].redundantstate, routers[0].redundantstate,
'MASTER', 'MASTER',
"Redundant state of the router should be MASTER" "Redundant state of the router should be MASTER but is %s" % routers[0].redundantstate
) )
self.assertEqual( self.assertEqual(
master_router.publicip, master_router.publicip,
@ -1472,10 +1462,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to stop BACKUP router: %s" % e) self.fail("Failed to stop BACKUP router: %s" % e)
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=backup_router.id, id=backup_router.id,
listall=True listall=True
) )
@ -1484,11 +1473,11 @@ class TestRvRRedundancy(cloudstackTestCase):
True, True,
"list router should return Master and backup routers" "list router should return Master and backup routers"
) )
self.assertEqual( self.assertIn(
routers[0].redundantstate, routers[0].redundantstate,
'UNKNOWN', ['UNKNOWN', 'FAULT'],
"Redundant state of the router should be UNKNOWN" "Redundant state of the backup router should be UNKNOWN/FAULT but is %s" % routers[0].redundantstate
) )
# Spawn an instance in that network # Spawn an instance in that network
vm_2 = VirtualMachine.create( vm_2 = VirtualMachine.create(
@ -1518,10 +1507,9 @@ class TestRvRRedundancy(cloudstackTestCase):
"Vm should be in running state after deployment" "Vm should be in running state after deployment"
) )
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
networkid=self.network.id,
id=backup_router.id, id=backup_router.id,
listall=True listall=True
) )
@ -1533,6 +1521,6 @@ class TestRvRRedundancy(cloudstackTestCase):
self.assertEqual( self.assertEqual(
routers[0].redundantstate, routers[0].redundantstate,
'BACKUP', 'BACKUP',
"Redundant state of the router should be BACKUP" "Redundant state of the router should be BACKUP but is %s" % routers[0].redundantstate
) )
return return

View File

@ -191,9 +191,9 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns"])
def test_RvR_multipods(self): def test_RvR_multipods(self):
"""Test RvR with muti pods """Test RvR with multi pods
""" """
# Steps to validate # Steps to validate
@ -323,9 +323,9 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
) )
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns"])
def test_RvR_multicluster(self): def test_RvR_multicluster(self):
"""Test RvR with muti clusters """Test RvR with multi clusters
""" """
# Steps to validate # Steps to validate
@ -526,9 +526,9 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
self.apiclient.updatePod(cmd) self.apiclient.updatePod(cmd)
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns"])
def test_RvR_multiprimarystorage(self): def test_RvR_multiprimarystorage(self):
"""Test RvR with muti primary storage """Test RvR with multi primary storage
""" """
# Steps to validate # Steps to validate
@ -770,7 +770,7 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_RvR_multihosts(self): def test_RvR_multihosts(self):
"""Test RvR with muti hosts """Test RvR with multi hosts
""" """
# Steps to validate # Steps to validate