creation of tests and configs subdirectories
[samplevnf.git] / VNFs / DPPD-PROX / helper-scripts / rapid / rapidxt.py
1 #!/usr/bin/python3
2
3 ##
4 ## Copyright (c) 2020 Intel Corporation
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 # pylint: disable=missing-docstring
20
21 import json
22 import os
23 import sys
24 import time
25
26 from xtesting.core import testcase
27 from runrapid import RapidTestManager
28 from rapid_cli import RapidCli
29 from rapid_log import RapidLog
30
31 class RapidXt(testcase.TestCase):
32
33     def run(self, **kwargs):
34         try:
35             test_params = RapidTestManager.get_defaults()
36             for key in kwargs:
37                 test_params[key] = kwargs[key]
38             os.makedirs(self.res_dir, exist_ok=True)
39             test_params['resultsdir'] = self.res_dir
40             _, test_file_name = os.path.split(test_params['test_file'])
41             _, environment_file_name = os.path.split(
42                     test_params['environment_file'])
43             log_file = '{}/RUN{}.{}.log'.format(self.res_dir,
44                     environment_file_name, test_file)
45             RapidLog.log_init(log_file, test_params['loglevel'],
46                 test_params['screenloglevel'] , test_params['version']  )
47             test_manager = RapidTestManager()
48             self.start_time = time.time()
49             self.result, self.details = test_manager.run_tests(test_params)
50             self.stop_time = time.time()
51             RapidLog.log_close()
52
53         except Exception:  # pylint: disable=broad-except
54             print("Unexpected error:", sys.exc_info()[0])
55             self.result = 0
56             self.stop_time = time.time()