Add Collectd as a Monitor Type
[doctor.git] / tests / main.py
index 182680c..b360f12 100644 (file)
@@ -12,12 +12,16 @@ import sys
 
 from alarm import Alarm
 import config
+from consumer import get_consumer
 from image import Image
 from instance import Instance
 from inspector import get_inspector
+from installer import get_installer
 import logger as doctor_log
 from user import User
 from network import Network
+from monitor import get_monitor
+
 
 LOG = doctor_log.Logger('doctor').getLogger()
 
@@ -32,9 +36,15 @@ class DoctorTest(object):
         self.instance = Instance(self.conf, LOG)
         self.alarm = Alarm(self.conf, LOG)
         self.inspector = get_inspector(self.conf, LOG)
+        self.monitor = get_monitor(self.conf,
+                                   self.inspector.get_inspector_url(),
+                                   LOG)
+        self.consumer = get_consumer(self.conf, LOG)
+        self.installer = get_installer(self.conf, LOG)
 
     def setup(self):
         # prepare the cloud env
+        self.installer.setup()
 
         # preparing VM image...
         self.image.create()
@@ -53,6 +63,8 @@ class DoctorTest(object):
 
         # starting doctor sample components...
         self.inspector.start()
+        self.monitor.start()
+        self.consumer.start()
 
     def run(self):
         """run doctor test"""
@@ -62,8 +74,10 @@ class DoctorTest(object):
             self.setup()
 
             # injecting host failure...
+            # NOTE (umar) add INTERFACE_NAME logic to host injection
 
             # verify the test results
+            # NOTE (umar) copy remote monitor.log file when monitor=collectd
 
         except Exception as e:
             LOG.error('doctor test failed, Exception=%s' % e)
@@ -78,11 +92,14 @@ class DoctorTest(object):
         self.image.delete()
         self.user.delete()
         self.inspector.stop()
+        self.monitor.stop()
+        self.consumer.stop()
+        self.installer.cleanup()
 
 
 def main():
     """doctor main"""
-    doctor_root_dir = os.path.dirname(os.getcwd())
+    doctor_root_dir = os.path.dirname(sys.path[0])
     config_file_dir = '{0}/{1}'.format(doctor_root_dir, 'etc/')
     config_files = [join(config_file_dir, f) for f in os.listdir(config_file_dir)
                     if isfile(join(config_file_dir, f))]