aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common/utils.py
AgeCommit message (Collapse)AuthorFilesLines
2019-04-19Log VM OS version, Sample VNF branch/commit IDStepan Andrushko1-0/+45
Added debug logs to track VM, Sample VNF details during testing: - Virtual machine OS, kernel version; - Sample VNF branch, commit ID. JIRA: YARDSTICK-1499 Change-Id: I243c435809d4541dfdb8c7c3466f50c5d524ac00 Signed-off-by: Stepan Andrushko <stepanx.andrushko@intel.com>
2018-12-27Add IxNetwork L3 scenario implementationMyron Sosyak1-0/+11
Protocol interfaces are creating with config from pod file Static IP configuration are creating from testcase flow options JIRA: YARDSTICK-1570 Change-Id: I74cde67b5084d5b65d09934fe8fce7760b5ea461 Signed-off-by: Myron Sosyak <myronx.sosyak@intel.com>
2018-11-22Fix hugepages calculationMytnyk, Volodymyr1-1/+2
JIRA: YARDSTICK-1537 Change-Id: If4e78fe49c8b248c180d5a8db3932d822b9e5f95 Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
2018-10-27Setup hugepages on SA host(sriov, ovs_dpdk)Serhiy Pshyk1-0/+17
JIRA: YARDSTICK-1461 Change-Id: Ia1f5026eee989672aac57775ec9dd182df658fa4 Signed-off-by: Serhiy Pshyk <serhiyx.pshyk@intel.com>
2018-08-21Convert IXIA latency statistics to integerRodolfo Alonso Hernandez1-0/+22
JIRA: YARDSTICK-1385 Change-Id: Id50c393da7ded4b3c8e127f7d7a6501832a68446 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-08-02Merge "Replace assert statements in PipelineRules"Abhijit Sinha1-0/+4
2018-07-31Replace assert statements in PipelineRulesMiikka Koistinen1-0/+4
The class PipelineRules uses assert statements to check the correctness of an input parameter IP address. This commit will modify these lines to use a dedicated function "common.utils.make_ipv4_address". JIRA: YARDSTICK-966 Change-Id: I1c4cc439a7716d36548125c87dfb0bc200714a56 Signed-off-by: Miikka Koistinen <miikka.koistinen@nokia.com>
2018-07-31Fix remote command execution in common.utilsMiikka Koistinen1-6/+2
yardstick.common.utils get_port_mac and get_port_ip both raise a RuntimeError on positive remote command exit status. This commit fixes them to use the error raising mechanism in yardstick.ssh.SSH. Additionally, the class AutoConnectSSH class needed an additional argument to allow the raising mechanism to work correctly. JIRA: YARDSTICK-1240 Change-Id: Idad125ebbd668cef10a6149eb3e601a437a8d40d Signed-off-by: Miikka Koistinen <miikka.koistinen@nokia.com>
2018-07-30Change assert statement to raise in common/utilsMiikka Koistinen1-2/+6
This modification utilises a custom exception to be raised if an invalid mac address is passed to the function "mac_address_to_hex_list". JIRA: YARDSTICK-966 Change-Id: Ic2940276f500e9710c54963a445a137e73bd6b25 Signed-off-by: Miikka Koistinen <miikka.koistinen@nokia.com>
2018-07-26Enable "wait_until_true" when used ouf the main threadRodolfo Alonso Hernandez1-4/+21
"util.wait_until_true" uses "util.Timer" to create an active wait for a condition. "Timer" class uses "signal" to create a watchdog to track the time lapsed. When used out of the main thread, "Timer" raises the following error: ValueError: signal only works in main thread To make "util.wait_until_true" usable always, a new waitting method is implemented. JIRA: YARDSTICK-1358 Change-Id: Ifb5ba0b17b5beca0af5ceab4f6431d58b7928762 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-07-24Add IP mask to IxNetwork configurationRodolfo Alonso Hernandez1-0/+8
Assign the IP mask to IxNetwork configuration, depending on the IP range provided by the user in the traffic profile. In case of single IP, a default mask will be provided: - IP_VERSION_4_MASK = 24 - IP_VERSION_6_MASK = 64 JIRA: YARDSTICK-1351 Change-Id: I029473ab8b9966a76cf559ffef53b34ca11462ad Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-07-10Merge "Add send socket commands function"Rodolfo Alonso Hernandez1-0/+22
2018-06-29Move "read_yaml_file" to common.yaml_loaderRodolfo Alonso Hernandez1-9/+0
JIRA: YARDSTICK-1265 Change-Id: Ic2813dca7fc9a3230632f6e8bd75aeacc7e951b0 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-26Extended Context class with get_physical_nodes functionalityChornyi, TarasX1-0/+9
JIRA: YARDSTICK-1255 Change-Id: I446d715dc6cf716a4fcbc1b809c1b1d6303071e0 Signed-off-by: Chornyi, TarasX <tarasx.chornyi@intel.com>
2018-06-22Merge "Configure ACL via static file"Abhijit Sinha1-0/+13
2018-06-21Configure ACL via static fileMytnyk, Volodymyr1-0/+13
This patch allows user to configure ACL/vFW SampleVNF ACL via configuration file provided in TC definition. The Yardstick applies the rules to SampleVNF from specified config file + rules generated by Yardstick (default rules). The example of SampleVNF ACL CLI commands generated/applied by Yardstick can be found at (using default ACL config file): ACL VNF ACL CLI commands: acl/tc_heat_rfc2544_ipv4_1rule_1flow_64B_trex.yaml http://paste.openstack.org/show/723303/ vFW VNF ACL CLI commands: vfw/tc_heat_rfc2544_ipv4_1rule_1flow_64B_trex.yaml http://paste.openstack.org/show/723304/ Change-Id: I76a630261a982083b628e3985fc3bec14ca495db Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
2018-06-18Refactor RFC2455 TRex traffic profile injectionRodolfo Alonso Hernandez1-2/+24
The TRex RFC2455 traffic profile configures the duration of the traffic injection. Once the traffic is started, the traffic profile should poll the traffic injector client for the injection status. When the injection is finished, the traffic execution should end. Instead of this, the traffic profile waits a fixed time (using time.sleep method) and then stops the traffic. This approach is not accurate and may cause shorter injection periods. JIRA: YARDSTICK-1197 Change-Id: I5090df81ef4ec7945ff6c1aff070656b48e0fe77 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-06-14Add send socket commands functionRodolfo Alonso Hernandez1-0/+22
Pktgen provides a TCP socket connection to allow the user to control it from a remote console or program [1]. This new method will provide Yardstick the ability to send string commands to a port in a remote host. [1] http://pktgen-dpdk.readthedocs.io/en/latest/socket.html JIRA: YARDSTICK-1186 Change-Id: I9d64ccad662fa3599de65654c5dab02833fcc91d Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-04-27Add active wait functionRodolfo Alonso Hernandez1-1/+33
Added function "wait_until_true". This function will make an active wait until the predicate passed as an argument returns True. If the timeout expires, the function will raise a generic exception or a user defined one passed as an argument. This function will be used in YARDSTICK-1127. JIRA: YARDSTICK-1128 Change-Id: I9854e465ac6b586bf4be39ab4b266d5625b39e30 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-04-12Bugfix: Can't get image list in APIchenjiankun1-0/+5
JIRA: YARDSTICK-1110 To match OpenStack Pike release, we upgrade novaclient from 7.1.1 to 9.1.1. And the client interface has changed, it no longer has nova_client.images attribute. So I use shade instead. Later will change all same issue. Change-Id: Ie4f54069d4346e44e2ad925439930504b945cbad Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
2018-03-01NSB: move interface probe to VNF, and attempt driver-only probe firstRoss Brattain1-0/+15
If no devices are present we can't detect MAC address so we can't match Heat ports to interfaces. If only the driver is missing we can try to probe the driver using lspci. We can use lspci to ask the kernel what driver it should use for the PCI device. If we can't probe at all because the device is already bound, we can use dpkd-devind to find all the PCI address we care about and create a map with PCI device and real kernel driver. Then we can dpdk force rebind to the kernel driver. Once we have rebound to the kernel driver we can detect MAC address and all the other attributes that are required. Fix VnfSshHelper to allow override of wait timeout And a bunch of other refactors that got swept up in this JIRA: YARDSTICK-835 Change-Id: I14cb657ed289a77941d048345d06ced5b5d5da52 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2018-03-01Merge "Import "traffic_profile" modules only once"Ross Brattain1-2/+32
2018-03-01Merge "Module to manage pip packages"Rodolfo Alonso Hernandez1-4/+4
2018-03-01Import "traffic_profile" modules only onceRodolfo Alonso Hernandez1-2/+32
"traffic_profile" modules should be imported only once. Every time TrafficProfile.get is called, the modules under "yardstick.network_services.traffic_profiles" are loaded [1]. Instead of this, the modules should be registered only once the first time "yardstick.network_services.traffic_profiles.base" is loaded. This will reduce the execution time and will avoid unnecessary calls. [1] https://github.com/opnfv/yardstick/blob/d2c7cc4e9768ed003257a95c92cdb278d516761b/yardstick/network_services/traffic_profile/base.py#L36-L37 JIRA: YARDSTICK-951 Change-Id: Ia3565378ba3a1377fcb0aea8bda50ef8189414fd Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-02-09Module to manage pip packagesRodolfo Alonso Hernandez1-4/+4
This new module provides methods to manage Python PIP packages from a URL, from a local directory or from a build PIP package. The implemented commands are: - Install package. - Remove package. - List all installed packages in the system. JIRA: YARDSTICK-910 Change-Id: I8f7d1b77c0c384b801cc6f5e67d8b45ce7c6bfdf Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-02-06Improve SampleVNF hugepages setupRodolfo Alonso Hernandez1-0/+15
The goal of this function is to: - Read the default hugepage size. - Set 16GB of hugepages. - Check if the status of the last action. According to [1], the default hugepage size could be read in "/proc/meminfo", always in kB. Then "/proc/sys/vm/nr_hugepages" could be used to set the number of default hugepages. [1] https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt JIRA: YARDSTICK-997 Change-Id: I762d1b16294ba1c1c2feee56610819ac358c7410 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2018-01-19Replace "oslo_utils.importutils" with standard library "importlib"Rodolfo Alonso Hernandez1-22/+18
The current implementation of dynamic library importation is prone to failure [1]: - "sys.modules" is modified manually, which is something not recommended [2]. - When a module is imported is added to "sys.modules"; that means there is no need to manually create an entry in this object. - "importlib" library is part of the standard library and is now available in PY3 and PY2 (backported). This library contains a function called "import_module" to import a module in runtime. [1]https://github.com/opnfv/yardstick/blob/d2c7cc4e9768ed003257a95c92cdb278d516761b/yardstick/common/utils.py#L72-L93 [2]http://justus.science/blog/2015/04/19/sys.modules-is-dangerous.html JIRA: YARDSTICK-949 Change-Id: Ide3b74f98858d06fa275fb6c9b78ceeaa64feed5 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2017-12-22Replace subprocess "check_output" with "Popen"Rodolfo Alonso Hernandez1-5/+15
"check_output" is a blocking wrapper for "Popen" which returns the output of the command execution or raises an exception in case of error. "Popen" is a non-blocking function that allows to create asynchronous tasks. It returns any possible execution error but doesn't raise an exception; this is delegated to the developer. This code is used in the Yardstick CLI base test class. Change-Id: Ie3e1228b2d40cb306354447653678bf581bc9697 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
2017-10-17validate_non_string_sequence: use six.string_typesRoss Brattain1-1/+1
Change-Id: I7248d97a55974091daf20f0fba4b612101a0e4c5 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-09-26Ensure that at least one handler is availableEdward MacGillivray1-14/+0
https://jira.opnfv.org/browse/YARDSTICK-773?filter=-3 Remove dependency of yardstick on utils methods Change-Id: Iadf502364a7f08c279a8f0d17d7e45e8047f4066 Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com>
2017-08-28utils: catch SyntaxError during importRoss Brattain1-1/+1
bad modules can also throw SyntaxError besides ImportError Change-Id: I4fa912505753cba3c06f127105354572b7f5ddd8 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-08-19import_modules_from_package: refactor with generatorsRoss Brattain1-13/+13
remove ..... split and use os.path.relpath to remove prefix use set operations to find missing modules, so we don't need to check dict contains multiple times Change-Id: I9531360fb9b2999e83874f144f1d06d825b22b2c Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-08-15YAML fixesRoss Brattain1-2/+2
There are multiple issues wiht YAML loading. 1. Jinja2 renders None values as a string 'None'. This is not valid YAML we need to render None values to '~' or 'null' which is the native YAML None value. 2. Jinja2 renders dict and lists that contain unicode with u'foo' values. This is not value YAML syntax. Because we are serializing dict and lists into YAML, we need to encode them as valid YAML. We can override Jinja2 finalize to use yaml.dump to dump inline YAML. We use yaml.safe_dump(elem, default_flow_style=True).replace('\n', '') to generate valid single-line YAML dict and list values. But this problem highlights the general difficulties with templating and loading files. We could avoid this Python->Jinja2->YAML->Python issue by directly injecting the list or dict after the YAML is loaded. I'm not sure of the real utility of these templates. 3. On Python 2 YAML loader is rendering all strings as unicode. This does not work for Trex because Trex is broken and badly coded. Trex does type checking against str() which is different for Python 2 and Python 3. The default YAML loader will return native string types, str() or unicode() for Python 2 and Python 3 respectively. The bad Trex codes is in convert_val: https://github.com/cisco-system-traffic-generator/trex-core/blob/master/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py#L674 def convert_val (val): if is_integer(val): return val if type(val) == str: return ipv4_str_to_num (is_valid_ipv4(val)) raise CTRexPacketBuildException(-11,("init val invalid %s ") % val ); This code is doing type(val) == str. This is bad and broken. We can't fix Trex, so we have to render all strings as native str() types The bug here was that the Heat template loader template_format.py was overriding the global YAML loader to always return unicode. We don't want this global override. To fix this we have to use local subclasses of the yaml.SafeLoader class. But in order to dynamically subclass from CSafeLoader or SafeLoader we have to use the type() builtin to define a new class at runtime. Once we have new classes defined, we can safely isolate different YAML constructors and return unicode or not depending on the case. To be consistent we implement a new yaml_loader.py module to centralize all non-Heat template yaml loading to ensure correct uncode/str conversion Change-Id: Iebf9cf78fbda390977c390436b0869e7bbf503eb Signed-off-by: Ross Brattain <ross.b.brattain@intel.com> Signed-off-by: Deepak S <deepak.s@linux.intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-08-14PROX VNF and TGRoss Brattain1-25/+29
PROX was added to samplevnf project https://git.opnfv.org/samplevnf/tree/VNFs/DPPD-PROX JIRA: YARDSTICK-638 Change-Id: If9875b1130c6bed87deb8720b0d8b28ede9289d9 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-08-11Add Ansible executor class for node contextRoss Brattain1-0/+17
import the AnsibleCommon class to execute Ansible playbooks Update node context support to use AnsibleCommon needs unittests We must call ansible-playbook as an executable, so we must create temp files for inventory, and for the playbooks. AnsibleCommon has evolved to be quite flexible, it auto-generates the inventory from the context['nodes'] and generates groups from the node Role. We also support either a single playbook filename, or a list of filenames. If given a list we dynamically generate a playbook that includes the other playbooks. We support adding any number of extra_vars using a temp JSON file. Also designed to be extended by subclassing. Change-Id: I5bd0a2b4547feaadd70b7e2b8801f19371b99df0 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-08-10Merge "constants: cache YAML config values"Ross Brattain1-14/+0
2017-08-08constants: cache YAML config valuesRoss Brattain1-14/+0
don't reparse the yardstick.yaml file each time we lookup an option. Since it is global data, just cache it in a global var Use pkg_resources.resource_filename to lookup the path of yardstick tests, intsead of using __file__ pkg_resources is slightly more proper than __file__ at least for packages Change-Id: I05d9748390a37bd45c53013fc084d23069ab7c51 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-08-08IXIA traffic generatorDeepak S1-0/+26
Change-Id: I09bcb3f2c4b945283070d442589d3bf00468abbc Signed-off-by: Deepak S <deepak.s@linux.intel.com> Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-08-08NSB updateDeepak S1-5/+93
Refactored main NSB VNF classes accroding to class diagram https://wiki.opnfv.org/display/yardstick/NSB+class+diagram All the SampleVNFs have been separated and placed under the SampleVNF class. Added AutoConnectSSH to automatically create SSH conneciton on demand. Added VnfdHelper class to wrap the VNFD dictionary in prepartion for class-based modeling. Extracted DpdkVnfSetupEnvHelper for DPDK based VNF setup. Extracted Stats and other client config to ResourceHelper Had to replace dict_key_flatten with deepgetitem due to Python 2.7 Jinja2 infinite recursion. Change-Id: Ia8840e9c44cdbdf39aab6b02e6d2176b31937dc9 Signed-off-by: Deepak S <deepak.s@linux.intel.com> Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-07-25Merge "yardstick env influxdb/grafana cmd support centos"Rex Lee1-1/+9
2017-07-19yardstick env influxdb/grafana cmd support centoschenjiankun1-1/+9
JIRA: YARDSTICK-714 Currently yardstick env influxdb/grafana command do not support centos. Because we use the gateway ip to get the service of influxdb and grafana. But in centos, we can not access influxdb/grafana service via gateway ip. In this patch, I use docker inspect to get the ip of influxdb and grafana. So these command can support centos. Change-Id: Ie4abcb8048b92d61bc62777dfc362bb29f354b2b Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
2017-07-17Add API(v2) to create influxdbchenjiankun1-0/+11
JIRA: YARDSTICK-726 API: /api/v2/yardstick/containers/action METHOD: POST PARAMS: { 'action': 'create_influxdb', 'args': { 'environment_id': environment_id } } Change-Id: I20961fc6ae9918c894de7fabd3f81ca966bd24cd Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
2017-07-17Kubernetes (k8s) supportchenjiankun1-0/+21
JIRA: YARDSTICK-682 We decide to support k8s in E release. We need to discuss with openretriver team and then rewrite the ping test case under k8s as the first step. Change-Id: I3f81ebca8de5c1f3a8b7d42581cd7342dc320239 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
2017-07-13Add API to get environmentschenjiankun1-0/+10
JIRA: YARDSTICK-716 API: /api/v2/yardstick/environments METHOD: GET Change-Id: I46b7fb2b143fe76b6a0edbf1ecc8281187b85918 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
2017-07-11Yardstick API architecture improvementchenjiankun1-2/+22
JIRA: YARDSTICK-710 Since we have the plan to upload api v2 and gui. We need to add put and delete method. So the architecture need to be improved. Change-Id: Ie20a79c26ef6c581897ce4e63980fa2895b162d2 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
2017-07-06move flatten dict key to common utilsrexlee87761-0/+23
So it can easily be used by other testcase to unify result JIRA: YARDSTICK-702 Change-Id: Id4fde38a9a0c2a87a6c870bdb7b0c8f3a3b371ac Signed-off-by: rexlee8776 <limingjiang@huawei.com>
2017-06-02utils: make module import saferRoss Brattain1-1/+4
If a module fails to import, then ignore it and try the next module. This can help if certain module depenencies aren't installed, e.g. TREX. Change-Id: I2bc4384429fabd61cd430817489cb2f3c86fe9b2 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
2017-05-01Extend TC008 to run pktgen-dpdk inside VMJing Zhang1-0/+19
Need a fast path inside VM to verify full throughput of SRIOV and OVS-dpdk. Update 1: Change newly added file names to avoid conflict Update 2: Add more unit test cases Update 3: Fix default parameter typo for testpmd Update 4: Adapted to the pktgen-dpdk prompt change from "Pktgen>" to "Pktgen:/>", now just expect "Pktgen" Update 5: Per comment, merge common functions between latency and throughput tests to utils.py Update 6: Per comment, seperate the test case from TC008 to a new test case TC077 Change-Id: I1f7471d4ba77636a3a66c79c2652578321312185 JIRA: YARDSTICK-614 Signed-off-by: Jing Zhang <jing.c.zhang@nokia.com>
2017-04-01Yardstick virtualenv supportchenjiankun1-16/+20
JIRA: YARDSTICK-620 Currently we recommend using docker to run yardstick. And it is hard to use virtualenv to install yardstick. So I modify install.sh in yardstick root path. It will support using virtualenv to install yardstick(including API) in linux. In this patch, I make yardstick support read yardstick configuration have priority over constants. Change-Id: I9ea1241b228532a6497451e6c8f232173ddb783e Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
2017-03-09Merge "Bugfix: don't use jsonutils.load, use loads()"Rex Lee1-1/+3