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 | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 27 | |
| 28 | DEFAULT_LOG_DIR = '/tmp/voltha_test_results' |
| 29 | |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 30 | def dirInit(logDir=DEFAULT_LOG_DIR, |
| 31 | volthaDir=os.environ['VOLTHA_BASE']): |
| 32 | print(__file__) |
| 33 | """ |
| 34 | Init automated testing environment and return three directories: root dir, |
| 35 | voltha sources dir and log dir |
| 36 | """ |
| 37 | |
| 38 | rootDir = os.path.abspath(os.path.dirname(__file__)) |
| 39 | |
| 40 | currentTime = time.strftime("%Y-%m-%d-%H-%M-%S") |
| 41 | |
| 42 | # In future in order to keep the history of jobs, the run time should be |
| 43 | # added to the log directory name |
| 44 | # logDir += '_' + currentTime |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 45 | |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 46 | os.system('mkdir -p ' + logDir + ' > /dev/null 2>&1') |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 47 | os.system('rm -rf %s/*' % logDir) |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 48 | print('Start Provisioning Test at: %s\nRoot Directory: %s\n' |
| 49 | 'VOLTHA Directory: %s\nLog Directory: %s' % |
| 50 | (currentTime, rootDir, volthaDir, logDir)) |
| 51 | |
| 52 | return rootDir, volthaDir, logDir |
| 53 | |
| 54 | |
| 55 | # |
| 56 | # MAIN |
| 57 | # |
| 58 | if __name__ == "__main__": |
| 59 | """ |
| 60 | Main entry point of the automated testing when executed directly |
| 61 | """ |
| 62 | |
| 63 | parser = argparse.ArgumentParser(description='VOLTHA Automated Testing') |
| 64 | parser.add_argument('-l', dest='logDir', default=DEFAULT_LOG_DIR, |
| 65 | help='log directory (default: %s).' % DEFAULT_LOG_DIR) |
| 66 | args = parser.parse_args() |
| 67 | |
| 68 | ROOT_DIR, VOLTHA_DIR, LOG_DIR = dirInit(args.logDir) |
| 69 | |
| 70 | volthaMngr.voltha_Initialize(ROOT_DIR, VOLTHA_DIR, LOG_DIR) |
| 71 | |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 72 | preprovisioning.runTest('olt.voltha.svc', 50060, LOG_DIR) |
Gilles Depatie | c68b3ad | 2018-08-21 16:29:03 -0400 | [diff] [blame] | 73 | |
| 74 | time.sleep(5) |