+ except Exception as e:
+ LOG.error('doctor fault management test failed, '
+ 'Exception=%s' % e)
+ sys.exit(1)
+ finally:
+ self.cleanup_fault_management()
+
+ def _amount_compute_nodes(self):
+ services = self.nova.services.list(binary='nova-compute')
+ return len(services)
+
+ def test_maintenance(self):
+ cnodes = self._amount_compute_nodes()
+ if cnodes < 3:
+ # need 2 compute for redundancy and one spare to migrate
+ LOG.info('not enough compute nodes, skipping doctor '
+ 'maintenance test')
+ return
+ try:
+ LOG.info('doctor maintenance test starting.......')
+ # TODO (tojuvone) test setup and actual test
+ except Exception as e:
+ LOG.error('doctor maintenance test failed, Exception=%s' % e)
+ sys.exit(1)
+ # TODO (tojuvone) finally: test case specific cleanup
+
+ def run(self):
+ """run doctor tests"""
+ try:
+ LOG.info('doctor test starting.......')
+ # prepare common test env
+ self.setup()
+ if self.conf.test_case == 'all':
+ self.test_fault_management()
+ self.test_maintenance()
+ else:
+ function = 'test_%s' % self.conf.test_case
+ if hasattr(self, function):
+ getattr(self, function)()
+ else:
+ raise Exception('Can not find function <%s> in'
+ 'DoctorTest, see config manual'
+ % function)