4 ## Copyright (c) 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
11 ## http://www.apache.org/licenses/LICENSE-2.0
13 ## Unless required by applicable law or agreed to in writing, software
14 ## distributed under the License is distributed on an "AS IS" BASIS,
15 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 ## See the License for the specific language governing permissions and
17 ## limitations under the License.
23 from rapid_log import RapidLog
24 from rapid_test import RapidTest
26 class PortStatsTest(RapidTest):
28 Class to manage the portstatstesting
30 def __init__(self, test_param, runtime, testname, environment_file,
32 super().__init__(test_param, runtime, testname, environment_file)
33 self.machines = machines
36 RapidLog.info("+---------------------------------------------------------------------------+")
37 RapidLog.info("| Measuring port statistics on 1 or more PROX instances |")
38 RapidLog.info("+-----------+-----------+------------+------------+------------+------------+")
39 RapidLog.info("| PROX ID | Time | RX | TX | no MBUFS | ierr&imiss |")
40 RapidLog.info("+-----------+-----------+------------+------------+------------+------------+")
41 duration = float(self.test['runtime'])
42 old_rx = []; old_tx = []; old_no_mbufs = []; old_errors = []; old_tsc = []
43 new_rx = []; new_tx = []; new_no_mbufs = []; new_errors = []; new_tsc = []
44 machines_to_go = len (self.machines)
45 for machine in self.machines:
47 old_rx.append(0); old_tx.append(0); old_no_mbufs.append(0); old_errors.append(0); old_tsc.append(0)
48 old_rx[-1], old_tx[-1], old_no_mbufs[-1], old_errors[-1], old_tsc[-1] = machine.multi_port_stats()
49 new_rx.append(0); new_tx.append(0); new_no_mbufs.append(0); new_errors.append(0); new_tsc.append(0)
52 # Get statistics after some execution time
53 for i, machine in enumerate(self.machines, start=0):
54 new_rx[i], new_tx[i], new_no_mbufs[i], new_errors[i], new_tsc[i] = machine.multi_port_stats()
55 rx = new_rx[i] - old_rx[i]
56 tx = new_tx[i] - old_tx[i]
57 no_mbufs = new_no_mbufs[i] - old_no_mbufs[i]
58 errors = new_errors[i] - old_errors[i]
59 tsc = new_tsc[i] - old_tsc[i]
65 old_no_mbufs[i] = new_no_mbufs[i]
66 old_errors[i] = new_errors[i]
67 old_tsc[i] = new_tsc[i]
68 RapidLog.info('|{:>10.0f}'.format(i)+ ' |{:>10.0f}'.format(duration)+' | ' + '{:>10.0f}'.format(rx) + ' | ' +'{:>10.0f}'.format(tx) + ' | '+'{:>10.0f}'.format(no_mbufs)+' | '+'{:>10.0f}'.format(errors)+' |')
69 variables = {'test': self.test['test'],
70 'environment_file': self.test['environment_file'],
77 self.post_data('rapid_corestatstest', variables)
78 if machines_to_go == 0:
79 duration = duration - 1
80 machines_to_go = len (self.machines)
81 RapidLog.info("+-----------+-----------+------------+------------+------------+------------+")