Maintenance support for latest Fenix, python3 and Fuel
[doctor.git] / doctor_tests / main.py
index 2a8abda..cdb4af5 100644 (file)
@@ -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
@@ -53,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()
@@ -79,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()
@@ -94,17 +96,26 @@ class DoctorTest(object):
             LOG.info('not enough compute nodes, skipping doctor '
                      'maintenance test')
             return
-        elif self.conf.installer.type != 'apex':
+        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.......')
-
-            maintenance = Maintenance(self.conf, LOG)
+            trasport_url = self.installer.get_transport_url()
+            maintenance = Maintenance(trasport_url, self.conf, LOG)
             maintenance.setup_maintenance(self.user)
 
-            # TODO (tojuvone) actual test
+            # 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)
@@ -134,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()