# under the License.
#
-from chain_managers import StageManager
from collections import OrderedDict
+import time
+
+from chain_managers import StageManager
from log import LOG
from specs import ChainType
-import time
class ServiceChain(object):
for vlan, device in zip(vlans, self.config.generator_config.devices):
self.stats_manager.set_vlan_tag(device, vlan)
- def __get_result_per_frame_size(self, frame_size, bidirectional):
+ def __get_result_per_frame_size(self, frame_size, actual_frame_size, bidirectional):
start_time = time.time()
traffic_result = {
frame_size: {}
}
result = {}
if not self.config.no_traffic:
- self.clients['traffic'].set_traffic(frame_size, bidirectional)
+ self.clients['traffic'].set_traffic(actual_frame_size, bidirectional)
if self.config.single_run:
result = self.stats_manager.run()
for dr in ['pdr', 'ndr']:
if dr in results:
+ if frame_size != actual_frame_size:
+ results[dr]['l2frame_size'] = frame_size
+ results[dr]['actual_l2frame_size'] = actual_frame_size
traffic_result[frame_size][dr] = results[dr]
if 'warning' in results[dr]['stats'] and results[dr]['stats']['warning']:
traffic_result['warning'] = results[dr]['stats']['warning']
result['run_config'] = self.clients['traffic'].get_run_config(result)
required = result['run_config']['direction-total']['orig']['rate_pps']
actual = result['stats']['total_tx_rate']
+ if frame_size != actual_frame_size:
+ result['actual_l2frame_size'] = actual_frame_size
warning = self.clients['traffic'].compare_tx_rates(required, actual)
if warning is not None:
result['run_config']['warning'] = warning
def __get_chain_result(self):
result = OrderedDict()
- for fs in self.config.frame_sizes:
- result.update(self.__get_result_per_frame_size(fs, self.config.traffic.bidirectional))
+ for fs, actual_fs in zip(self.config.frame_sizes, self.config.actual_frame_sizes):
+ result.update(self.__get_result_per_frame_size(fs,
+ actual_fs,
+ self.config.traffic.bidirectional))
chain_result = {
'flow_count': self.config.flow_count,
self.clients['traffic'].ensure_end_to_end()
def run(self):
- LOG.info('Starting {} chain...'.format(self.chain_name))
- LOG.info('Dry run: {}'.format(self.config.no_traffic))
+ LOG.info('Starting %s chain...', self.chain_name)
+ LOG.info('Dry run: %s', self.config.no_traffic)
results = {}
self.__set_helpers()
results[self.chain_name]['mode'] = 'inter-node' \
if self.config.inter_node else 'intra-node'
- LOG.info("Service chain '{}' run completed.".format(self.chain_name))
+ LOG.info("Service chain '%s' run completed.", self.chain_name)
return results
def get_version(self):
return self.stats_manager.get_version()
def close(self):
- self.stage_manager.close()
- self.stats_manager.close()
+ if self.stage_manager:
+ self.stage_manager.close()
+ if self.stats_manager:
+ self.stats_manager.close()