blob: 2721923eaf95ad88b062f830f4f4a5858cb40b0c [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 Depatie1be639b2018-12-06 10:51:08 -050029import logging
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040030
31DEFAULT_LOG_DIR = '/tmp/voltha_test_results'
Gilles Depatie1be639b2018-12-06 10:51:08 -050032logging.basicConfig(level=logging.INFO)
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040033
Gilles Depatiea85fe812019-01-23 15:55:53 -050034def dir_init(logDir=DEFAULT_LOG_DIR, volthaDir=os.environ['VOLTHA_BASE']):
Gilles Depatie1be639b2018-12-06 10:51:08 -050035 logging.info(__file__)
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040036 """
37 Init automated testing environment and return three directories: root dir,
38 voltha sources dir and log dir
39 """
40
41 rootDir = os.path.abspath(os.path.dirname(__file__))
42
43 currentTime = time.strftime("%Y-%m-%d-%H-%M-%S")
44
45 # In future in order to keep the history of jobs, the run time should be
46 # added to the log directory name
47 # logDir += '_' + currentTime
Gilles Depatiea85fe812019-01-23 15:55:53 -050048
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040049 os.system('mkdir -p ' + logDir + ' > /dev/null 2>&1')
Gilles Depatie84cb1e72018-10-26 12:41:33 -040050 os.system('rm -rf %s/*' % logDir)
Gilles Depatiea85fe812019-01-23 15:55:53 -050051 logging.info('Starting Voltha Test Case Suite at: %s\nRoot Directory: %s\n'
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040052 'VOLTHA Directory: %s\nLog Directory: %s' %
53 (currentTime, rootDir, volthaDir, logDir))
54
55 return rootDir, volthaDir, logDir
56
57
58#
59# MAIN
60#
61if __name__ == "__main__":
62 """
63 Main entry point of the automated testing when executed directly
64 """
65
66 parser = argparse.ArgumentParser(description='VOLTHA Automated Testing')
67 parser.add_argument('-l', dest='logDir', default=DEFAULT_LOG_DIR,
68 help='log directory (default: %s).' % DEFAULT_LOG_DIR)
69 args = parser.parse_args()
70
Gilles Depatiea85fe812019-01-23 15:55:53 -050071 ROOT_DIR, VOLTHA_DIR, LOG_DIR = dir_init(args.logDir)
72
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040073 volthaMngr.voltha_Initialize(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
74
Gilles Depatie9651e462018-11-21 15:58:33 -050075 preprovisioning.runTest('olt.voltha.svc', 50060, 'ponsim_olt', 'ponsim_onu', LOG_DIR)
Gilles Depatie1be639b2018-12-06 10:51:08 -050076
77 discovery.runTest('ponsim_olt', 'ponsim_onu', LOG_DIR)
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040078
Gilles Depatiea85fe812019-01-23 15:55:53 -050079 authentication.runTest(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
80
Gilles Depatiec68b3ad2018-08-21 16:29:03 -040081 time.sleep(5)