def send_traffic(self, traffic): """See ITrafficController for description """ self._logger.debug('send_traffic with ' + str(self._traffic_gen_class)) for packet_size in self._packet_sizes: # Merge framesize with the default traffic definition if 'l2' in traffic: traffic['l2'] = dict(traffic['l2'], **{'framesize': packet_size}) else: traffic['l2'] = {'framesize': packet_size} if traffic['traffic_type'] == 'back2back': self._duration = int(get_test_param('duration', 1)) self._trials = int(get_test_param('rfc2544_trials', 1)) result = self._traffic_gen_class.send_rfc2544_back2back( traffic, trials=self._trials, duration=self._duration) elif traffic['traffic_type'] == 'continuous': result = self._traffic_gen_class.send_cont_traffic( traffic, duration=int(get_test_param('duration', 30))) else: result = self._traffic_gen_class.send_rfc2544_throughput( traffic, trials=self._trials, duration=self._duration) result = TrafficControllerRFC2544._append_results( result, packet_size) self._results.append(result)
def _configure_linux_bridge(self): """ Configure VM to perform L2 forwarding between NICs by linux bridge """ if int(S.getValue('GUEST_NIC_QUEUES')[self._number]): self._set_multi_queue_nic() self._configure_disable_firewall() # configure linux bridge #self.execute('brctl addbr br0') # add all NICs into the bridge for nic in self._nics: self.execute('ip addr add ' + nic['ip'] + ' dev ' + nic['device']) if S.getValue('VSWITCH_JUMBO_FRAMES_ENABLED'): self.execute('ifconfig {} mtu {}'.format( nic['device'], S.getValue('VSWITCH_JUMBO_FRAMES_SIZE'))) self.execute('ip link set dev ' + nic['device'] + ' up') #self.execute('brctl addif br0 ' + nic['device']) #self.execute('ip addr add 192.168.1.2/24 enp0s6') #self.execute('ip addr add 192.168.1.3/24 enp0s7') self.execute('ip link add br0 type bridge') self.execute('ip link set dev enp0s6 master br0') self.execute('ip link set dev enp0s7 master br0') self.execute('ip addr add ' + S.getValue('GUEST_BRIDGE_IP')[self._number] + ' dev br0') self.execute('ip link set dev br0 up') # Add the arp entries for the IXIA ports and the bridge you are using. # Use command line values if provided. trafficgen_mac = get_test_param('vanilla_tgen_port1_mac', S.getValue('VANILLA_TGEN_PORT1_MAC')) trafficgen_ip = get_test_param('vanilla_tgen_port1_ip', S.getValue('VANILLA_TGEN_PORT1_IP')) self.execute('arp -s ' + trafficgen_ip + ' ' + trafficgen_mac) trafficgen_mac = get_test_param('vanilla_tgen_port2_mac', S.getValue('VANILLA_TGEN_PORT2_MAC')) trafficgen_ip = get_test_param('vanilla_tgen_port2_ip', S.getValue('VANILLA_TGEN_PORT2_IP')) self.execute('arp -s ' + trafficgen_ip + ' ' + trafficgen_mac) # Enable forwarding self.execute('sysctl -w net.ipv4.ip_forward=1') self.execute('yum install -y tuna') self.execute_and_wait('tuned-adm profile network-latency') self.execute('tuna -Q') # Controls source route verification # 0 means no source validation self.execute('sysctl -w net.ipv4.conf.all.rp_filter=0') for nic in self._nics: self.execute('sysctl -w net.ipv4.conf.' + nic['device'] + '.rp_filter=0')
def _configure_linux_bridge(self): """ Configure VM to perform L2 forwarding between NICs by linux bridge """ self._configure_disable_firewall() self.execute('ifconfig ' + self._net1 + ' ' + S.getValue('VANILLA_NIC1_IP_CIDR')[self._number]) self.execute('ifconfig ' + self._net2 + ' ' + S.getValue('VANILLA_NIC2_IP_CIDR')[self._number]) # configure linux bridge self.execute('brctl addbr br0') self.execute('brctl addif br0 ' + self._net1 + ' ' + self._net2) self.execute('ifconfig br0 ' + S.getValue('VANILLA_BRIDGE_IP')[self._number]) # Add the arp entries for the IXIA ports and the bridge you are using. # Use command line values if provided. trafficgen_mac = get_test_param('vanilla_tgen_port1_mac', S.getValue('VANILLA_TGEN_PORT1_MAC')) trafficgen_ip = get_test_param('vanilla_tgen_port1_ip', S.getValue('VANILLA_TGEN_PORT1_IP')) self.execute('arp -s ' + trafficgen_ip + ' ' + trafficgen_mac) trafficgen_mac = get_test_param('vanilla_tgen_port2_mac', S.getValue('VANILLA_TGEN_PORT2_MAC')) trafficgen_ip = get_test_param('vanilla_tgen_port2_ip', S.getValue('VANILLA_TGEN_PORT2_IP')) self.execute('arp -s ' + trafficgen_ip + ' ' + trafficgen_mac) # Enable forwarding self.execute('sysctl -w net.ipv4.ip_forward=1') # Controls source route verification # 0 means no source validation self.execute('sysctl -w net.ipv4.conf.all.rp_filter=0') self.execute('sysctl -w net.ipv4.conf.' + self._net1 + '.rp_filter=0') self.execute('sysctl -w net.ipv4.conf.' + self._net2 + '.rp_filter=0')
def __init__(self, traffic_gen_class): """Initialise the trafficgen and store. :param traffic_gen_class: The traffic generator class to be used. """ self._logger = logging.getLogger(__name__) self._logger.debug("__init__") self._traffic_gen_class = traffic_gen_class() self._traffic_started = False self._traffic_started_call_count = 0 self._trials = int(get_test_param('rfc2544_trials', 1)) self._duration = int(get_test_param('duration', 30)) self._results = [] # If set, comma separated packet_sizes value from --test_params # on cli takes precedence over value in settings file. self._packet_sizes = None packet_sizes_cli = get_test_param('pkt_sizes') if packet_sizes_cli: self._packet_sizes = [ int(x.strip()) for x in packet_sizes_cli.split(',') ] else: self._packet_sizes = settings.getValue('TRAFFICGEN_PKT_SIZES')
def __init__(self, traffic_gen_class): """Initialise the trafficgen and store. :param traffic_gen_class: The traffic generator class to be used. """ self._logger = logging.getLogger(__name__) self._logger.debug("__init__") self._traffic_gen_class = traffic_gen_class() self._traffic_started = False self._traffic_started_call_count = 0 self._trials = int(get_test_param('rfc2544_trials', 1)) self._duration = int(get_test_param('duration', 30)) self._lossrate = int(get_test_param('lossrate', 0.002)) self._results = [] # If set, comma separated packet_sizes value from --test_params # on cli takes precedence over value in settings file. self._packet_sizes = None packet_sizes_cli = get_test_param('pkt_sizes') if packet_sizes_cli: self._packet_sizes = [int(x.strip()) for x in packet_sizes_cli.split(',')] else: self._packet_sizes = settings.getValue('TRAFFICGEN_PKT_SIZES')
def __init__(self): """ Initialisation function. """ super(IVnfQemu, self).__init__() self._logger = logging.getLogger(__name__) self._logfile = os.path.join(S.getValue('LOG_DIR'), S.getValue('LOG_FILE_QEMU')) + str( self._number) self._timeout = S.getValue('GUEST_TIMEOUT')[self._number] self._monitor = '%s/vm%dmonitor' % ('/tmp', self._number) self._net1 = get_test_param('guest_nic1_name', None) if self._net1 == None: self._net1 = S.getValue('GUEST_NIC1_NAME')[self._number] else: self._net1 = self._net1.split(',')[self._number] self._net2 = get_test_param('guest_nic2_name', None) if self._net2 == None: self._net2 = S.getValue('GUEST_NIC2_NAME')[self._number] else: self._net2 = self._net2.split(',')[self._number] name = 'Client%d' % self._number vnc = ':%d' % self._number # don't use taskset to affinize main qemu process; It causes hangup # of 2nd VM in case of DPDK. It also slows down VM responsivnes. self._cmd = [ 'sudo', '-E', S.getValue('QEMU_BIN'), '-m', S.getValue('GUEST_MEMORY')[self._number], '-smp', str(S.getValue('GUEST_SMP')[self._number]), '-cpu', 'host', '-drive', 'if=scsi,file=' + S.getValue('GUEST_IMAGE')[self._number], '-boot', 'c', '--enable-kvm', '-monitor', 'unix:%s,server,nowait' % self._monitor, '-object', 'memory-backend-file,id=mem,size=' + str(S.getValue('GUEST_MEMORY')[self._number]) + 'M,' + 'mem-path=' + S.getValue('HUGEPAGE_DIR') + ',share=on', '-numa', 'node,memdev=mem -mem-prealloc', '-nographic', '-vnc', str(vnc), '-name', name, '-snapshot', '-net none', '-no-reboot', '-drive', 'if=scsi,file=fat:rw:%s,snapshot=off' % S.getValue('GUEST_SHARE_DIR')[self._number], ] self._configure_logging()
def __init__(self, test_cfg): """Pull out fields from test config :param test_cfg: A dictionary of string-value pairs describing the test configuration. Both the key and values strings use well-known values. :param results_dir: Where the csv formatted results are written. """ # make a local copy of test configuration to avoid modification of # original content used in vsperf main script cfg = copy.deepcopy(test_cfg) self._testcase_start_time = time.time() self._hugepages_mounted = False self._traffic_ctl = None self._vnf_ctl = None self._vswitch_ctl = None self._collector = None self._loadgen = None self._output_file = None self._tc_results = None self._settings_original = {} self._settings_paths_modified = False self._testcast_run_time = None self._versions = [] # initialization of step driven specific members self._step_check = False # by default don't check result for step driven testcases self._step_vnf_list = {} self._step_result = [] self._step_status = None self._testcase_run_time = None # store all GUEST_ specific settings to keep original values before their expansion for key in S.__dict__: if key.startswith('GUEST_'): self._settings_original[key] = S.getValue(key) self._update_settings('VSWITCH', cfg.get('vSwitch', S.getValue('VSWITCH'))) self._update_settings('VNF', cfg.get('VNF', S.getValue('VNF'))) self._update_settings('TRAFFICGEN', cfg.get('Trafficgen', S.getValue('TRAFFICGEN'))) test_params = copy.deepcopy(S.getValue('TEST_PARAMS')) tc_test_params = cfg.get('Parameters', S.getValue('TEST_PARAMS')) test_params = merge_spec(test_params, tc_test_params) self._update_settings('TEST_PARAMS', test_params) S.check_test_params() # override all redefined GUEST_ values to have them expanded correctly tmp_test_params = copy.deepcopy(S.getValue('TEST_PARAMS')) for key in tmp_test_params: if key.startswith('GUEST_'): S.setValue(key, S.getValue(key)) S.getValue('TEST_PARAMS').pop(key) # update global settings functions.settings_update_paths() # set test parameters; CLI options take precedence to testcase settings self._logger = logging.getLogger(__name__) self.name = cfg['Name'] self.desc = cfg.get('Description', 'No description given.') self.test = cfg.get('TestSteps', None) bidirectional = S.getValue('TRAFFIC')['bidir'] if not isinstance(S.getValue('TRAFFIC')['bidir'], str): raise TypeError('Bi-dir value must be of type string') bidirectional = bidirectional.title() # Keep things consistent self.deployment = cfg['Deployment'] self._frame_mod = cfg.get('Frame Modification', None) self._tunnel_type = None self._tunnel_operation = None if self.deployment == 'op2p': self._tunnel_operation = cfg['Tunnel Operation'] if 'Tunnel Type' in cfg: self._tunnel_type = cfg['Tunnel Type'] self._tunnel_type = get_test_param('TUNNEL_TYPE', self._tunnel_type) # check if test requires background load and which generator it uses self._load_cfg = cfg.get('Load', None) if self._load_cfg and 'tool' in self._load_cfg: self._loadgen = self._load_cfg['tool'] else: # background load is not requested, so use dummy implementation self._loadgen = "Dummy" if self._frame_mod: self._frame_mod = self._frame_mod.lower() self._results_dir = S.getValue('RESULTS_PATH') # set traffic details, so they can be passed to vswitch and traffic ctls self._traffic = copy.deepcopy(S.getValue('TRAFFIC')) self._traffic.update({ 'bidir': bidirectional, 'tunnel_type': self._tunnel_type, }) self._traffic = functions.check_traffic(self._traffic) # Packet Forwarding mode self._vswitch_none = str( S.getValue('VSWITCH')).strip().lower() == 'none' # trafficgen configuration required for tests of tunneling protocols if self.deployment == "op2p": self._traffic['l2'].update({ 'srcmac': S.getValue('TRAFFICGEN_PORT1_MAC'), 'dstmac': S.getValue('TRAFFICGEN_PORT2_MAC') }) self._traffic['l3'].update({ 'srcip': S.getValue('TRAFFICGEN_PORT1_IP'), 'dstip': S.getValue('TRAFFICGEN_PORT2_IP') }) if self._tunnel_operation == "decapsulation": self._traffic['l2'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L2') self._traffic['l3'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L3') self._traffic['l4'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L4') elif len(S.getValue('NICS')) and \ (S.getValue('NICS')[0]['type'] == 'vf' or S.getValue('NICS')[1]['type'] == 'vf'): mac1 = S.getValue('NICS')[0]['mac'] mac2 = S.getValue('NICS')[1]['mac'] if mac1 and mac2: self._traffic['l2'].update({'srcmac': mac2, 'dstmac': mac1}) else: self._logger.debug("MAC addresses can not be read") # count how many VNFs are involved in TestSteps if self.test: for step in self.test: if step[0].startswith('vnf'): self._step_vnf_list[step[0]] = None
def __init__(self, cfg, results_dir): """Pull out fields from test config :param cfg: A dictionary of string-value pairs describing the test configuration. Both the key and values strings use well-known values. :param results_dir: Where the csv formatted results are written. """ self._logger = logging.getLogger(__name__) self.name = cfg['Name'] self.desc = cfg.get('Description', 'No description given.') self.deployment = cfg['Deployment'] self._frame_mod = cfg.get('Frame Modification', None) framerate = get_test_param('iload', None) if framerate == None: framerate = cfg.get('iLoad', 100) # identify guest loopback method, so it can be added into reports self.guest_loopback = [] if self.deployment in ['pvp', 'pvvp']: guest_loopback = get_test_param('guest_loopback', None) if guest_loopback: self.guest_loopback.append(guest_loopback) else: if self.deployment == 'pvp': self.guest_loopback.append(S.getValue('GUEST_LOOPBACK')[0]) else: self.guest_loopback = S.getValue('GUEST_LOOPBACK').copy() # read configuration of streams; CLI parameter takes precedence to # testcase definition multistream = cfg.get('MultiStream', 0) multistream = get_test_param('multistream', multistream) stream_type = cfg.get('Stream Type', 'L4') stream_type = get_test_param('stream_type', stream_type) pre_installed_flows = False # placeholder for VSPERF-83 implementation # check if test requires background load and which generator it uses self._load_cfg = cfg.get('Load', None) if self._load_cfg and 'tool' in self._load_cfg: self._loadgen = self._load_cfg['tool'] else: # background load is not requested, so use dummy implementation self._loadgen = "Dummy" if self._frame_mod: self._frame_mod = self._frame_mod.lower() self._results_dir = results_dir # set traffic details, so they can be passed to vswitch and traffic ctls self._traffic = copy.deepcopy(TRAFFIC_DEFAULTS) self._traffic.update({ 'traffic_type': cfg['Traffic Type'], 'flow_type': cfg.get('Flow Type', 'port'), 'bidir': cfg['biDirectional'], 'multistream': int(multistream), 'stream_type': stream_type, 'pre_installed_flows': pre_installed_flows, 'frame_rate': int(framerate) }) # OVS Vanilla requires guest VM MAC address and IPs to work if 'linux_bridge' in self.guest_loopback: self._traffic['l2'].update({ 'srcmac': S.getValue('GUEST_NET2_MAC')[0], 'dstmac': S.getValue('GUEST_NET1_MAC')[0] }) self._traffic['l3'].update({ 'srcip': S.getValue('VANILLA_TGEN_PORT1_IP'), 'dstip': S.getValue('VANILLA_TGEN_PORT2_IP') })