Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 1 | #!/usr/bin/python2 |
| 2 | |
| 3 | # |
| 4 | # Copyright 2018 the original author or authors. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | |
| 19 | """ |
| 20 | vOLT-HA Automated Testing module |
| 21 | """ |
| 22 | import os |
| 23 | import time |
| 24 | import argparse |
| 25 | import volthaMngr |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 26 | import preprovisioning |
Gilles Depatie | 1be639b | 2018-12-06 10:51:08 -0500 | [diff] [blame] | 27 | import discovery |
Gilles Depatie | a85fe81 | 2019-01-23 15:55:53 -0500 | [diff] [blame] | 28 | import authentication |
Gilles Depatie | 1be639b | 2018-12-06 10:51:08 -0500 | [diff] [blame] | 29 | import logging |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 30 | |
| 31 | DEFAULT_LOG_DIR = '/tmp/voltha_test_results' |
Gilles Depatie | 1be639b | 2018-12-06 10:51:08 -0500 | [diff] [blame] | 32 | logging.basicConfig(level=logging.INFO) |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 33 | |
Gilles Depatie | 0bf3135 | 2019-02-04 13:48:41 -0500 | [diff] [blame] | 34 | |
| 35 | def dir_init(log_dir=DEFAULT_LOG_DIR, voltha_dir=os.environ['VOLTHA_BASE']): |
Gilles Depatie | 1be639b | 2018-12-06 10:51:08 -0500 | [diff] [blame] | 36 | logging.info(__file__) |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 37 | """ |
| 38 | Init automated testing environment and return three directories: root dir, |
| 39 | voltha sources dir and log dir |
| 40 | """ |
| 41 | |
Gilles Depatie | 0bf3135 | 2019-02-04 13:48:41 -0500 | [diff] [blame] | 42 | root_dir = os.path.abspath(os.path.dirname(__file__)) |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 43 | |
| 44 | currentTime = time.strftime("%Y-%m-%d-%H-%M-%S") |
| 45 | |
| 46 | # In future in order to keep the history of jobs, the run time should be |
| 47 | # added to the log directory name |
| 48 | # logDir += '_' + currentTime |
Gilles Depatie | a85fe81 | 2019-01-23 15:55:53 -0500 | [diff] [blame] | 49 | |
Gilles Depatie | 0bf3135 | 2019-02-04 13:48:41 -0500 | [diff] [blame] | 50 | os.system('mkdir -p ' + log_dir + ' > /dev/null 2>&1') |
| 51 | os.system('rm -rf %s/*' % log_dir) |
Gilles Depatie | a85fe81 | 2019-01-23 15:55:53 -0500 | [diff] [blame] | 52 | logging.info('Starting Voltha Test Case Suite at: %s\nRoot Directory: %s\n' |
Gilles Depatie | 0bf3135 | 2019-02-04 13:48:41 -0500 | [diff] [blame] | 53 | 'VOLTHA Directory: %s\nLog Directory: %s' % |
| 54 | (currentTime, root_dir, voltha_dir, log_dir)) |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 55 | |
Gilles Depatie | 0bf3135 | 2019-02-04 13:48:41 -0500 | [diff] [blame] | 56 | return root_dir, voltha_dir, log_dir |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 57 | |
| 58 | |
| 59 | # |
| 60 | # MAIN |
| 61 | # |
| 62 | if __name__ == "__main__": |
| 63 | """ |
| 64 | Main entry point of the automated testing when executed directly |
| 65 | """ |
| 66 | |
| 67 | parser = argparse.ArgumentParser(description='VOLTHA Automated Testing') |
| 68 | parser.add_argument('-l', dest='logDir', default=DEFAULT_LOG_DIR, |
| 69 | help='log directory (default: %s).' % DEFAULT_LOG_DIR) |
| 70 | args = parser.parse_args() |
| 71 | |
Gilles Depatie | a85fe81 | 2019-01-23 15:55:53 -0500 | [diff] [blame] | 72 | ROOT_DIR, VOLTHA_DIR, LOG_DIR = dir_init(args.logDir) |
| 73 | |
Gilles Depatie | 0bf3135 | 2019-02-04 13:48:41 -0500 | [diff] [blame] | 74 | volthaMngr.voltha_initialize(ROOT_DIR, VOLTHA_DIR, LOG_DIR) |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 75 | |
Gilles Depatie | 0bf3135 | 2019-02-04 13:48:41 -0500 | [diff] [blame] | 76 | preprovisioning.run_test('olt.voltha.svc', 50060, 'ponsim_olt', 'ponsim_onu', LOG_DIR) |
Gilles Depatie | 1be639b | 2018-12-06 10:51:08 -0500 | [diff] [blame] | 77 | |
Gilles Depatie | 0bf3135 | 2019-02-04 13:48:41 -0500 | [diff] [blame] | 78 | discovery.run_test('olt.voltha.svc', 'ponsim_olt', 'ponsim_onu', LOG_DIR) |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 79 | |
Gilles Depatie | 0bf3135 | 2019-02-04 13:48:41 -0500 | [diff] [blame] | 80 | authentication.run_test(ROOT_DIR, VOLTHA_DIR, LOG_DIR) |
Gilles Depatie | a85fe81 | 2019-01-23 15:55:53 -0500 | [diff] [blame] | 81 | |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 82 | time.sleep(5) |