4 ## Copyright (c) 2010-2020 Intel Corporation
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
10 ## http://www.apache.org/licenses/LICENSE-2.0
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.
18 from __future__ import print_function
19 from __future__ import print_function
20 from __future__ import division
22 from future import standard_library
23 standard_library.install_aliases()
24 from builtins import object
26 from rapid_cli import RapidCli
27 from rapid_log import RapidLog
28 from rapid_parser import RapidConfigParser
29 from rapid_defaults import RapidDefaults
30 from rapid_machine import RapidMachine
31 from rapid_generator_machine import RapidGeneratorMachine
32 from rapid_flowsizetest import FlowSizeTest
33 from rapid_corestatstest import CoreStatsTest
34 from rapid_portstatstest import PortStatsTest
35 from rapid_impairtest import ImpairTest
36 from rapid_irqtest import IrqTest
37 from rapid_warmuptest import WarmupTest
39 class RapidTestManager(object):
41 RapidTestManager Class
45 return (RapidDefaults.test_params)
48 def run_tests(test_params):
49 test_params = RapidConfigParser.parse_config(test_params)
50 RapidLog.debug(test_params)
51 monitor_gen = monitor_sut = False
52 background_machines = []
53 sut_machine = gen_machine = None
55 for machine_params in test_params['machines']:
56 if 'gencores' in machine_params.keys():
57 machine = RapidGeneratorMachine(test_params['key'],
58 test_params['user'], test_params['vim_type'],
59 test_params['rundir'], machine_params,
61 if machine_params['monitor']:
63 RapidLog.exception("Can only monitor 1 generator")
64 raise Exception("Can only monitor 1 generator")
69 background_machines.append(machine)
71 machine = RapidMachine(test_params['key'], test_params['user'],
72 test_params['vim_type'], test_params['rundir'],
74 if machine_params['monitor']:
76 RapidLog.exception("Can only monitor 1 sut")
77 raise Exception("Can only monitor 1 sut")
81 machines.append(machine)
82 if test_params['configonly']:
84 for machine in machines:
87 for test_param in test_params['tests']:
88 RapidLog.info(test_param['test'])
89 if test_param['test'] in ['flowsizetest', 'TST009test',
90 'fixed_rate', 'increment_till_fail']:
91 test = FlowSizeTest(test_param, test_params['lat_percentile'],
92 test_params['runtime'],
93 test_params['TestName'],
94 test_params['environment_file'], gen_machine,
95 sut_machine, background_machines)
96 elif test_param['test'] in ['corestats']:
97 test = CoreStatsTest(test_param, test_params['runtime'],
98 test_params['TestName'],
99 test_params['environment_file'], machines)
100 elif test_param['test'] in ['portstats']:
101 test = PortStatsTest(test_param, test_params['runtime'],
102 test_params['TestName'],
103 test_params['environment_file'], machines)
104 elif test_param['test'] in ['impairtest']:
105 test = ImpairTest(test_param, test_params['lat_percentile'],
106 test_params['runtime'],
107 test_params['TestName'],
108 test_params['environment_file'], gen_machine,
110 elif test_param['test'] in ['irqtest']:
111 test = IrqTest(test_param, test_params['runtime'],
112 test_params['TestName'],
113 test_params['environment_file'], machines)
114 elif test_param['test'] in ['warmuptest']:
115 test = WarmupTest(test_param, gen_machine)
117 RapidLog.debug('Test name ({}) is not valid:'.format(
119 single_test_result = test.run()
120 if not single_test_result:
127 test_params = RapidTestManager.get_defaults()
128 # When no cli is used, the process_cli can be replaced by code modifying
130 test_params = RapidCli.process_cli(test_params)
131 log_file = 'RUN{}.{}.log'.format(test_params['environment_file'],
132 test_params['test_file'])
133 RapidLog.log_init(log_file, test_params['loglevel'],
134 test_params['screenloglevel'] , test_params['version'] )
135 test_result = RapidTestManager.run_tests(test_params)
136 RapidLog.info('Test result is : {}'.format(test_result))
138 if __name__ == "__main__":