aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/network_services
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/network_services')
-rw-r--r--yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py41
-rw-r--r--yardstick/network_services/traffic_profile/http.py4
-rw-r--r--yardstick/network_services/traffic_profile/http_ixload.py103
-rw-r--r--yardstick/network_services/traffic_profile/ixia_rfc2544.py12
-rw-r--r--yardstick/network_services/vnf_generic/vnf/sample_vnf.py18
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_ixload.py35
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_landslide.py33
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py3
8 files changed, 222 insertions, 27 deletions
diff --git a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
index 8b69a8848..556682b29 100644
--- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
+++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
@@ -41,12 +41,12 @@ C_VLAN = 1
ETHER_TYPE_802_1ad = '0x88a8'
-IP_VERSION_4_MASK = 24
-IP_VERSION_6_MASK = 64
-
TRAFFIC_STATUS_STARTED = 'started'
TRAFFIC_STATUS_STOPPED = 'stopped'
+PROTOCOL_STATUS_UP = 'up'
+PROTOCOL_STATUS_DOWN = ['down', 'notStarted']
+
SUPPORTED_PROTO = [PROTO_UDP]
@@ -180,6 +180,15 @@ class IxNextgen(object): # pragma: no cover
return self.ixnet.getAttribute(self.ixnet.getRoot() + 'traffic',
'-state')
+ def _get_protocol_status(self, proto):
+ """Get protocol status
+
+ :param proto: IxNet protocol str representation, e.g.:
+ '::ixNet::OBJ-/topology:2/deviceGroup:1/ethernet:1/ipv4:L14'
+ :return: (str) protocol status: 'up', 'down' or 'notStarted'
+ """
+ return self.ixnet.getAttribute(proto, '-sessionStatus')[0]
+
def is_traffic_running(self):
"""Returns true if traffic state == TRAFFIC_STATUS_STARTED"""
return self._get_traffic_state() == TRAFFIC_STATUS_STARTED
@@ -188,6 +197,28 @@ class IxNextgen(object): # pragma: no cover
"""Returns true if traffic state == TRAFFIC_STATUS_STOPPED"""
return self._get_traffic_state() == TRAFFIC_STATUS_STOPPED
+ def is_protocols_running(self, protocols):
+ """Returns true if all protocols statuses are PROTOCOL_STATUS_UP
+
+ :param protocols: list of protocols str representations, e.g.:
+ ['::ixNet::OBJ-/topology:2/deviceGroup:1/ethernet:1/ipv4:L14', ...]
+ :return: (bool) True if all protocols status is 'up', False if any
+ protocol status is 'down' or 'notStarted'
+ """
+ return all(self._get_protocol_status(proto) == PROTOCOL_STATUS_UP
+ for proto in protocols)
+
+ def is_protocols_stopped(self, protocols):
+ """Returns true if all protocols statuses are in PROTOCOL_STATUS_DOWN
+
+ :param protocols: list of protocols str representations, e.g.:
+ ['::ixNet::OBJ-/topology:2/deviceGroup:1/ethernet:1/ipv4:L14', ...]
+ :return: (bool) True if all protocols status is 'down' or 'notStarted',
+ False if any protocol status is 'up'
+ """
+ return all(self._get_protocol_status(proto) in PROTOCOL_STATUS_DOWN
+ for proto in protocols)
+
@staticmethod
def _parse_framesize(framesize):
"""Parse "framesize" config param. to return a list of weighted pairs
@@ -526,9 +557,9 @@ class IxNextgen(object): # pragma: no cover
srcseed = traffic_param['outer_l3']['srcseed']
dstseed = traffic_param['outer_l3']['dstseed']
srcmask = traffic_param['outer_l3']['srcmask'] \
- or IP_VERSION_4_MASK
+ or ipaddress.IPV4LENGTH
dstmask = traffic_param['outer_l3']['dstmask'] \
- or IP_VERSION_4_MASK
+ or ipaddress.IPV4LENGTH
if srcip:
self._update_ipv4_address(
self._get_stack_item(fg_id, PROTO_IPV4)[0],
diff --git a/yardstick/network_services/traffic_profile/http.py b/yardstick/network_services/traffic_profile/http.py
index 2d00fb849..31ab17ef7 100644
--- a/yardstick/network_services/traffic_profile/http.py
+++ b/yardstick/network_services/traffic_profile/http.py
@@ -24,6 +24,10 @@ class TrafficProfileGenericHTTP(TrafficProfile):
def __init__(self, TrafficProfile):
super(TrafficProfileGenericHTTP, self).__init__(TrafficProfile)
+ def get_links_param(self):
+ return {k: v for k, v in self.params.items() if
+ "uplink" in k or "downlink" in k}
+
def execute(self, traffic_generator):
''' send run traffic for a selected traffic generator'''
pass
diff --git a/yardstick/network_services/traffic_profile/http_ixload.py b/yardstick/network_services/traffic_profile/http_ixload.py
index 6cbdb8ab2..3ccec637d 100644
--- a/yardstick/network_services/traffic_profile/http_ixload.py
+++ b/yardstick/network_services/traffic_profile/http_ixload.py
@@ -106,8 +106,10 @@ class IXLOADHttpTest(object):
self.chassis = None
self.card = None
self.ports_to_reassign = None
+ self.links_param = None
self.test_input = jsonutils.loads(test_input)
self.parse_run_test()
+ self.test = None
@staticmethod
def format_ports_for_reassignment(ports):
@@ -171,6 +173,90 @@ class IXLOADHttpTest(object):
LOG.error('Error: IxLoad config file not found: %s', config_file)
raise
+ def update_network_address(self, net_traffic, address, gateway, prefix):
+ """Update ip address and gateway for net_traffic object
+
+ This function update field which configure source addresses for
+ traffic which is described by net_traffic object.
+ Do not return anything
+
+ :param net_traffic: (IxLoadObjectProxy) proxy obj to tcl net_traffic object
+ :param address: (str) Ipv4 range start address
+ :param gateway: (str) Ipv4 address of gateway
+ :param prefix: (int) subnet prefix
+ :return:
+ """
+ try:
+ ethernet = net_traffic.network.getL1Plugin()
+ ix_net_l2_ethernet_plugin = ethernet.childrenList[0]
+ ix_net_ip_v4_v6_plugin = ix_net_l2_ethernet_plugin.childrenList[0]
+ ix_net_ip_v4_v6_range = ix_net_ip_v4_v6_plugin.rangeList[0]
+
+ ix_net_ip_v4_v6_range.config(
+ prefix=prefix,
+ ipAddress=address,
+ gatewayAddress=gateway)
+ except Exception:
+ raise exceptions.InvalidRxfFile
+
+ def update_network_mac_address(self, net_traffic, mac):
+ """Update MACaddress for net_traffic object
+
+ This function update field which configure MACaddresses for
+ traffic which is described by net_traffic object.
+ If mac == "auto" then will be configured auto generated mac
+ Do not return anything.
+
+ :param net_traffic: (IxLoadObjectProxy) proxy obj to tcl net_traffic object
+ :param mac: (str) MAC
+ :return:
+ """
+ try:
+ ethernet = net_traffic.network.getL1Plugin()
+ ix_net_l2_ethernet_plugin = ethernet.childrenList[0]
+ ix_net_ip_v4_v6_plugin = ix_net_l2_ethernet_plugin.childrenList[0]
+ ix_net_ip_v4_v6_range = ix_net_ip_v4_v6_plugin.rangeList[0]
+
+ if str(mac).lower() == "auto":
+ ix_net_ip_v4_v6_range.config(autoMacGeneration=True)
+ else:
+ ix_net_ip_v4_v6_range.config(autoMacGeneration=False)
+ mac_range = ix_net_ip_v4_v6_range.getLowerRelatedRange(
+ "MacRange")
+ mac_range.config(mac=mac)
+ except Exception:
+ raise exceptions.InvalidRxfFile
+
+ def update_network_param(self, net_traffic, param):
+ """Update net_traffic by parameters specified in param"""
+
+ self.update_network_address(net_traffic, param["address"],
+ param["gateway"], param["subnet_prefix"])
+
+ self.update_network_mac_address(net_traffic, param["mac"])
+
+ def update_config(self):
+ """Update some fields by parameters from traffic profile"""
+
+ net_traffics = {}
+ # self.test.communityList is a IxLoadObjectProxy to some tcl object
+ # which contain all net_traffic objects in scenario.
+ # net_traffic item has a name in format "activity_name@item_name"
+ try:
+ for item in self.test.communityList:
+ net_traffics[item.name.split('@')[1]] = item
+ except Exception: # pylint: disable=broad-except
+ pass
+
+ for name, net_traffic in net_traffics.items():
+ try:
+ param = self.links_param[name]
+ except KeyError:
+ LOG.debug('There is no param for net_traffic %s', name)
+ continue
+
+ self.update_network_param(net_traffic, param["ip"])
+
def start_http_test(self):
self.ix_load = IxLoad()
@@ -197,16 +283,18 @@ class IXLOADHttpTest(object):
# Get the first test on the testList
test_name = repository.testList[0].cget("name")
- test = repository.testList.getItem(test_name)
+ self.test = repository.testList.getItem(test_name)
self.set_results_dir(test_controller, self.results_on_windows)
- test.config(statsRequired=1, enableResetPorts=1, csvInterval=2,
- enableForceOwnership=True)
+ self.test.config(statsRequired=1, enableResetPorts=1, csvInterval=2,
+ enableForceOwnership=True)
+
+ self.update_config()
# ---- Remap ports ----
try:
- self.reassign_ports(test, repository, self.ports_to_reassign)
+ self.reassign_ports(self.test, repository, self.ports_to_reassign)
except Exception: # pylint: disable=broad-except
LOG.exception("Exception occurred during reassign_ports")
@@ -246,7 +334,7 @@ class IXLOADHttpTest(object):
self.stat_utils.StartCollector(self.IxL_StatCollectorCommand)
- test_controller.run(test)
+ test_controller.run(self.test)
self.ix_load.waitForTestFinish()
test_controller.releaseConfigWaitFinish()
@@ -258,7 +346,7 @@ class IXLOADHttpTest(object):
test_controller.generateReport(detailedReport=1, format="PDF;HTML")
test_controller.releaseConfigWaitFinish()
- self.ix_load.delete(test)
+ self.ix_load.delete(self.test)
self.ix_load.delete(test_controller)
self.ix_load.delete(logger)
self.ix_load.delete(log_engine)
@@ -296,6 +384,9 @@ class IXLOADHttpTest(object):
LOG.debug("Ports to be reassigned: %s", self.ports_to_reassign)
+ self.links_param = self.test_input["links_param"]
+ LOG.debug("Links param to be applied: %s", self.links_param)
+
def main(args):
# Get the args from cmdline and parse and run the test
diff --git a/yardstick/network_services/traffic_profile/ixia_rfc2544.py b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
index b8aa78d80..0b7a78c2c 100644
--- a/yardstick/network_services/traffic_profile/ixia_rfc2544.py
+++ b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
@@ -28,6 +28,8 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
DOWNLINK = 'downlink'
DROP_PERCENT_ROUND = 6
RATE_ROUND = 5
+ STATUS_SUCCESS = "Success"
+ STATUS_FAIL = "Failure"
def __init__(self, yaml_data):
super(IXIARFC2544Profile, self).__init__(yaml_data)
@@ -174,7 +176,7 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
self._ixia_traffic_generate(traffic, ixia_obj)
return first_run
- def get_drop_percentage(self, samples, tol_min, tolerance,
+ def get_drop_percentage(self, samples, tol_min, tolerance, precision,
first_run=False):
completed = False
drop_percent = 100
@@ -208,6 +210,10 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
else:
completed = True
+ LOG.debug("tolerance=%s, tolerance_precision=%s drop_percent=%s "
+ "completed=%s", tolerance, precision, drop_percent,
+ completed)
+
latency_ns_avg = float(
sum([samples[iface]['Store-Forward_Avg_latency_ns']
for iface in samples])) / num_ifaces
@@ -218,6 +224,10 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
sum([samples[iface]['Store-Forward_Max_latency_ns']
for iface in samples])) / num_ifaces
+ samples['Status'] = self.STATUS_FAIL
+ if round(drop_percent, precision) <= tolerance:
+ samples['Status'] = self.STATUS_SUCCESS
+
samples['TxThroughput'] = tx_throughput
samples['RxThroughput'] = rx_throughput
samples['DropPercentage'] = drop_percent
diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
index a09f2a7a9..21719cbf0 100644
--- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
@@ -13,6 +13,7 @@
# limitations under the License.
import logging
+import decimal
from multiprocessing import Queue, Value, Process
import os
import posixpath
@@ -499,6 +500,7 @@ class Rfc2544ResourceHelper(object):
self._rfc2544 = None
self._tolerance_low = None
self._tolerance_high = None
+ self._tolerance_precision = None
@property
def rfc2544(self):
@@ -519,6 +521,12 @@ class Rfc2544ResourceHelper(object):
return self._tolerance_high
@property
+ def tolerance_precision(self):
+ if self._tolerance_precision is None:
+ self.get_rfc_tolerance()
+ return self._tolerance_precision
+
+ @property
def correlated_traffic(self):
if self._correlated_traffic is None:
self._correlated_traffic = \
@@ -537,9 +545,13 @@ class Rfc2544ResourceHelper(object):
def get_rfc_tolerance(self):
tolerance_str = self.get_rfc2544('allowed_drop_rate', self.DEFAULT_TOLERANCE)
- tolerance_iter = iter(sorted(float(t.strip()) for t in tolerance_str.split('-')))
- self._tolerance_low = next(tolerance_iter)
- self._tolerance_high = next(tolerance_iter, self.tolerance_low)
+ tolerance_iter = iter(sorted(
+ decimal.Decimal(t.strip()) for t in tolerance_str.split('-')))
+ tolerance_low = next(tolerance_iter)
+ tolerance_high = next(tolerance_iter, tolerance_low)
+ self._tolerance_precision = abs(tolerance_high.as_tuple().exponent)
+ self._tolerance_high = float(tolerance_high)
+ self._tolerance_low = float(tolerance_low)
class SampleVNFDeployHelper(object):
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_ixload.py b/yardstick/network_services/vnf_generic/vnf/tg_ixload.py
index e0fc47dbf..d25402740 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_ixload.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_ixload.py
@@ -20,9 +20,11 @@ import os
import shutil
import subprocess
+from oslo_serialization import jsonutils
+
from yardstick.common import utils
-from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNFTrafficGen
-from yardstick.network_services.vnf_generic.vnf.sample_vnf import ClientResourceHelper
+from yardstick.network_services.vnf_generic.vnf import sample_vnf
+
LOG = logging.getLogger(__name__)
@@ -43,7 +45,8 @@ IXLOAD_CONFIG_TEMPLATE = '''\
},
"remote_server": "%s",
"result_dir": "%s",
- "ixload_cfg": "C:/Results/%s"
+ "ixload_cfg": "C:/Results/%s",
+ "links_param": %s
}'''
IXLOAD_CMD = "{ixloadpy} {http_ixload} {args}"
@@ -59,7 +62,7 @@ class ResourceDataHelper(list):
}
-class IxLoadResourceHelper(ClientResourceHelper):
+class IxLoadResourceHelper(sample_vnf.ClientResourceHelper):
RESULTS_MOUNT = "/mnt/Results"
@@ -121,7 +124,7 @@ class IxLoadResourceHelper(ClientResourceHelper):
LOG.debug(self.result[key])
-class IxLoadTrafficGen(SampleVNFTrafficGen):
+class IxLoadTrafficGen(sample_vnf.SampleVNFTrafficGen):
def __init__(self, name, vnfd, task_id, setup_env_helper_type=None,
resource_helper_type=None):
@@ -132,6 +135,21 @@ class IxLoadTrafficGen(SampleVNFTrafficGen):
name, vnfd, task_id, setup_env_helper_type, resource_helper_type)
self._result = {}
+ def update_gateways(self, links):
+ for name in links:
+ try:
+ gateway = next(intf["virtual-interface"]["dst_ip"] for intf in
+ self.setup_helper.vnfd_helper["vdu"][0][
+ "external-interface"] if
+ intf["virtual-interface"]["vld_id"] == name)
+
+ links[name]["ip"]["gateway"] = gateway
+ except StopIteration:
+ LOG.debug("Cant find gateway for link %s", name)
+ links[name]["ip"]["gateway"] = "0.0.0.0"
+
+ return links
+
def run_traffic(self, traffic_profile):
ports = []
card = None
@@ -143,11 +161,16 @@ class IxLoadTrafficGen(SampleVNFTrafficGen):
for csv_file in glob.iglob(self.ssh_helper.join_bin_path('*.csv')):
os.unlink(csv_file)
+ links_param = self.update_gateways(
+ traffic_profile.get_links_param())
+
ixia_config = self.vnfd_helper.mgmt_interface["tg-config"]
ixload_config = IXLOAD_CONFIG_TEMPLATE % (
ixia_config["ixchassis"], ports, card,
self.vnfd_helper.mgmt_interface["ip"], self.ssh_helper.bin_path,
- os.path.basename(self.resource_helper.resource_file_name))
+ os.path.basename(self.resource_helper.resource_file_name),
+ jsonutils.dumps(links_param)
+ )
http_ixload_path = os.path.join(VNF_PATH, "../../traffic_profile")
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_landslide.py b/yardstick/network_services/vnf_generic/vnf/tg_landslide.py
index a146b72ca..2fba89b22 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_landslide.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_landslide.py
@@ -129,6 +129,17 @@ class LandslideTrafficGen(sample_vnf.SampleVNFTrafficGen):
self.session_profile['reservePorts'] = 'true'
self.session_profile['reservations'] = [reservation]
+ def _update_session_library_name(self, test_session):
+ """Update DMF library name in session profile"""
+ for _ts_group in test_session['tsGroups']:
+ for _tc in _ts_group['testCases']:
+ try:
+ for _mainflow in _tc['parameters']['Dmf']['mainflows']:
+ _mainflow['library'] = \
+ self.vnfd_helper.mgmt_interface['user']
+ except KeyError:
+ pass
+
@staticmethod
def _update_session_tc_params(tc_options, testcase):
for _param_key in tc_options:
@@ -206,6 +217,8 @@ class LandslideTrafficGen(sample_vnf.SampleVNFTrafficGen):
_testcase_idx].update(
self._update_session_tc_params(tc_options, _testcase))
+ self._update_session_library_name(self.session_profile)
+
class LandslideResourceHelper(sample_vnf.ClientResourceHelper):
"""Landslide TG helper class"""
@@ -459,11 +472,14 @@ class LandslideResourceHelper(sample_vnf.ClientResourceHelper):
self._terminated.value = 1
def create_dmf(self, dmf):
- if isinstance(dmf, list):
- for _dmf in dmf:
- self._tcl.create_dmf(_dmf)
- else:
- self._tcl.create_dmf(dmf)
+ if isinstance(dmf, dict):
+ dmf = [dmf]
+ for _dmf in dmf:
+ # Update DMF library name in traffic profile
+ _dmf['dmf'].update(
+ {'library': self.vnfd_helper.mgmt_interface['user']})
+ # Create DMF on Landslide server
+ self._tcl.create_dmf(_dmf)
def delete_dmf(self, dmf):
if isinstance(dmf, list):
@@ -600,6 +616,13 @@ class LandslideResourceHelper(sample_vnf.ClientResourceHelper):
def create_test_session(self, test_session):
# Use tcl client to create session
test_session['library'] = self._user_id
+
+ # If no traffic duration set in test case, use predefined default value
+ # in session profile
+ test_session['duration'] = self.scenario_helper.all_options.get(
+ 'traffic_duration',
+ test_session['duration'])
+
LOG.debug("Creating session='%s'", test_session['name'])
self._tcl.create_test_session(test_session)
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
index 558a62935..89f8194c0 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
@@ -107,6 +107,7 @@ class IxiaResourceHelper(ClientResourceHelper):
min_tol = self.rfc_helper.tolerance_low
max_tol = self.rfc_helper.tolerance_high
+ precision = self.rfc_helper.tolerance_precision
default = "00:00:00:00:00:00"
self._build_ports()
@@ -134,7 +135,7 @@ class IxiaResourceHelper(ClientResourceHelper):
traffic_profile.config.duration)
completed, samples = traffic_profile.get_drop_percentage(
- samples, min_tol, max_tol, first_run=first_run)
+ samples, min_tol, max_tol, precision, first_run=first_run)
self._queue.put(samples)
if completed: