X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=doctor_tests%2Fmain.py;h=cdb4af55611deb354e8aa8177f28d4c3152f3e5f;hb=a0528f67abe01f0bb4be3565cfef4fd049afa1fa;hp=79480ca1226885f1a7c21fe384dc046ef1b4f92a;hpb=dcbe7bf1c26052b0e95d209254e7273aa1eaace1;p=doctor.git diff --git a/doctor_tests/main.py b/doctor_tests/main.py index 79480ca1..cdb4af55 100644 --- a/doctor_tests/main.py +++ b/doctor_tests/main.py @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2017 ZTE Corporation and others. +# Copyright (c) 2019 ZTE Corporation and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -10,6 +10,7 @@ import os from os.path import isfile, join import sys import time +from traceback import format_exc from doctor_tests import config from doctor_tests.identity_auth import get_identity_auth @@ -17,8 +18,9 @@ from doctor_tests.identity_auth import get_session from doctor_tests.image import Image from doctor_tests.installer import get_installer import doctor_tests.logger as doctor_log -from doctor_tests.os_clients import nova_client from doctor_tests.scenario.fault_management import FaultManagement +from doctor_tests.os_clients import nova_client +from doctor_tests.scenario.maintenance import Maintenance from doctor_tests.user import User @@ -51,9 +53,10 @@ class DoctorTest(object): def test_fault_management(self): try: LOG.info('doctor fault management test starting.......') - + transport_url = self.installer.get_transport_url() self.fault_management = \ - FaultManagement(self.conf, self.installer, self.user, LOG) + FaultManagement(self.conf, self.installer, self.user, LOG, + transport_url) # prepare test env self.fault_management.setup() @@ -77,6 +80,7 @@ class DoctorTest(object): except Exception as e: LOG.error('doctor fault management test failed, ' 'Exception=%s' % e) + LOG.error(format_exc()) sys.exit(1) finally: self.fault_management.cleanup() @@ -92,20 +96,42 @@ class DoctorTest(object): LOG.info('not enough compute nodes, skipping doctor ' 'maintenance test') return + elif self.conf.installer.type not in ['apex', 'fuel']: + LOG.info('not supported installer, skipping doctor ' + 'maintenance test') + return try: LOG.info('doctor maintenance test starting.......') - # TODO (tojuvone) test setup and actual test + trasport_url = self.installer.get_transport_url() + maintenance = Maintenance(trasport_url, self.conf, LOG) + maintenance.setup_maintenance(self.user) + + # wait for aodh alarms are updated in caches for event evaluator, + # sleep time should be larger than event_alarm_cache_ttl + # (default 60) + LOG.info('wait aodh for 120s.......') + time.sleep(120) + + session_id = maintenance.start_maintenance() + maintenance.wait_maintenance_complete(session_id) + + LOG.info('doctor maintenance complete.......') + except Exception as e: LOG.error('doctor maintenance test failed, Exception=%s' % e) + LOG.error(format_exc()) sys.exit(1) - # TODO (tojuvone) finally: test case specific cleanup + finally: + maintenance.cleanup_maintenance() 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() @@ -119,6 +145,7 @@ class DoctorTest(object): % function) except Exception as e: LOG.error('doctor test failed, Exception=%s' % e) + LOG.error(format_exc()) sys.exit(1) finally: self.cleanup()