summaryrefslogtreecommitdiffstats
path: root/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py')
-rw-r--r--testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py168
1 files changed, 125 insertions, 43 deletions
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py
index a29794f4..38bfa70e 100644
--- a/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py
+++ b/testsuites/vstf/vstf_scripts/vstf/controller/spirent/common/model.py
@@ -24,6 +24,7 @@ reverse_dict = {
class BaseModel(object):
+
def __init__(self, config):
self.config = config
@@ -117,6 +118,7 @@ def _tranfer_array_to_range(array):
class TnV(BaseModel):
+
def __init__(self, config):
super(TnV, self).__init__(config)
self.config = config
@@ -178,7 +180,8 @@ class TnV(BaseModel):
info = self.handle.get(option, 'macs')
macs = info.split()
if len(macs) != int(self.config['virtenv']) or macs == []:
- print("[ERROR]The macs number is not equal to vms or containers.")
+ print(
+ "[ERROR]The macs number is not equal to vms or containers.")
return False
for mac in macs:
# check mac valid
@@ -211,12 +214,12 @@ class TnV(BaseModel):
@property
def check_logic_invalid(self):
return self.flow_match() and self.match_virt_env() and \
- self.match_flows_and_nic and self.check_mac_valid() and \
- self.check_vlan_valid()
+ self.match_flows_and_nic and self.check_mac_valid() and \
+ self.check_vlan_valid()
@property
def read_flow_init(self):
- # The
+ # The
temp_flow = {}
src_macs = self._get_range('send', 'macs')
dst_macs = self._get_range('recv', 'macs')
@@ -233,7 +236,7 @@ class TnV(BaseModel):
temp_flow['tester_ip'] = self._get_nic_from_file('common', 'tester_ip')
vlan = src_vlan
avg_flow = int(self.config['flows']) / int(self.config['virtenv'])
- # build the main dictionary
+ # build the main dictionary
for _direct in sorted(fwd[self.config['direct']]):
i = 0
j = 0
@@ -267,9 +270,11 @@ class TnV(BaseModel):
temp_flow['qemu_thread_list'] = _vm_info['qemu_thread']
forward_core = {
- "forward": _vm_info['qemu_thread'][_queue + avg_flow * vm_index],
- "reverse": _vm_info['qemu_thread'][_queue + avg_flow * vm_index + int(self.config['flows'])]
- }
+ "forward": _vm_info['qemu_thread'][
+ _queue + avg_flow * vm_index],
+ "reverse": _vm_info['qemu_thread'][
+ _queue + avg_flow * vm_index + int(
+ self.config['flows'])]}
temp_flow['fwd_thread'] = forward_core[_direct]
temp_flow['fwd_vhost'] = None
@@ -280,7 +285,8 @@ class TnV(BaseModel):
temp_flow['dst_nic'] = dst_nic
# above all
j += 1
- self.init_flows[_direct + '_' + _vm + '_' + str(_queue)] = copy.deepcopy(temp_flow)
+ self.init_flows[_direct + '_' + _vm + '_' +
+ str(_queue)] = copy.deepcopy(temp_flow)
i += 1
src_nic_irq, dst_nic_irq = dst_nic_irq, src_nic_irq
vlan = dst_vlan
@@ -323,30 +329,67 @@ class TnV(BaseModel):
try:
i += 1
thread_info = None
- self.mac_learning(self.init_flows[_direct + '_' + _vm + '_' + str(_queue)],
- self.init_flows[reverse_dict[_direct] + '_' + _vm + '_' + str(_queue)])
- streamblock = self.send_packet(self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
+ self.mac_learning(
+ self.init_flows[
+ _direct +
+ '_' +
+ _vm +
+ '_' +
+ str(_queue)],
+ self.init_flows[
+ reverse_dict[_direct] +
+ '_' +
+ _vm +
+ '_' +
+ str(_queue)])
+ streamblock = self.send_packet(
+ self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
time.sleep(1)
result, thread_info = self.catch_thread_info()
thread_info = eval(thread_info)
- self.stop_flow(streamblock, self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
+ self.stop_flow(
+ streamblock, self.init_flows[
+ _direct + '_' + _vm + '_' + str(_queue)])
time.sleep(1)
if not result:
print("[ERROR]Catch the thread info failed.")
break
except:
- print("[ERROR]send flow failed error or get host thread info failed.")
+ print(
+ "[ERROR]send flow failed error or get host thread info failed.")
# compare the got thread info to
- if check_dict(thread_info, self.init_flows[_direct + '_' + _vm + '_' + str(_queue)]):
- self.set_thread2flow(thread_info, self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
- print("[INFO]Flow %s_%s_%s : fwd_vhost %s src_recv_irq %s dst_send_irq %s"
- % (_direct, _vm, _queue, thread_info['fwd_vhost'], thread_info['src_recv_irq'],
- thread_info['dst_send_irq']))
- print("%s" % (self.init_flows[_direct + '_' + _vm + '_' + str(_queue)]))
+ if check_dict(
+ thread_info, self.init_flows[
+ _direct + '_' + _vm + '_' + str(_queue)]):
+ self.set_thread2flow(
+ thread_info, self.init_flows[
+ _direct + '_' + _vm + '_' + str(_queue)])
+ print(
+ "[INFO]Flow %s_%s_%s : fwd_vhost %s src_recv_irq %s dst_send_irq %s" %
+ (_direct,
+ _vm,
+ _queue,
+ thread_info['fwd_vhost'],
+ thread_info['src_recv_irq'],
+ thread_info['dst_send_irq']))
+ print(
+ "%s" %
+ (self.init_flows[
+ _direct +
+ '_' +
+ _vm +
+ '_' +
+ str(_queue)]))
break
else:
- dst_ip_update(self.init_flows[_direct + '_' + _vm + '_' + str(_queue)])
+ dst_ip_update(
+ self.init_flows[
+ _direct +
+ '_' +
+ _vm +
+ '_' +
+ str(_queue)])
return self.init_flows
def affinity_bind(self, aff_strategy):
@@ -361,7 +404,8 @@ class TnV(BaseModel):
# recognize the thread id
for flowname in sorted(self.init_flows.keys()):
tmp_thread = self.init_flows[flowname]['fwd_thread']
- qemu_other = qemu_other + copy.deepcopy(self.init_flows[flowname]['qemu_thread_list'])
+ qemu_other = qemu_other + \
+ copy.deepcopy(self.init_flows[flowname]['qemu_thread_list'])
qemu_list.append(tmp_thread)
if self.init_flows[flowname]['direct'] == 'forward':
dst_vhost.append(self.init_flows[flowname]['fwd_vhost'])
@@ -386,16 +430,38 @@ class TnV(BaseModel):
handle = ConfigParser.ConfigParser()
handle.read(self.config['strategyfile'])
try:
- qemu_numa = handle.get('strategy' + self.config['strategy'], 'qemu_numa')
- src_vhost_numa = handle.get('strategy' + self.config['strategy'], 'src_vhost_numa')
- dst_vhost_numa = handle.get('strategy' + self.config['strategy'], 'dst_vhost_numa')
- src_irq_numa = handle.get('strategy' + self.config['strategy'], 'src_irq_numa')
- dst_irq_numa = handle.get('strategy' + self.config['strategy'], 'dst_irq_numa')
- loan_numa = handle.get('strategy' + self.config['strategy'], 'loan_numa')
+ qemu_numa = handle.get(
+ 'strategy' +
+ self.config['strategy'],
+ 'qemu_numa')
+ src_vhost_numa = handle.get(
+ 'strategy' + self.config['strategy'],
+ 'src_vhost_numa')
+ dst_vhost_numa = handle.get(
+ 'strategy' + self.config['strategy'],
+ 'dst_vhost_numa')
+ src_irq_numa = handle.get(
+ 'strategy' +
+ self.config['strategy'],
+ 'src_irq_numa')
+ dst_irq_numa = handle.get(
+ 'strategy' +
+ self.config['strategy'],
+ 'dst_irq_numa')
+ loan_numa = handle.get(
+ 'strategy' +
+ self.config['strategy'],
+ 'loan_numa')
except:
print("[ERROR]Parse the strategy file failed or get the options failed.")
- for value in [qemu_numa, src_vhost_numa, dst_vhost_numa, src_irq_numa, dst_irq_numa, loan_numa]:
+ for value in [
+ qemu_numa,
+ src_vhost_numa,
+ dst_vhost_numa,
+ src_irq_numa,
+ dst_irq_numa,
+ loan_numa]:
if value is not None or value == '':
raise ValueError('some option in the strategy file is none.')
# cores mapping thread
@@ -407,26 +473,39 @@ class TnV(BaseModel):
for node in numa_topo.keys():
numa_topo[node]['process'] = []
if 'node' + src_irq_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + src_irq
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + src_irq
if 'node' + dst_irq_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + dst_irq
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + dst_irq
if 'node' + src_vhost_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + src_vhost
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + src_vhost
if 'node' + dst_vhost_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + dst_vhost
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + dst_vhost
if 'node' + qemu_numa == node:
- numa_topo[node]['process'] = numa_topo[node]['process'] + qemu_list
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'] + qemu_list
loan_cores = ''
for node in numa_topo.keys():
- if len(numa_topo[node]['process']) > len(numa_topo[node]['phy_cores']):
+ if len(
+ numa_topo[node]['process']) > len(
+ numa_topo[node]['phy_cores']):
# length distance
- diff = len(numa_topo[node]['process']) - len(numa_topo[node]['phy_cores'])
+ diff = len(numa_topo[node]['process']) - \
+ len(numa_topo[node]['phy_cores'])
# first deep copy
- numa_topo['node' + loan_numa]['process'] = numa_topo['node' + loan_numa]['process'] + copy.deepcopy(
- numa_topo[node]['process'][-diff:])
- cores_str = _tranfer_array_to_range(numa_topo['node' + loan_numa]['phy_cores'][diff:])
+ numa_topo['node' + loan_numa]['process'] = numa_topo['node' + loan_numa][
+ 'process'] + copy.deepcopy(numa_topo[node]['process'][-diff:])
+ cores_str = _tranfer_array_to_range(
+ numa_topo[
+ 'node' +
+ loan_numa]['phy_cores'][
+ diff:])
loan_cores = ','.join([loan_cores, cores_str])
- numa_topo[node]['process'] = numa_topo[node]['process'][0:-diff]
+ numa_topo[node]['process'] = numa_topo[
+ node]['process'][0:-diff]
loan_cores = loan_cores[1:]
loan_bind_list = {}
for proc_loan in qemu_other:
@@ -435,7 +514,8 @@ class TnV(BaseModel):
bind_list = {}
for node in numa_topo.keys():
for i in range(len(numa_topo[node]['process'])):
- bind_list[numa_topo[node]['process'][i]] = str(numa_topo[node]['phy_cores'][i])
+ bind_list[numa_topo[node]['process'][i]] = str(
+ numa_topo[node]['phy_cores'][i])
bind_list.update(loan_bind_list)
for key in bind_list.keys():
self.host_instance.bind_cpu(bind_list[key], key)
@@ -459,8 +539,10 @@ class TnV(BaseModel):
if suite == "throughput":
print("[INFO]!!!!!!!!!!!!!!!Now begin to throughput test")
- ret, result = self.send_instace.run_rfc2544_throughput(forward_init_flows, reverse_init_flows)
+ ret, result = self.send_instace.run_rfc2544_throughput(
+ forward_init_flows, reverse_init_flows)
elif suite == "frameloss":
print("[INFO]!!!!!!!!!!!1!!!Now begin to frameloss test")
- ret, result = self.send_instace.run_rfc2544_frameloss(forward_init_flows, reverse_init_flows)
+ ret, result = self.send_instace.run_rfc2544_frameloss(
+ forward_init_flows, reverse_init_flows)
return ret, result