blob: d93e7b5e8be8c7685a4f4e3da29f86a3a22754da [file] [log] [blame]
Gilles Depatiec68b3ad2018-08-21 16:29:03 -04001#!/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"""
20vOLT-HA Automated Testing module
21"""
22import os
23import time
24import argparse
25import volthaMngr
Gilles Depatie84cb1e72018-10-26 12:41:33 -040026import preprovisioning
Gilles Depatie1be639b2018-12-06 10:51:08 -050027import discovery
Gilles Depatiea85fe812019-01-23 15:55:53 -050028import authentication
Gilles Depatie2e683692019-02-22 16:06:52 -050029import dhcp
Gilles Depatieed99efe2019-03-12 16:12:26 -040030import unicast
Gilles Depatie1be639b2018-12-06 10:51:08 -050031import logging
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040032
33DEFAULT_LOG_DIR = '/tmp/voltha_test_results'
Gilles Depatie1be639b2018-12-06 10:51:08 -050034logging.basicConfig(level=logging.INFO)
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040035
Gilles Depatie0bf31352019-02-04 13:48:41 -050036
37def dir_init(log_dir=DEFAULT_LOG_DIR, voltha_dir=os.environ['VOLTHA_BASE']):
Gilles Depatie1be639b2018-12-06 10:51:08 -050038 logging.info(__file__)
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040039 """
40 Init automated testing environment and return three directories: root dir,
41 voltha sources dir and log dir
42 """
43
Gilles Depatie0bf31352019-02-04 13:48:41 -050044 root_dir = os.path.abspath(os.path.dirname(__file__))
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040045
46 currentTime = time.strftime("%Y-%m-%d-%H-%M-%S")
47
48 # In future in order to keep the history of jobs, the run time should be
49 # added to the log directory name
50 # logDir += '_' + currentTime
Gilles Depatiea85fe812019-01-23 15:55:53 -050051
Gilles Depatie0bf31352019-02-04 13:48:41 -050052 os.system('mkdir -p ' + log_dir + ' > /dev/null 2>&1')
53 os.system('rm -rf %s/*' % log_dir)
Gilles Depatiea85fe812019-01-23 15:55:53 -050054 logging.info('Starting Voltha Test Case Suite at: %s\nRoot Directory: %s\n'
Gilles Depatie0bf31352019-02-04 13:48:41 -050055 'VOLTHA Directory: %s\nLog Directory: %s' %
56 (currentTime, root_dir, voltha_dir, log_dir))
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040057
Gilles Depatie0bf31352019-02-04 13:48:41 -050058 return root_dir, voltha_dir, log_dir
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040059
60
61#
62# MAIN
63#
64if __name__ == "__main__":
65 """
66 Main entry point of the automated testing when executed directly
67 """
68
69 parser = argparse.ArgumentParser(description='VOLTHA Automated Testing')
70 parser.add_argument('-l', dest='logDir', default=DEFAULT_LOG_DIR,
71 help='log directory (default: %s).' % DEFAULT_LOG_DIR)
72 args = parser.parse_args()
73
Gilles Depatiea85fe812019-01-23 15:55:53 -050074 ROOT_DIR, VOLTHA_DIR, LOG_DIR = dir_init(args.logDir)
75
Gilles Depatie0bf31352019-02-04 13:48:41 -050076 volthaMngr.voltha_initialize(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040077
Gilles Depatie0bf31352019-02-04 13:48:41 -050078 preprovisioning.run_test('olt.voltha.svc', 50060, 'ponsim_olt', 'ponsim_onu', LOG_DIR)
Gilles Depatie1be639b2018-12-06 10:51:08 -050079
Gilles Depatie0bf31352019-02-04 13:48:41 -050080 discovery.run_test('olt.voltha.svc', 'ponsim_olt', 'ponsim_onu', LOG_DIR)
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040081
Gilles Depatie0bf31352019-02-04 13:48:41 -050082 authentication.run_test(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
Gilles Depatiea85fe812019-01-23 15:55:53 -050083
Gilles Depatie2e683692019-02-22 16:06:52 -050084 dhcp.run_test(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
85
Gilles Depatieed99efe2019-03-12 16:12:26 -040086 unicast.run_test(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
87
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040088 time.sleep(5)