add test user, project and role
[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 from user import User
15
16
17 LOG = doctor_log.Logger('doctor').getLogger()
18
19
20 class DoctorTest(object):
21
22     def __init__(self, conf):
23         self.conf = conf
24         self.image = Image(self.conf, LOG)
25         self.user = User(self.conf, LOG)
26
27     def setup(self):
28         # prepare the cloud env
29
30         # preparing VM image...
31         self.image.create()
32
33         # creating test user...
34         self.user.create()
35         self.user.update_quota()
36
37     def run(self):
38         """run doctor test"""
39         try:
40             LOG.info('doctor test starting.......')
41
42             self.setup()
43
44             # injecting host failure...
45
46             # verify the test results
47
48         except Exception as e:
49             LOG.error('doctor test failed, Exception=%s' % e)
50             sys.exit(1)
51         finally:
52             self.cleanup()
53
54     def cleanup(self):
55         self.image.delete()
56         self.user.delete()
57
58
59 def main():
60     """doctor main"""
61     conf = config.prepare_conf()
62
63     doctor = DoctorTest(conf)
64     doctor.run()
65
66
67 if __name__ == '__main__':
68     sys.exit(main())