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 result_details = {'Details': 'Nothing'}
37 RapidLog.info("+---------------------------------------------------------------------------+")
38 RapidLog.info("| Measuring port statistics on 1 or more PROX instances |")
39 RapidLog.info("+-----------+-----------+------------+------------+------------+------------+")
40 RapidLog.info("| PROX ID | Time | RX | TX | no MBUFS | ierr&imiss |")
41 RapidLog.info("+-----------+-----------+------------+------------+------------+------------+")
42 duration = float(self.test['runtime'])
43 old_rx = []; old_tx = []; old_no_mbufs = []; old_errors = []; old_tsc = []
44 new_rx = []; new_tx = []; new_no_mbufs = []; new_errors = []; new_tsc = []
45 machines_to_go = len (self.machines)
46 for machine in self.machines:
48 old_rx.append(0); old_tx.append(0); old_no_mbufs.append(0); old_errors.append(0); old_tsc.append(0)
49 old_rx[-1], old_tx[-1], old_no_mbufs[-1], old_errors[-1], old_tsc[-1] = machine.multi_port_stats()
50 new_rx.append(0); new_tx.append(0); new_no_mbufs.append(0); new_errors.append(0); new_tsc.append(0)
53 # Get statistics after some execution time
54 for i, machine in enumerate(self.machines, start=0):
55 new_rx[i], new_tx[i], new_no_mbufs[i], new_errors[i], new_tsc[i] = machine.multi_port_stats()
56 rx = new_rx[i] - old_rx[i]
57 tx = new_tx[i] - old_tx[i]
58 no_mbufs = new_no_mbufs[i] - old_no_mbufs[i]
59 errors = new_errors[i] - old_errors[i]
60 tsc = new_tsc[i] - old_tsc[i]
66 old_no_mbufs[i] = new_no_mbufs[i]
67 old_errors[i] = new_errors[i]
68 old_tsc[i] = new_tsc[i]
69 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)+' |')
70 result_details = {'test': self.test['test'],
71 'environment_file': self.test['environment_file'],
78 result_details = self.post_data('rapid_corestatstest', result_details)
79 if machines_to_go == 0:
80 duration = duration - 1
81 machines_to_go = len (self.machines)
82 RapidLog.info("+-----------+-----------+------------+------------+------------+------------+")
83 return (True, result_details)