50e0821b5f0aa5a6949ed97b206a68e071ed6969
[doctor.git] / tests / main.py
1 ##############################################################################
2 # Copyright (c) 2017 ZTE Corporation and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import sys
10
11 import config
12 from image import Image
13 import logger as doctor_log
14
15
16 LOG = doctor_log.Logger('doctor').getLogger()
17
18
19 class DoctorTest(object):
20
21     def __init__(self, conf):
22         self.conf = conf
23         self.image = Image(self.conf)
24
25     def run(self):
26         """run doctor test"""
27         try:
28             LOG.info('doctor test starting.......')
29             # prepare the cloud env
30
31             # preparing VM image...
32             self.image.create()
33
34             # creating test user...
35
36             # creating VM...
37
38             # creating alarm...
39
40             # starting doctor sample components...
41
42             # injecting host failure...
43
44             # verify the test results
45         except Exception as e:
46             LOG.error('doctor test failed, Exception=%s' % e)
47             sys.exit(1)
48         finally:
49             self.image.delete()
50
51
52 def main():
53     """doctor main"""
54     conf = config.prepare_conf()
55
56     doctor = DoctorTest(conf)
57     doctor.run()
58
59
60 if __name__ == '__main__':
61     sys.exit(main())