summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ansible/install.yaml1
-rw-r--r--ansible/roles/configure_uwsgi/templates/yardstick.ini.j24
-rw-r--r--docker/Dockerfile2
-rw-r--r--docs/release/release-notes/release-notes.rst120
-rwxr-xr-xdocs/testing/developer/devguide/devguide_nsb_prox.rst143
-rw-r--r--docs/testing/developer/devguide/images/PROX_Grafana_1.pngbin0 -> 98429 bytes
-rw-r--r--docs/testing/developer/devguide/images/PROX_Grafana_2.pngbin0 -> 61661 bytes
-rw-r--r--docs/testing/developer/devguide/images/PROX_Grafana_3.pngbin0 -> 24975 bytes
-rw-r--r--docs/testing/developer/devguide/images/PROX_Grafana_4.pngbin0 -> 67328 bytes
-rw-r--r--docs/testing/developer/devguide/images/PROX_Test_BM_Script.pngbin76705 -> 86549 bytes
-rw-r--r--docs/testing/developer/devguide/images/PROX_Test_HEAT_Script.pngbin90040 -> 0 bytes
-rw-r--r--docs/testing/developer/devguide/images/PROX_Test_HEAT_Script1.pngbin0 -> 87627 bytes
-rw-r--r--docs/testing/developer/devguide/images/PROX_Test_HEAT_Script2.pngbin0 -> 85248 bytes
-rw-r--r--docs/testing/developer/devguide/index.rst1
-rw-r--r--tests/opnfv/test_suites/opnfv_os-odl-ovs-noha_daily.yaml64
-rw-r--r--yardstick/benchmark/contexts/base.py3
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py4
-rw-r--r--yardstick/network_services/collector/subscriber.py31
-rw-r--r--yardstick/network_services/nfvi/resource.py73
-rw-r--r--yardstick/network_services/vnf_generic/vnf/prox_vnf.py25
-rw-r--r--yardstick/network_services/vnf_generic/vnf/router_vnf.py4
-rw-r--r--yardstick/network_services/vnf_generic/vnf/sample_vnf.py58
-rw-r--r--yardstick/network_services/vnf_generic/vnf/udp_replay.py11
-rw-r--r--yardstick/network_services/vnf_generic/vnf/vpe_vnf.py5
-rw-r--r--yardstick/tests/unit/benchmark/contexts/test_base.py2
-rw-r--r--yardstick/tests/unit/common/test_openstack_utils.py67
-rw-r--r--yardstick/tests/unit/common/test_process.py10
-rw-r--r--yardstick/tests/unit/network_services/collector/test_subscriber.py31
-rw-r--r--yardstick/tests/unit/network_services/nfvi/test_resource.py31
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/acl_1rule.yaml47
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py36
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py11
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py46
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py19
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py40
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py43
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py18
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py12
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py16
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py29
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py21
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py40
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py10
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py16
44 files changed, 823 insertions, 271 deletions
diff --git a/ansible/install.yaml b/ansible/install.yaml
index d1745798c..e93232d06 100644
--- a/ansible/install.yaml
+++ b/ansible/install.yaml
@@ -35,6 +35,7 @@
- install_yardstick
- configure_uwsgi
- configure_nginx
+ - configure_gui
- download_trex
- install_trex
- configure_rabbitmq
diff --git a/ansible/roles/configure_uwsgi/templates/yardstick.ini.j2 b/ansible/roles/configure_uwsgi/templates/yardstick.ini.j2
index c049daf84..044f42acb 100644
--- a/ansible/roles/configure_uwsgi/templates/yardstick.ini.j2
+++ b/ansible/roles/configure_uwsgi/templates/yardstick.ini.j2
@@ -1,7 +1,7 @@
[uwsgi]
master = true
debug = true
-chdir = {{ yardstick_dir }}api
+chdir = {{ yardstick_dir }}/api
module = server
plugins = python
processes = 10
@@ -15,4 +15,4 @@ close-on-exec = 1
daemonize = {{ log_dir }}uwsgi.log
socket = {{ socket_file }}
{# If virtual environment, we need to add:
- virtualenv = <virtual_env> #} \ No newline at end of file
+ virtualenv = <virtual_env> #}
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 7f85cbd7f..4aa7237a5 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -40,7 +40,7 @@ RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/yardstick ${Y
RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng ${RELENG_REPO_DIR}
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/storperf ${STORPERF_REPO_DIR}
-RUN ansible-playbook -c local -vvv -e INSTALLATION_MODE="container" ${YARDSTICK_REPO_DIR}/ansible/install.yaml
+RUN ansible-playbook -i ${YARDSTICK_REPO_DIR}/ansible/install-inventory.ini -c local -vvv -e INSTALLATION_MODE="container" ${YARDSTICK_REPO_DIR}/ansible/install.yaml
RUN ${YARDSTICK_REPO_DIR}/docker/supervisor.sh
diff --git a/docs/release/release-notes/release-notes.rst b/docs/release/release-notes/release-notes.rst
index 7ea2616e4..daa4b8187 100644
--- a/docs/release/release-notes/release-notes.rst
+++ b/docs/release/release-notes/release-notes.rst
@@ -36,6 +36,12 @@ Version History
| *Date* | *Version* | *Comment* |
| | | |
+-------------------+-----------+---------------------------------+
+| Jul 2, 2018 | 6.2.1 | Yardstick for Fraser release |
+| | | |
++-------------------+-----------+---------------------------------+
+| Jun 29, 2018 | 6.2.0 | Yardstick for Fraser release |
+| | | |
++-------------------+-----------+---------------------------------+
| May 25, 2018 | 6.1.0 | Yardstick for Fraser release |
| | | |
+-------------------+-----------+---------------------------------+
@@ -120,19 +126,19 @@ Release Data
| **Project** | Yardstick |
| | |
+--------------------------------+-----------------------+
-| **Repo/tag** | yardstick/opnfv-6.1.0 |
+| **Repo/tag** | yardstick/opnfv-6.2.0 |
| | |
+--------------------------------+-----------------------+
-| **Yardstick Docker image tag** | opnfv-6.1.0 |
+| **Yardstick Docker image tag** | opnfv-6.2.0 |
| | |
+--------------------------------+-----------------------+
| **Release designation** | Fraser |
| | |
+--------------------------------+-----------------------+
-| **Release date** | May 25, 2018 |
+| **Release date** | Jun 29, 2018 |
| | |
+--------------------------------+-----------------------+
-| **Purpose of the delivery** | OPNFV Fraser 6.1.0 |
+| **Purpose of the delivery** | OPNFV Fraser 6.2.0 |
| | |
+--------------------------------+-----------------------+
@@ -151,7 +157,7 @@ Documents
Software Deliverables
---------------------
- - The Yardstick Docker image: https://hub.docker.com/r/opnfv/yardstick (tag: opnfv-6.1.0)
+ - The Yardstick Docker image: https://hub.docker.com/r/opnfv/yardstick (tag: opnfv-6.2.0)
List of Contexts
^^^^^^^^^^^^^^^^
@@ -391,6 +397,110 @@ Known Issues/Faults
Corrected Faults
----------------
+Fraser 6.2.1:
+
++--------------------+--------------------------------------------------------------------------+
+| **JIRA REFERENCE** | **DESCRIPTION** |
++====================+==========================================================================+
+| YARDSTICK-1147 | Fix ansible scripts for running in container |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1157 | Bug Fix: correct the file path to build docker file |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1276 | Bugfix: docker build failed |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1280 | Bugfix: uwsgi config file yardstick.ini output error |
++--------------------+--------------------------------------------------------------------------+
+
+Fraser 6.2.0:
+
++--------------------+--------------------------------------------------------------------------+
+| **JIRA REFERENCE** | **DESCRIPTION** |
++====================+==========================================================================+
+| YARDSTICK-1246 | Update pmd/lcore mask for OVS-DPDK context |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-837 | Move tests: unit/network_services/{lib/,collector/,*.py} |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1144 | Correctly set PYTHONPATH in Dockerfile |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1205 | Set "cmd2" library to version 0.8.6 |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1204 | Bump oslo.messaging version to 5.36.0 |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1210 | Remove __init__ method overriding in HeatContextTestCase |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1189 | Error when adding SR-IOV interfaces in SR-IOV context |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1214 | Remove AnsibleCommon class method mock |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1159 | Add --hwlb options as a command line argument for SampleVNF |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1203 | Add scale out TCs with availability zone support |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1167 | Do not start collectd twice when SampleVNF is running on Baremetal |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1188 | Add "host_name_separator" variable to Context class |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1112 | MQ startup process refactor |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1229 | Cleanup BaseMonitor unit tests |
++--------------------+--------------------------------------------------------------------------+
+| - | Configure ACL via static file |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1191 | Use TRex release v2.41 to support both x86 and aarch64 |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1106 | Add IxNetwork API Python Binding package |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1224 | Cleanup TestYardstickNSCli class |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1225 | Remove print out of logger exception in TestUtils |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1194 | Add "duration" parameter to test case definition |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1209 | Remove instantiated contexts in "test_task" |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1192 | Standalone XML machine type is not longer valid |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1197 | Refactor RFC2455 TRex traffic profile injection |
++--------------------+--------------------------------------------------------------------------+
+| - | Fix "os.path" mock problems during tests |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1218 | Refactor "utils.parse_ini_file" testing |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1179 | Start nginx and uwsgi servicies only in not container mode |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1177 | Install dependencies: bare-metal, standalone |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1126 | Migrate install.sh script to ansible |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1146 | Fix nsb_setup.sh script |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1247 | NSB setup inventory name changed |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1116 | Changed IxNextgen library load in IXIA RFC2544 traffic generator call. |
++--------------------+--------------------------------------------------------------------------+
+| - | Corrected scale-up command line arguments |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-878 | OpenStack client replacement |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1222 | Bugfix: HA kill process recovery has a conflict |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1139 | Add "os_cloud_config" as a new context flag parameter |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1255 | Extended Context class with get_physical_nodes functionality |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1244 | NSB NFVi BNG test fails to run - stops after one step |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1219 | Decrease Sampling interval |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1101 | NSB NFVi PROX BNG losing many packets |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1217 | Fix NSB NfVi support for 25 and 40Gbps |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-1185 | NSB Topology fix for Prox 4 port test case |
++--------------------+--------------------------------------------------------------------------+
+| YARDSTICK-966 | Convert SLA asserts to raises |
++--------------------+--------------------------------------------------------------------------+
+
Fraser 6.1.0:
+--------------------+--------------------------------------------------------------------------+
diff --git a/docs/testing/developer/devguide/devguide_nsb_prox.rst b/docs/testing/developer/devguide/devguide_nsb_prox.rst
index 22628413b..79990055a 100755
--- a/docs/testing/developer/devguide/devguide_nsb_prox.rst
+++ b/docs/testing/developer/devguide/devguide_nsb_prox.rst
@@ -244,10 +244,13 @@ Now let's examine the components of the file in detail
3. ``nodes`` - This names the Traffic Generator and the System
under Test. Does not need to change.
-4. ``prox_path`` - Location of the Prox executable on the traffic
+4. ``interface_speed_gbps`` - This is an optional parameter. If not present
+ the system defaults to 10Gbps. This defines the speed of the interfaces.
+
+5. ``prox_path`` - Location of the Prox executable on the traffic
generator (Either baremetal or Openstack Virtual Machine)
-5. ``prox_config`` - This is the ``SUT Config File``.
+6. ``prox_config`` - This is the ``SUT Config File``.
In this case it is ``handle_l2fwd-2.cfg``
A number of additional parameters can be added. This example
@@ -285,16 +288,31 @@ Now let's examine the components of the file in detail
of a file called ``parameters.lua``, which contains information
retrieved from either the hardware or the openstack configuration.
-6. ``prox_args`` - this specifies the command line arguments to start
+7. ``prox_args`` - this specifies the command line arguments to start
prox. See `prox command line`_.
-7. ``prox_config`` - This specifies the Traffic Generator config file.
+8. ``prox_config`` - This specifies the Traffic Generator config file.
+
+9. ``runner`` - This is set to ``ProxDuration`` - This specifies that the
+ test runs for a set duration. Other runner types are available
+ but it is recommend to use ``ProxDuration``
+
+ The following parrameters are supported
+
+ ``interval`` - (optional) - This specifies the sampling interval.
+ Default is 1 sec
+
+ ``sampled`` - (optional) - This specifies if sampling information is
+ required. Default ``no``
+
+ ``duration`` - This is the length of the test in seconds. Default
+ is 60 seconds.
-8. ``runner`` - This is set to ``Duration`` - This specified that the
- test run for a set duration. Other runner types are available
- but it is recommend to use ``Duration``
+ ``confirmation`` - This specifies the number of confirmation retests to
+ be made before deciding to increase or decrease line speed. Default 0.
+
+10. ``context`` - This is ``context`` for a 2 port Baremetal configuration.
-9. ``context`` - This is ``context`` for a 2 port Baremetal configuration.
If a 4 port configuration was required then file
``prox-baremetal-4.yaml`` would be used. This is the NSB Prox
baremetal configuration file.
@@ -304,7 +322,8 @@ Now let's examine the components of the file in detail
*Traffic Profile file*
----------------------
-This describes the details of the traffic flow. In this case ``prox_binsearch.yaml`` is used.
+This describes the details of the traffic flow. In this case
+``prox_binsearch.yaml`` is used.
.. image:: images/PROX_Traffic_profile.png
:width: 800px
@@ -326,21 +345,29 @@ This describes the details of the traffic flow. In this case ``prox_binsearch.ya
Custom traffic types can be created by creating a new traffic profile class.
-3. ``tolerated_loss`` - This specifies the percentage of packets that can be lost/dropped before
- we declare success or failure. Success is Transmitted-Packets from Traffic Generator is greater than or equal to
+3. ``tolerated_loss`` - This specifies the percentage of packets that
+ can be lost/dropped before
+ we declare success or failure. Success is Transmitted-Packets from
+ Traffic Generator is greater than or equal to
packets received by Traffic Generator plus tolerated loss.
-4. ``test_precision`` - This specifies the precision of the test results. For some tests the success criteria
- may never be achieved because the test precision may be greater than the successful throughput. For finer
- results increase the precision by making this value smaller.
+4. ``test_precision`` - This specifies the precision of the test
+ results. For some tests the success criteria may never be
+ achieved because the test precision may be greater than the
+ successful throughput. For finer results increase the precision
+ by making this value smaller.
-5. ``packet_sizes`` - This specifies the range of packets size this test is run for.
+5. ``packet_sizes`` - This specifies the range of packets size this
+ test is run for.
-6. ``duration`` - This specifies the sample duration that the test uses to check for success or failure.
+6. ``duration`` - This specifies the sample duration that the test
+ uses to check for success or failure.
-7. ``lower_bound`` - This specifies the test initial lower bound sample rate. On success this value is increased.
+7. ``lower_bound`` - This specifies the test initial lower bound sample rate.
+ On success this value is increased.
-8. ``upper_bound`` - This specifies the test initial upper bound sample rate. On success this value is decreased.
+8. ``upper_bound`` - This specifies the test initial upper bound sample rate.
+ On success this value is decreased.
Other traffic profiles exist eg prox_ACL.yaml which does not
compare what is received with what is transmitted. It just
@@ -371,14 +398,18 @@ See this prox_vpe.yaml as example::
We will use ``tc_prox_heat_context_l2fwd-2.yaml`` as a example to show
you how to understand the test description file.
-.. image:: images/PROX_Test_HEAT_Script.png
+.. image:: images/PROX_Test_HEAT_Script1.png
:width: 800px
- :alt: NSB PROX Test Description File
+ :alt: NSB PROX Test Description File - Part 1
+
+.. image:: images/PROX_Test_HEAT_Script2.png
+ :width: 800px
+ :alt: NSB PROX Test Description File - Part 2
Now lets examine the components of the file in detail
-Sections 1 to 8 are exactly the same in Baremetal and in Heat. Section
-``9`` is replaced with sections A to F. Section 9 was for a baremetal
+Sections 1 to 9 are exactly the same in Baremetal and in Heat. Section
+``10`` is replaced with sections A to F. Section 10 was for a baremetal
configuration file. This has no place in a heat configuration.
A. ``image`` - yardstick-samplevnfs. This is the name of the image
@@ -418,12 +449,12 @@ F. ``networks`` - is composed of a management network labeled ``mgmt``
gateway_ip: 'null'
port_security_enabled: False
enable_dhcp: 'false'
- downlink_1:
+ uplink_1:
cidr: '10.0.4.0/24'
gateway_ip: 'null'
port_security_enabled: False
enable_dhcp: 'false'
- downlink_2:
+ downlink_1:
cidr: '10.0.5.0/24'
gateway_ip: 'null'
port_security_enabled: False
@@ -1033,7 +1064,7 @@ If PROX NSB does not work on baremetal, problem is either in network configurati
1. What is received on 0 is transmitted on 1, received on 1 transmitted on 0,
received on 2 transmitted on 3 and received on 3 transmitted on 2.
2. No packets are Failed.
- 3. No Packets are discarded.
+ 3. No packets are discarded.
We can also dump the packets being received or transmitted via the following commands. ::
@@ -1228,7 +1259,69 @@ Where
4) ir.intel.com = local no proxy
+*How to Understand the Grafana output?*
+---------------------------------------
+
+ .. image:: images/PROX_Grafana_1.png
+ :width: 1000px
+ :alt: NSB PROX Grafana_1
+
+ .. image:: images/PROX_Grafana_2.png
+ :width: 1000px
+ :alt: NSB PROX Grafana_2
+
+ .. image:: images/PROX_Grafana_3.png
+ :width: 1000px
+ :alt: NSB PROX Grafana_3
+
+ .. image:: images/PROX_Grafana_4.png
+ :width: 1000px
+ :alt: NSB PROX Grafana_4
+
+A. Test Parameters - Test interval, Duartion, Tolerated Loss and Test Precision
+
+B. Overall No of packets send and received during test
+
+C. Generator Stats - packets sent, received and attempted by Generator
+
+D. Packets Size
+
+E. No of packets received by SUT
+
+F. No of packets forwarded by SUT
+
+G. This is the number of packets sent by the generator per port, for each interval.
+
+H. This is the number of packets received by the generator per port, for each interval.
+
+I. This is the number of packets send and received by the generator and lost by the SUT
+ that meet the success criteria
+
+J. This is the changes the Percentage of Line Rate used over a test, The MAX and the
+ MIN should converge to within the interval specified as the ``test-precision``.
+
+K. This is the packets Size supported during test. If "N/A" appears in any field the result has not been decided.
+
+L. This is the calculated throughput in MPPS(Million Packets Per second) for this line rate.
+
+M. This is the actual No, of packets sent by the generator in MPPS
+
+N. This is the actual No. of packets received by the generator in MPPS
+
+O. This is the total No. of packets sent by SUT.
+
+P. This is the total No. of packets received by the SUT
+
+Q. This is the total No. of packets dropped. (These packets were sent by the generator but not
+ received back by the generator, these may be dropped by the SUT or the Generator)
+
+R. This is the tolerated no of packets that can be dropped.
+
+S. This is the test Throughput in Gbps
+
+T. This is the Latencey per Port
+U. This is the CPU Utilization
diff --git a/docs/testing/developer/devguide/images/PROX_Grafana_1.png b/docs/testing/developer/devguide/images/PROX_Grafana_1.png
new file mode 100644
index 000000000..d272edcf3
--- /dev/null
+++ b/docs/testing/developer/devguide/images/PROX_Grafana_1.png
Binary files differ
diff --git a/docs/testing/developer/devguide/images/PROX_Grafana_2.png b/docs/testing/developer/devguide/images/PROX_Grafana_2.png
new file mode 100644
index 000000000..4f7fd4cf5
--- /dev/null
+++ b/docs/testing/developer/devguide/images/PROX_Grafana_2.png
Binary files differ
diff --git a/docs/testing/developer/devguide/images/PROX_Grafana_3.png b/docs/testing/developer/devguide/images/PROX_Grafana_3.png
new file mode 100644
index 000000000..5ae967698
--- /dev/null
+++ b/docs/testing/developer/devguide/images/PROX_Grafana_3.png
Binary files differ
diff --git a/docs/testing/developer/devguide/images/PROX_Grafana_4.png b/docs/testing/developer/devguide/images/PROX_Grafana_4.png
new file mode 100644
index 000000000..5353d1c7e
--- /dev/null
+++ b/docs/testing/developer/devguide/images/PROX_Grafana_4.png
Binary files differ
diff --git a/docs/testing/developer/devguide/images/PROX_Test_BM_Script.png b/docs/testing/developer/devguide/images/PROX_Test_BM_Script.png
index 32530eb15..c09f7bb1b 100644
--- a/docs/testing/developer/devguide/images/PROX_Test_BM_Script.png
+++ b/docs/testing/developer/devguide/images/PROX_Test_BM_Script.png
Binary files differ
diff --git a/docs/testing/developer/devguide/images/PROX_Test_HEAT_Script.png b/docs/testing/developer/devguide/images/PROX_Test_HEAT_Script.png
deleted file mode 100644
index 754973b4e..000000000
--- a/docs/testing/developer/devguide/images/PROX_Test_HEAT_Script.png
+++ /dev/null
Binary files differ
diff --git a/docs/testing/developer/devguide/images/PROX_Test_HEAT_Script1.png b/docs/testing/developer/devguide/images/PROX_Test_HEAT_Script1.png
new file mode 100644
index 000000000..bd375dba1
--- /dev/null
+++ b/docs/testing/developer/devguide/images/PROX_Test_HEAT_Script1.png
Binary files differ
diff --git a/docs/testing/developer/devguide/images/PROX_Test_HEAT_Script2.png b/docs/testing/developer/devguide/images/PROX_Test_HEAT_Script2.png
new file mode 100644
index 000000000..99d9d24e6
--- /dev/null
+++ b/docs/testing/developer/devguide/images/PROX_Test_HEAT_Script2.png
Binary files differ
diff --git a/docs/testing/developer/devguide/index.rst b/docs/testing/developer/devguide/index.rst
index 92a18f6ee..9a76a32f1 100644
--- a/docs/testing/developer/devguide/index.rst
+++ b/docs/testing/developer/devguide/index.rst
@@ -14,3 +14,4 @@ Yardstick Developer Guide
:numbered:
devguide
+ devguide_nsb_prox
diff --git a/tests/opnfv/test_suites/opnfv_os-odl-ovs-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl-ovs-noha_daily.yaml
new file mode 100644
index 000000000..83b370066
--- /dev/null
+++ b/tests/opnfv/test_suites/opnfv_os-odl-ovs-noha_daily.yaml
@@ -0,0 +1,64 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+---
+# os-odl-ovs-noha daily task suite
+
+schema: "yardstick:suite:0.1"
+
+name: "os-odl-ovs-noha"
+test_cases_dir: "tests/opnfv/test_cases/"
+test_cases:
+-
+ file_name: opnfv_yardstick_tc002.yaml
+-
+ file_name: opnfv_yardstick_tc005.yaml
+-
+ file_name: opnfv_yardstick_tc010.yaml
+-
+ file_name: opnfv_yardstick_tc011.yaml
+ constraint:
+ installer: compass,fuel
+-
+ file_name: opnfv_yardstick_tc012.yaml
+-
+ file_name: opnfv_yardstick_tc014.yaml
+-
+ file_name: opnfv_yardstick_tc037.yaml
+-
+ file_name: opnfv_yardstick_tc055.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5"}'
+-
+ file_name: opnfv_yardstick_tc063.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node5"}'
+-
+ file_name: opnfv_yardstick_tc069.yaml
+-
+ file_name: opnfv_yardstick_tc070.yaml
+-
+ file_name: opnfv_yardstick_tc071.yaml
+-
+ file_name: opnfv_yardstick_tc072.yaml
+-
+ file_name: opnfv_yardstick_tc075.yaml
+ constraint:
+ installer: compass
+ pod: huawei-pod1
+ task_args:
+ huawei-pod1: '{"file": "etc/yardstick/nodes/compass_sclab_physical/pod.yaml",
+ "host": "node1"}'
diff --git a/yardstick/benchmark/contexts/base.py b/yardstick/benchmark/contexts/base.py
index 022e365e4..1c798fbb3 100644
--- a/yardstick/benchmark/contexts/base.py
+++ b/yardstick/benchmark/contexts/base.py
@@ -81,6 +81,9 @@ class Context(object):
self.file_path = os.path.join(YARDSTICK_ROOT_PATH, file_path)
cfg = utils.read_yaml_file(self.file_path)
+ for node in cfg["nodes"]:
+ node["ctx_type"] = self.__context_type__
+
self.nodes.extend(cfg["nodes"])
self.controllers.extend([node for node in cfg["nodes"]
if node.get("role") == "Controller"])
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py
index 4d7c4f9be..eb62d6222 100644
--- a/yardstick/benchmark/scenarios/networking/vnf_generic.py
+++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py
@@ -23,6 +23,7 @@ import time
import six
import yaml
+from yardstick.benchmark.contexts import base as context_base
from yardstick.benchmark.scenarios import base as scenario_base
from yardstick.common.constants import LOG_DIR
from yardstick.common import exceptions
@@ -36,6 +37,7 @@ from yardstick.network_services.traffic_profile import base as tprofile_base
from yardstick.network_services.utils import get_nsb_option
from yardstick import ssh
+
traffic_profile.register_modules()
@@ -448,7 +450,7 @@ class NetworkServiceTestCase(scenario_base.Scenario):
traffic_gen.listen_traffic(self.traffic_profile)
# register collector with yardstick for KPI collection.
- self.collector = Collector(self.vnfs)
+ self.collector = Collector(self.vnfs, context_base.Context.get_physical_nodes())
self.collector.start()
# Start the actual traffic
diff --git a/yardstick/network_services/collector/subscriber.py b/yardstick/network_services/collector/subscriber.py
index 322b3f5a2..937c266a6 100644
--- a/yardstick/network_services/collector/subscriber.py
+++ b/yardstick/network_services/collector/subscriber.py
@@ -14,17 +14,36 @@
"""This module implements stub for publishing results in yardstick format."""
import logging
+from yardstick.network_services.nfvi.resource import ResourceProfile
+from yardstick.network_services.utils import get_nsb_option
+
+
LOG = logging.getLogger(__name__)
class Collector(object):
"""Class that handles dictionary of results in yardstick-plot format."""
- def __init__(self, vnfs):
+ def __init__(self, vnfs, contexts_nodes, timeout=3600):
super(Collector, self).__init__()
self.vnfs = vnfs
+ self.nodes = contexts_nodes
+ self.bin_path = get_nsb_option('bin_path', '')
+ self.resource_profiles = {}
+
+ for ctx_name, nodes in contexts_nodes.items():
+ for node in (node for node in nodes if node.get('collectd')):
+ name = ".".join([node['name'], ctx_name])
+ self.resource_profiles.update(
+ {name: ResourceProfile.make_from_node(node, timeout)}
+ )
def start(self):
+ for resource in self.resource_profiles.values():
+ resource.initiate_systemagent(self.bin_path)
+ resource.start()
+ resource.amqp_process_for_nfvi_kpi()
+
for vnf in self.vnfs:
vnf.start_collect()
@@ -32,6 +51,9 @@ class Collector(object):
for vnf in self.vnfs:
vnf.stop_collect()
+ for resource in self.resource_profiles.values():
+ resource.stop()
+
def get_kpi(self):
"""Returns dictionary of results in yardstick-plot format
@@ -42,7 +64,12 @@ class Collector(object):
for vnf in self.vnfs:
# Result example:
# {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
- LOG.debug("collect KPI for %s", vnf.name)
+ LOG.debug("collect KPI for vnf %s", vnf.name)
results[vnf.name] = vnf.collect_kpi()
+ for node_name, resource in self.resource_profiles.items():
+ LOG.debug("collect KPI for nfvi_node %s", node_name)
+ results[node_name] = {"core": resource.amqp_collect_nfvi_kpi()}
+ LOG.debug("%s collect KPIs %s", node_name, results[node_name]['core'])
+
return results
diff --git a/yardstick/network_services/nfvi/resource.py b/yardstick/network_services/nfvi/resource.py
index 0c0bf223a..5922bd3b9 100644
--- a/yardstick/network_services/nfvi/resource.py
+++ b/yardstick/network_services/nfvi/resource.py
@@ -31,6 +31,7 @@ from yardstick.common.exceptions import ResourceCommandError
from yardstick.common.task_template import finalize_for_yaml
from yardstick.common.utils import validate_non_string_sequence
from yardstick.network_services.nfvi.collectd import AmqpConsumer
+from yardstick.benchmark.contexts import heat
LOG = logging.getLogger(__name__)
@@ -52,7 +53,8 @@ class ResourceProfile(object):
DEFAULT_TIMEOUT = 3600
OVS_SOCKET_PATH = "/usr/local/var/run/openvswitch/db.sock"
- def __init__(self, mgmt, port_names=None, plugins=None, interval=None, timeout=None):
+ def __init__(self, mgmt, port_names=None, plugins=None,
+ interval=None, timeout=None, reset_mq_flag=True):
if plugins is None:
self.plugins = {}
@@ -77,6 +79,7 @@ class ResourceProfile(object):
# we need to save mgmt so we can connect to port 5672
self.mgmt = mgmt
self.connection = ssh.AutoConnectSSH.from_node(mgmt)
+ self._reset_mq_flag = reset_mq_flag
@classmethod
def make_from_node(cls, node, timeout):
@@ -87,7 +90,10 @@ class ResourceProfile(object):
plugins = collectd_options.get("plugins", {})
interval = collectd_options.get("interval")
- return cls(node, plugins=plugins, interval=interval, timeout=timeout)
+ reset_mq_flag = (False if node.get("ctx_type") == heat.HeatContext.__context_type__
+ else True)
+ return cls(node, plugins=plugins, interval=interval,
+ timeout=timeout, reset_mq_flag=reset_mq_flag)
def check_if_system_agent_running(self, process):
""" verify if system agent is running """
@@ -210,11 +216,14 @@ class ResourceProfile(object):
if not self.enable:
return {}
+ if self.check_if_system_agent_running("collectd")[0] != 0:
+ return {}
+
metric = {}
while not self._queue.empty():
metric.update(self._queue.get())
- msg = self.parse_collectd_result(metric)
- return msg
+
+ return self.parse_collectd_result(metric)
def _provide_config_file(self, config_file_path, nfvi_cfg, template_kwargs):
template = pkg_resources.resource_string("yardstick.network_services.nfvi",
@@ -250,7 +259,7 @@ class ResourceProfile(object):
if status != 0:
LOG.error("cannot find OVS socket %s", socket_path)
- def _start_rabbitmq(self, connection):
+ def _reset_rabbitmq(self, connection):
# Reset amqp queue
LOG.debug("reset and setup amqp to collect data from collectd")
# ensure collectd.conf.d exists to avoid error/warning
@@ -263,10 +272,37 @@ class ResourceProfile(object):
"sudo rabbitmqctl authenticate_user admin admin",
"sudo rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'"
]
+
for cmd in cmd_list:
- exit_status, stdout, stderr = connection.execute(cmd)
- if exit_status != 0:
- raise ResourceCommandError(command=cmd, stderr=stderr)
+ exit_status, _, stderr = connection.execute(cmd)
+ if exit_status != 0:
+ raise ResourceCommandError(command=cmd, stderr=stderr)
+
+ def _check_rabbitmq_user(self, connection, user='admin'):
+ exit_status, stdout, _ = connection.execute("sudo rabbitmqctl list_users")
+ if exit_status == 0:
+ for line in stdout.split('\n')[1:]:
+ if line.split('\t')[0] == user:
+ return True
+
+ def _set_rabbitmq_admin_user(self, connection):
+ LOG.debug("add admin user to amqp")
+ cmd_list = ["sudo rabbitmqctl add_user admin admin",
+ "sudo rabbitmqctl authenticate_user admin admin",
+ "sudo rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'"
+ ]
+
+ for cmd in cmd_list:
+ exit_status, stdout, stderr = connection.execute(cmd)
+ if exit_status != 0:
+ raise ResourceCommandError(command=cmd, stdout=stdout, stderr=stderr)
+
+ def _start_rabbitmq(self, connection):
+ if self._reset_mq_flag:
+ self._reset_rabbitmq(connection)
+ else:
+ if not self._check_rabbitmq_user(connection):
+ self._set_rabbitmq_admin_user(connection)
# check stdout for "sudo rabbitmqctl status" command
cmd = "sudo rabbitmqctl status"
@@ -282,10 +318,11 @@ class ResourceProfile(object):
self._prepare_collectd_conf(config_file_path)
connection.execute('sudo pkill -x -9 collectd')
- exit_status = connection.execute("which %s > /dev/null 2>&1" % collectd_path)[0]
+ cmd = "which %s > /dev/null 2>&1" % collectd_path
+ exit_status, _, stderr = connection.execute(cmd)
if exit_status != 0:
- LOG.warning("%s is not present disabling", collectd_path)
- return
+ raise ResourceCommandError(command=cmd, stderr=stderr)
+
if "ovs_stats" in self.plugins:
self._setup_ovs_stats(connection)
@@ -293,8 +330,12 @@ class ResourceProfile(object):
LOG.debug("Start collectd service..... %s second timeout", self.timeout)
# intel_pmu plug requires large numbers of files open, so try to set
# ulimit -n to a large value
- connection.execute("sudo bash -c 'ulimit -n 1000000 ; %s'" % collectd_path,
- timeout=self.timeout)
+
+ cmd = "sudo bash -c 'ulimit -n 1000000 ; %s'" % collectd_path
+ exit_status, _, stderr = connection.execute(cmd, timeout=self.timeout)
+ if exit_status != 0:
+ raise ResourceCommandError(command=cmd, stderr=stderr)
+
LOG.debug("Done")
def initiate_systemagent(self, bin_path):
@@ -334,5 +375,7 @@ class ResourceProfile(object):
if pid:
self.connection.execute('sudo kill -9 "%s"' % pid)
self.connection.execute('sudo pkill -9 "%s"' % agent)
- self.connection.execute('sudo service rabbitmq-server stop')
- self.connection.execute("sudo rabbitmqctl stop_app")
+
+ if self._reset_mq_flag:
+ self.connection.execute('sudo service rabbitmq-server stop')
+ self.connection.execute("sudo rabbitmqctl stop_app")
diff --git a/yardstick/network_services/vnf_generic/vnf/prox_vnf.py b/yardstick/network_services/vnf_generic/vnf/prox_vnf.py
index 63295c2e6..bc810ecb3 100644
--- a/yardstick/network_services/vnf_generic/vnf/prox_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/prox_vnf.py
@@ -21,6 +21,7 @@ from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxDpdkVnfS
from yardstick.network_services.vnf_generic.vnf.prox_helpers import ProxResourceHelper
from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNF
from yardstick.network_services import constants
+from yardstick.benchmark.contexts import base as context_base
LOG = logging.getLogger(__name__)
@@ -68,13 +69,19 @@ class ProxApproxVnf(SampleVNF):
def collect_kpi(self):
# we can't get KPIs if the VNF is down
check_if_process_failed(self._vnf_process, 0.01)
+
+ physical_node = context_base.Context.get_physical_node_from_server(
+ self.scenario_helper.nodes[self.name])
+
+ result = {"physical_node": physical_node}
+
if self.resource_helper is None:
- result = {
+ result.update({
"packets_in": 0,
"packets_dropped": 0,
"packets_fwd": 0,
"collect_stats": {"core": {}},
- }
+ })
return result
if (self.tsc_hz == 0):
@@ -90,34 +97,36 @@ class ProxApproxVnf(SampleVNF):
"1, 2 or 4 ports only supported at this time")
all_port_stats = self.vnf_execute('multi_port_stats', range(port_count))
- rx_total = tx_total = 0
+ rx_total = tx_total = tsc = 0
try:
for single_port_stats in all_port_stats:
rx_total = rx_total + single_port_stats[1]
tx_total = tx_total + single_port_stats[2]
- tsc = single_port_stats[5]
+ tsc = tsc + single_port_stats[5]
except (TypeError, IndexError):
LOG.error("Invalid data ...")
return {}
- result = {
+ tsc = tsc / port_count
+
+ result.update({
"packets_in": rx_total,
"packets_dropped": max((tx_total - rx_total), 0),
"packets_fwd": tx_total,
# we share ProxResourceHelper with TG, but we want to collect
# collectd KPIs here and not TG KPIs, so use a different method name
"collect_stats": self.resource_helper.collect_collectd_kpi(),
- }
+ })
try:
curr_packets_in = int(((rx_total - self.prev_packets_in) * self.tsc_hz)
- / (tsc - self.prev_tsc) * port_count)
+ / (tsc - self.prev_tsc))
except ZeroDivisionError:
LOG.error("Error.... Divide by Zero")
curr_packets_in = 0
try:
curr_packets_fwd = int(((tx_total - self.prev_packets_sent) * self.tsc_hz)
- / (tsc - self.prev_tsc) * port_count)
+ / (tsc - self.prev_tsc))
except ZeroDivisionError:
LOG.error("Error.... Divide by Zero")
curr_packets_fwd = 0
diff --git a/yardstick/network_services/vnf_generic/vnf/router_vnf.py b/yardstick/network_services/vnf_generic/vnf/router_vnf.py
index aea27ffa6..90b7b215e 100644
--- a/yardstick/network_services/vnf_generic/vnf/router_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/router_vnf.py
@@ -47,7 +47,6 @@ class RouterVNF(SampleVNF):
def instantiate(self, scenario_cfg, context_cfg):
self.scenario_helper.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.nfvi_context = Context.get_context_from_server(self.scenario_helper.nodes[self.name])
self.configure_routes(self.name, scenario_cfg, context_cfg)
def wait_for_instantiate(self):
@@ -107,8 +106,11 @@ class RouterVNF(SampleVNF):
stdout = self.ssh_helper.execute(ip_link_stats)[1]
link_stats = self.get_stats(stdout)
# get RX/TX from link_stats and assign to results
+ physical_node = Context.get_physical_node_from_server(
+ self.scenario_helper.nodes[self.name])
result = {
+ "physical_node": physical_node,
"packets_in": 0,
"packets_dropped": 0,
"packets_fwd": 0,
diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
index 3976acb76..1ee71aa25 100644
--- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
@@ -39,7 +39,7 @@ from yardstick.network_services.vnf_generic.vnf.base import GenericTrafficGen
from yardstick.network_services.vnf_generic.vnf.base import GenericVNF
from yardstick.network_services.vnf_generic.vnf.base import QueueFileWrapper
from yardstick.network_services.vnf_generic.vnf.vnf_ssh_helper import VnfSshHelper
-
+from yardstick.benchmark.contexts.node import NodeContext
LOG = logging.getLogger(__name__)
@@ -319,6 +319,7 @@ class ResourceHelper(object):
self.resource = None
self.setup_helper = setup_helper
self.ssh_helper = setup_helper.ssh_helper
+ self._enable = True
def setup(self):
self.resource = self.setup_helper.setup_vnf_environment()
@@ -326,22 +327,33 @@ class ResourceHelper(object):
def generate_cfg(self):
pass
+ def update_from_context(self, context, attr_name):
+ """Disable resource helper in case of baremetal context.
+
+ And update appropriate node collectd options in context
+ """
+ if isinstance(context, NodeContext):
+ self._enable = False
+ context.update_collectd_options_for_node(self.setup_helper.collectd_options,
+ attr_name)
+
def _collect_resource_kpi(self):
result = {}
status = self.resource.check_if_system_agent_running("collectd")[0]
- if status == 0:
+ if status == 0 and self._enable:
result = self.resource.amqp_collect_nfvi_kpi()
result = {"core": result}
return result
def start_collect(self):
- self.resource.initiate_systemagent(self.ssh_helper.bin_path)
- self.resource.start()
- self.resource.amqp_process_for_nfvi_kpi()
+ if self._enable:
+ self.resource.initiate_systemagent(self.ssh_helper.bin_path)
+ self.resource.start()
+ self.resource.amqp_process_for_nfvi_kpi()
def stop_collect(self):
- if self.resource:
+ if self.resource and self._enable:
self.resource.stop()
def collect_kpi(self):
@@ -631,7 +643,6 @@ class SampleVNF(GenericVNF):
self.resource_helper = resource_helper_type(self.setup_helper)
self.context_cfg = None
- self.nfvi_context = None
self.pipeline_kwargs = {}
self.uplink_ports = None
self.downlink_ports = None
@@ -658,8 +669,10 @@ class SampleVNF(GenericVNF):
self._update_collectd_options(scenario_cfg, context_cfg)
self.scenario_helper.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.nfvi_context = Context.get_context_from_server(self.scenario_helper.nodes[self.name])
- # self.nfvi_context = None
+ self.resource_helper.update_from_context(
+ Context.get_context_from_server(self.scenario_helper.nodes[self.name]),
+ self.scenario_helper.nodes[self.name]
+ )
# vnf deploy is unsupported, use ansible playbooks
if self.scenario_helper.options.get("vnf_deploy", False):
@@ -813,15 +826,18 @@ class SampleVNF(GenericVNF):
check_if_process_failed(self._vnf_process, 0.01)
stats = self.get_stats()
m = re.search(self.COLLECT_KPI, stats, re.MULTILINE)
+ physical_node = Context.get_physical_node_from_server(
+ self.scenario_helper.nodes[self.name])
+
+ result = {"physical_node": physical_node}
if m:
- result = {k: int(m.group(v)) for k, v in self.COLLECT_MAP.items()}
+ result.update({k: int(m.group(v)) for k, v in self.COLLECT_MAP.items()})
result["collect_stats"] = self.resource_helper.collect_kpi()
else:
- result = {
- "packets_in": 0,
- "packets_fwd": 0,
- "packets_dropped": 0,
- }
+ result.update({"packets_in": 0,
+ "packets_fwd": 0,
+ "packets_dropped": 0})
+
LOG.debug("%s collect KPIs %s", self.APP_NAME, result)
return result
@@ -867,6 +883,11 @@ class SampleVNFTrafficGen(GenericTrafficGen):
def instantiate(self, scenario_cfg, context_cfg):
self.scenario_helper.scenario_cfg = scenario_cfg
+ self.resource_helper.update_from_context(
+ Context.get_context_from_server(self.scenario_helper.nodes[self.name]),
+ self.scenario_helper.nodes[self.name]
+ )
+
self.resource_helper.setup()
# must generate_cfg after DPDK bind because we need port number
self.resource_helper.generate_cfg()
@@ -921,9 +942,14 @@ class SampleVNFTrafficGen(GenericTrafficGen):
def collect_kpi(self):
# check if the tg processes have exited
+ physical_node = Context.get_physical_node_from_server(
+ self.scenario_helper.nodes[self.name])
+
+ result = {"physical_node": physical_node}
for proc in (self._tg_process, self._traffic_process):
check_if_process_failed(proc)
- result = self.resource_helper.collect_kpi()
+
+ result["collect_stats"] = self.resource_helper.collect_kpi()
LOG.debug("%s collect KPIs %s", self.APP_NAME, result)
return result
diff --git a/yardstick/network_services/vnf_generic/vnf/udp_replay.py b/yardstick/network_services/vnf_generic/vnf/udp_replay.py
index a57f53bc7..fa92744d8 100644
--- a/yardstick/network_services/vnf_generic/vnf/udp_replay.py
+++ b/yardstick/network_services/vnf_generic/vnf/udp_replay.py
@@ -19,7 +19,7 @@ from yardstick.common.process import check_if_process_failed
from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNF
from yardstick.network_services.vnf_generic.vnf.sample_vnf import DpdkVnfSetupEnvHelper
from yardstick.network_services.vnf_generic.vnf.sample_vnf import ClientResourceHelper
-
+from yardstick.benchmark.contexts import base as ctx_base
LOG = logging.getLogger(__name__)
@@ -79,9 +79,11 @@ class UdpReplayApproxVnf(SampleVNF):
ports_mask_hex = hex(sum(2 ** num for num in port_nums))
# one core extra for master
cpu_mask_hex = hex(2 ** (number_of_ports + 1) - 1)
+ nfvi_context = ctx_base.Context.get_context_from_server(
+ self.scenario_helper.nodes[self.name])
hw_csum = ""
if (not self.scenario_helper.options.get('hw_csum', False) or
- self.nfvi_context.attrs.get('nfvi_type') not in self.HW_OFFLOADING_NFVI_TYPES):
+ nfvi_context.attrs.get('nfvi_type') not in self.HW_OFFLOADING_NFVI_TYPES):
hw_csum = '--no-hw-csum'
# tuples of (FLD_PORT, FLD_QUEUE, FLD_LCORE)
@@ -116,7 +118,12 @@ class UdpReplayApproxVnf(SampleVNF):
stats = self.get_stats()
stats_words = stats.split()
split_stats = stats_words[stats_words.index('0'):][:number_of_ports * 5]
+
+ physical_node = ctx_base.Context.get_physical_node_from_server(
+ self.scenario_helper.nodes[self.name])
+
result = {
+ "physical_node": physical_node,
"packets_in": get_sum(1),
"packets_fwd": get_sum(2),
"packets_dropped": get_sum(3) + get_sum(4),
diff --git a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
index 9deef5cfa..bfff45c67 100644
--- a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
@@ -28,6 +28,7 @@ from yardstick.common.process import check_if_process_failed
from yardstick.network_services.helpers.samplevnf_helper import PortPairs
from yardstick.network_services.pipeline import PipelineRules
from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNF, DpdkVnfSetupEnvHelper
+from yardstick.benchmark.contexts import base as ctx_base
LOG = logging.getLogger(__name__)
@@ -302,7 +303,11 @@ class VpeApproxVnf(SampleVNF):
def collect_kpi(self):
# we can't get KPIs if the VNF is down
check_if_process_failed(self._vnf_process)
+ physical_node = ctx_base.Context.get_physical_node_from_server(
+ self.scenario_helper.nodes[self.name])
+
result = {
+ "physical_node": physical_node,
'pkt_in_up_stream': 0,
'pkt_drop_up_stream': 0,
'pkt_in_down_stream': 0,
diff --git a/yardstick/tests/unit/benchmark/contexts/test_base.py b/yardstick/tests/unit/benchmark/contexts/test_base.py
index 8f1cbcc55..1e63b4831 100644
--- a/yardstick/tests/unit/benchmark/contexts/test_base.py
+++ b/yardstick/tests/unit/benchmark/contexts/test_base.py
@@ -25,6 +25,8 @@ from yardstick.common.constants import YARDSTICK_ROOT_PATH
class DummyContextClass(Context):
+ __context_type__ = "Dummy"
+
def __init__(self, host_name_separator='.'):
super(DummyContextClass, self).__init__\
(host_name_separator=host_name_separator)
diff --git a/yardstick/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py
index d02a34d24..f6a0bdcc1 100644
--- a/yardstick/tests/unit/common/test_openstack_utils.py
+++ b/yardstick/tests/unit/common/test_openstack_utils.py
@@ -7,11 +7,13 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from oslo_utils import uuidutils
-import unittest
+import os
+
import mock
+from oslo_utils import uuidutils
import shade
from shade import exc
+import unittest
from yardstick.common import constants
from yardstick.common import openstack_utils
@@ -28,11 +30,12 @@ class GetCredentialsTestCase(unittest.TestCase):
class GetHeatApiVersionTestCase(unittest.TestCase):
- def test_get_heat_api_version_check_result(self):
+ @mock.patch.object(openstack_utils, 'log')
+ def test_get_heat_api_version_check_result(self, *args):
API = 'HEAT_API_VERSION'
expected_result = '2'
- with mock.patch.dict('os.environ', {API: '2'}, clear=True):
+ with mock.patch.dict(os.environ, {API: '2'}, clear=True):
api_version = openstack_utils.get_heat_api_version()
self.assertEqual(api_version, expected_result)
@@ -277,6 +280,12 @@ class CreateSecurityGroupRuleTestCase(unittest.TestCase):
self.mock_shade_client = mock.Mock()
self.secgroup_name_or_id = 'sg_name_id'
self.mock_shade_client.create_security_group_rule = mock.Mock()
+ self._mock_log = mock.patch.object(openstack_utils, 'log')
+ self.mock_log = self._mock_log.start()
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_log.stop()
def test_create_security_group_rule(self):
self.mock_shade_client.create_security_group_rule.return_value = (
@@ -285,14 +294,13 @@ class CreateSecurityGroupRuleTestCase(unittest.TestCase):
self.mock_shade_client, self.secgroup_name_or_id)
self.assertTrue(output)
- @mock.patch.object(openstack_utils, 'log')
- def test_create_security_group_rule_exception(self, mock_logger):
+ def test_create_security_group_rule_exception(self):
self.mock_shade_client.create_security_group_rule.side_effect = (
exc.OpenStackCloudException('error message'))
output = openstack_utils.create_security_group_rule(
self.mock_shade_client, self.secgroup_name_or_id)
- mock_logger.error.assert_called_once()
+ self.mock_log.error.assert_called_once()
self.assertFalse(output)
@@ -321,6 +329,12 @@ class SecurityGroupTestCase(unittest.TestCase):
self.sg_name = 'sg_name'
self.sg_description = 'sg_description'
self._uuid = uuidutils.generate_uuid()
+ self._mock_log = mock.patch.object(openstack_utils, 'log')
+ self.mock_log = self._mock_log.start()
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_log.stop()
def test_create_security_group_full_existing_security_group(self):
self.mock_shade_client.get_security_group.return_value = (
@@ -330,21 +344,18 @@ class SecurityGroupTestCase(unittest.TestCase):
self.mock_shade_client.get_security_group.assert_called_once()
self.assertEqual(self._uuid, output)
- @mock.patch.object(openstack_utils, 'log')
- def test_create_security_group_full_non_existing_security_group(
- self, mock_logger):
+ def test_create_security_group_full_non_existing_security_group(self):
self.mock_shade_client.get_security_group.return_value = None
self.mock_shade_client.create_security_group.side_effect = (
exc.OpenStackCloudException('error message'))
output = openstack_utils.create_security_group_full(
self.mock_shade_client, self.sg_name, self.sg_description)
- mock_logger.error.assert_called_once()
+ self.mock_log.error.assert_called_once()
self.assertIsNone(output)
@mock.patch.object(openstack_utils, 'create_security_group_rule')
- @mock.patch.object(openstack_utils, 'log')
def test_create_security_group_full_create_rule_fail(
- self, mock_logger, mock_create_security_group_rule):
+ self, mock_create_security_group_rule):
self.mock_shade_client.get_security_group.return_value = None
self.mock_shade_client.create_security_group.return_value = (
{'name': 'name', 'id': self._uuid})
@@ -353,7 +364,7 @@ class SecurityGroupTestCase(unittest.TestCase):
self.mock_shade_client, self.sg_name, self.sg_description)
mock_create_security_group_rule.assert_called()
self.mock_shade_client.delete_security_group(self.sg_name)
- mock_logger.error.assert_called_once()
+ self.mock_log.error.assert_called_once()
self.assertIsNone(output)
@mock.patch.object(openstack_utils, 'create_security_group_rule')
@@ -369,10 +380,6 @@ class SecurityGroupTestCase(unittest.TestCase):
self.mock_shade_client.delete_security_group(self.sg_name)
self.assertEqual(self._uuid, output)
-# *********************************************
-# NOVA
-# *********************************************
-
class CreateInstanceTestCase(unittest.TestCase):
@@ -543,10 +550,6 @@ class GetFlavorTestCase(unittest.TestCase):
mock_logger.error.assert_called_once()
self.assertIsNone(output)
-# *********************************************
-# CINDER
-# *********************************************
-
class GetVolumeIDTestCase(unittest.TestCase):
@@ -664,22 +667,23 @@ class DetachVolumeTestCase(unittest.TestCase):
self.assertFalse(output)
-# *********************************************
-# GLANCE
-# *********************************************
-
class CreateImageTestCase(unittest.TestCase):
def setUp(self):
self.mock_shade_client = mock.Mock()
self._uuid = uuidutils.generate_uuid()
self.name = 'image_name'
+ self._mock_log = mock.patch.object(openstack_utils, 'log')
+ self.mock_log = self._mock_log.start()
+ self.addCleanup(self._stop_mock)
- @mock.patch.object(openstack_utils, 'log')
- def test_create_image_already_exit(self, mock_logger):
+ def _stop_mock(self):
+ self._mock_log.stop()
+
+ def test_create_image_already_exit(self):
self.mock_shade_client.get_image_id.return_value = self._uuid
output = openstack_utils.create_image(self.mock_shade_client, self.name)
- mock_logger.info.assert_called_once()
+ self.mock_log.info.assert_called_once()
self.assertEqual(self._uuid, output)
def test_create_image(self):
@@ -688,15 +692,14 @@ class CreateImageTestCase(unittest.TestCase):
output = openstack_utils.create_image(self.mock_shade_client, self.name)
self.assertEqual(self._uuid, output)
- @mock.patch.object(openstack_utils, 'log')
- def test_create_image_exception(self, mock_logger):
+ def test_create_image_exception(self):
self.mock_shade_client.get_image_id.return_value = None
self.mock_shade_client.create_image.side_effect = (
exc.OpenStackCloudException('error message'))
output = openstack_utils.create_image(self.mock_shade_client,
self.name)
- mock_logger.error.assert_called_once()
+ self.mock_log.error.assert_called_once()
self.assertIsNone(output)
diff --git a/yardstick/tests/unit/common/test_process.py b/yardstick/tests/unit/common/test_process.py
index 1c6dfec27..e0933c6ac 100644
--- a/yardstick/tests/unit/common/test_process.py
+++ b/yardstick/tests/unit/common/test_process.py
@@ -90,10 +90,11 @@ class ExecuteTestCase(unittest.TestCase):
additional_env=self.additional_env)
self.assertEqual(self.stdout, out)
- def test_execute_exception(self):
+ @mock.patch.object(process, 'LOG')
+ def test_execute_exception(self, *args):
self.obj.returncode = self.RET_CODE_WRONG
- self.assertRaises(exceptions.ProcessExecutionError, process.execute,
- self.input_cmd, additional_env=self.additional_env)
+ with self.assertRaises(exceptions.ProcessExecutionError):
+ process.execute(self.input_cmd, additional_env=self.additional_env)
self.obj.communicate.assert_called_once_with(None)
def test_execute_with_extra_code(self):
@@ -107,7 +108,8 @@ class ExecuteTestCase(unittest.TestCase):
additional_env=self.additional_env)
self.assertEqual(self.stdout, out)
- def test_execute_exception_no_check(self):
+ @mock.patch.object(process, 'LOG')
+ def test_execute_exception_no_check(self, *args):
self.obj.returncode = self.RET_CODE_WRONG
out = process.execute(self.input_cmd,
additional_env=self.additional_env,
diff --git a/yardstick/tests/unit/network_services/collector/test_subscriber.py b/yardstick/tests/unit/network_services/collector/test_subscriber.py
index 14e26f7fe..4271f852c 100644
--- a/yardstick/tests/unit/network_services/collector/test_subscriber.py
+++ b/yardstick/tests/unit/network_services/collector/test_subscriber.py
@@ -38,6 +38,15 @@ class MockVnfAprrox(object):
class CollectorTestCase(unittest.TestCase):
+ NODES = {'context1': [{'name': 'node1',
+ 'ip': '1.2.3.4',
+ 'collectd': {
+ 'plugins': {'abc': 12, 'def': 34},
+ 'interval': 987
+ },
+ }]
+ }
+
def setUp(self):
vnf = MockVnfAprrox()
vnf.start_collect = mock.Mock()
@@ -47,30 +56,46 @@ class CollectorTestCase(unittest.TestCase):
mock_instance = mock.Mock()
mock_instance.execute.return_value = 0, '', ''
mock_ssh.from_node.return_value = mock_instance
- self.collector = subscriber.Collector([vnf])
+ self.collector = subscriber.Collector([vnf], self.NODES)
def tearDown(self):
self.ssh_patch.stop()
def test___init__(self, *_):
vnf = MockVnfAprrox()
- collector = subscriber.Collector([vnf])
+ collector = subscriber.Collector([vnf], self.NODES)
self.assertEqual(len(collector.vnfs), 1)
+ self.assertEqual(len(collector.nodes), 1)
def test_start(self, *_):
+ resource_profile = mock.MagicMock()
+ self.collector.resource_profiles = {'key': resource_profile}
+ self.collector.bin_path = 'path'
+
self.assertIsNone(self.collector.start())
for vnf in self.collector.vnfs:
vnf.start_collect.assert_called_once()
+ for resource_profile in self.collector.resource_profiles.values():
+ resource_profile.initiate_systemagent.assert_called_once_with('path')
+ resource_profile.start.assert_called_once()
+ resource_profile.amqp_process_for_nfvi_kpi.assert_called_once()
+
def test_stop(self, *_):
+ resource_profile = mock.MagicMock()
+ self.collector.resource_profiles = {'key': resource_profile}
+
self.assertIsNone(self.collector.stop())
for vnf in self.collector.vnfs:
vnf.stop_collect.assert_called_once()
+ for resource in self.collector.resource_profiles.values():
+ resource.stop.assert_called_once()
+
def test_get_kpi(self, *_):
result = self.collector.get_kpi()
- self.assertEqual(1, len(result))
+ self.assertEqual(2, len(result))
self.assertEqual(4, len(result["vnf__1"]))
self.assertEqual(result["vnf__1"]["pkt_in_up_stream"], 100)
self.assertEqual(result["vnf__1"]["pkt_drop_up_stream"], 5)
diff --git a/yardstick/tests/unit/network_services/nfvi/test_resource.py b/yardstick/tests/unit/network_services/nfvi/test_resource.py
index de9679456..c06658218 100644
--- a/yardstick/tests/unit/network_services/nfvi/test_resource.py
+++ b/yardstick/tests/unit/network_services/nfvi/test_resource.py
@@ -18,6 +18,7 @@ import mock
import unittest
from yardstick.common import exceptions
+from yardstick.common.exceptions import ResourceCommandError
from yardstick.network_services.nfvi.resource import ResourceProfile
from yardstick.network_services.nfvi import resource, collectd
@@ -139,18 +140,38 @@ class TestResourceProfile(unittest.TestCase):
self.resource_profile._start_collectd(ssh_mock, "/opt/nsb_bin")
ssh_mock.execute = mock.Mock(return_value=(1, "", ""))
- self.assertIsNone(self.resource_profile._start_collectd(ssh_mock,
- "/opt/nsb_bin"))
+ with self.assertRaises(ResourceCommandError):
+ self.resource_profile._start_collectd(ssh_mock, "/opt/nsb_bin")
+
+ def test__reset_rabbitmq(self):
+ ssh_mock = mock.Mock()
+ ssh_mock.execute = mock.Mock(return_value=(1, "", ""))
+ with self.assertRaises(exceptions.ResourceCommandError):
+ self.resource_profile._reset_rabbitmq(ssh_mock)
+
+ def test__check_rabbitmq_user(self):
+ ssh_mock = mock.Mock()
+ ssh_mock.execute = mock.Mock(return_value=(0, "title\nadmin\t[]", ""))
+ self.assertTrue(self.resource_profile._check_rabbitmq_user(ssh_mock))
+
+ def test__set_rabbitmq_admin_user(self):
+ ssh_mock = mock.Mock()
+ ssh_mock.execute = mock.Mock(return_value=(1, "", ""))
+ with self.assertRaises(exceptions.ResourceCommandError):
+ self.resource_profile._set_rabbitmq_admin_user(ssh_mock)
def test__start_rabbitmq(self):
ssh_mock = mock.Mock()
- ssh_mock.execute = mock.Mock(return_value=(0, "RabbitMQ", ""))
- self.assertIsNone(self.resource_profile._start_rabbitmq(ssh_mock))
+ self.resource_profile._reset_rabbitmq = mock.Mock()
+ self.resource_profile._set_rabbitmq_admin_user = mock.Mock()
- ssh_mock.execute = mock.Mock(return_value=(0, "", ""))
+ self.resource_profile._reset_mq_flag = True
+ ssh_mock.execute = mock.Mock(return_value=(1, "", ""))
with self.assertRaises(exceptions.ResourceCommandError):
self.resource_profile._start_rabbitmq(ssh_mock)
+ self.resource_profile._reset_mq_flag = False
+ self.resource_profile._check_rabbitmq_user = mock.Mock(return_value=False)
ssh_mock.execute = mock.Mock(return_value=(1, "", ""))
with self.assertRaises(exceptions.ResourceCommandError):
self.resource_profile._start_rabbitmq(ssh_mock)
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/acl_1rule.yaml b/yardstick/tests/unit/network_services/vnf_generic/vnf/acl_1rule.yaml
deleted file mode 100644
index b184a29e2..000000000
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/acl_1rule.yaml
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (c) 2016-2017 Intel Corporation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-access-list1:
- acl:
- access-list-entries:
- - ace:
- ace-oper-data:
- match-counter: 0
- actions: drop,count
- matches:
- destination-ipv4-network: 152.16.40.20/24
- destination-port-range:
- lower-port: 0
- upper-port: 65535
- source-ipv4-network: 0.0.0.0/0
- source-port-range:
- lower-port: 0
- upper-port: 65535
- rule-name: rule1588
- - ace:
- ace-oper-data:
- match-counter: 0
- actions: drop,count
- matches:
- destination-ipv4-network: 0.0.0.0/0
- destination-port-range:
- lower-port: 0
- upper-port: 65535
- source-ipv4-network: 152.16.100.20/24
- source-port-range:
- lower-port: 0
- upper-port: 65535
- rule-name: rule1589
- acl-name: sample-ipv4-acl
- acl-type: ipv4-acl
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
index ce32a31e2..f04d2c617 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py
@@ -23,6 +23,7 @@ from yardstick.tests import STL_MOCKS
from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from yardstick.common import utils
from yardstick.common import exceptions
+from yardstick.benchmark.contexts import base as ctx_base
STLClient = mock.MagicMock()
@@ -30,7 +31,7 @@ stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
stl_patch.start()
if stl_patch:
- from yardstick.network_services.vnf_generic.vnf.acl_vnf import AclApproxVnf
+ from yardstick.network_services.vnf_generic.vnf import acl_vnf
from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
from yardstick.network_services.nfvi.resource import ResourceProfile
from yardstick.network_services.vnf_generic.vnf.acl_vnf import AclApproxSetupEnvSetupEnvHelper
@@ -146,7 +147,7 @@ class TestAclApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens513f0',
- 'vld_id': AclApproxVnf.DOWNLINK,
+ 'vld_id': acl_vnf.AclApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -174,7 +175,7 @@ class TestAclApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens785f0',
- 'vld_id': AclApproxVnf.UPLINK,
+ 'vld_id': acl_vnf.AclApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -199,7 +200,7 @@ class TestAclApproxVnf(unittest.TestCase):
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens786f0',
- 'vld_id': AclApproxVnf.UPLINK,
+ 'vld_id': acl_vnf.AclApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -209,7 +210,7 @@ class TestAclApproxVnf(unittest.TestCase):
'vpci': '0000:05:00.0',
'dpdk_port_num': 0},
'xe1': {'local_iface_name': 'ens786f1',
- 'vld_id': AclApproxVnf.DOWNLINK,
+ 'vld_id': acl_vnf.AclApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
@@ -245,22 +246,31 @@ class TestAclApproxVnf(unittest.TestCase):
def test___init__(self, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- acl_approx_vnf = AclApproxVnf(name, vnfd)
+ acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
self.assertIsNone(acl_approx_vnf._vnf_process)
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
def test_collect_kpi(self, ssh, *args):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- acl_approx_vnf = AclApproxVnf(name, vnfd)
+ acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
+ acl_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {acl_approx_vnf.name: "mock"}
+ }
acl_approx_vnf.q_in = mock.MagicMock()
acl_approx_vnf.q_out = mock.MagicMock()
acl_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
acl_approx_vnf.resource = mock.Mock(autospec=ResourceProfile)
acl_approx_vnf.vnf_execute = mock.Mock(return_value="")
- result = {'packets_dropped': 0, 'packets_fwd': 0, 'packets_in': 0}
+ result = {
+ 'physical_node': 'mock_node',
+ 'packets_dropped': 0,
+ 'packets_fwd': 0,
+ 'packets_in': 0
+ }
self.assertEqual(result, acl_approx_vnf.collect_kpi())
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@@ -269,7 +279,7 @@ class TestAclApproxVnf(unittest.TestCase):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- acl_approx_vnf = AclApproxVnf(name, vnfd)
+ acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
acl_approx_vnf.q_in = mock.MagicMock()
acl_approx_vnf.q_out = mock.MagicMock()
acl_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
@@ -281,7 +291,7 @@ class TestAclApproxVnf(unittest.TestCase):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- acl_approx_vnf = AclApproxVnf(name, vnfd)
+ acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
acl_approx_vnf.q_in = mock.MagicMock()
acl_approx_vnf.q_out = mock.MagicMock()
acl_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
@@ -302,7 +312,7 @@ class TestAclApproxVnf(unittest.TestCase):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- acl_approx_vnf = AclApproxVnf(name, vnfd)
+ acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
acl_approx_vnf._build_config = mock.MagicMock()
acl_approx_vnf.queue_wrapper = mock.MagicMock()
acl_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg
@@ -322,7 +332,7 @@ class TestAclApproxVnf(unittest.TestCase):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- acl_approx_vnf = AclApproxVnf(name, vnfd)
+ acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
acl_approx_vnf.deploy_helper = mock.MagicMock()
acl_approx_vnf.resource_helper = mock.MagicMock()
acl_approx_vnf._build_config = mock.MagicMock()
@@ -340,7 +350,7 @@ class TestAclApproxVnf(unittest.TestCase):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- acl_approx_vnf = AclApproxVnf(name, vnfd)
+ acl_approx_vnf = acl_vnf.AclApproxVnf(name, vnfd)
acl_approx_vnf._vnf_process = mock.MagicMock()
acl_approx_vnf._vnf_process.terminate = mock.Mock()
acl_approx_vnf.used_drivers = {"01:01.0": "i40e",
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
index 6b6f3ef34..635ca41a2 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
@@ -322,9 +322,13 @@ class TestCgnaptApproxVnf(unittest.TestCase):
self.assertIsNone(cgnapt_approx_vnf._vnf_process)
@mock.patch.object(process, 'check_if_process_failed')
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
def test_collect_kpi(self, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
cgnapt_approx_vnf = cgnapt_vnf.CgnaptApproxVnf(name, vnfd)
+ cgnapt_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {cgnapt_approx_vnf.name: "mock"}
+ }
cgnapt_approx_vnf._vnf_process = mock.MagicMock(
**{"is_alive.return_value": True, "exitcode": None})
cgnapt_approx_vnf.q_in = mock.MagicMock()
@@ -332,7 +336,12 @@ class TestCgnaptApproxVnf(unittest.TestCase):
cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
cgnapt_approx_vnf.resource = mock.Mock(
autospec=resource.ResourceProfile)
- result = {'packets_dropped': 0, 'packets_fwd': 0, 'packets_in': 0}
+ result = {
+ 'physical_node': 'mock_node',
+ 'packets_dropped': 0,
+ 'packets_fwd': 0,
+ 'packets_in': 0
+ }
with mock.patch.object(cgnapt_approx_vnf, 'get_stats',
return_value=''):
self.assertEqual(result, cgnapt_approx_vnf.collect_kpi())
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
index b23854e9f..678e58056 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py
@@ -20,6 +20,7 @@ import mock
from copy import deepcopy
from yardstick.tests import STL_MOCKS
+from yardstick.benchmark.contexts import base as ctx_base
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -29,7 +30,7 @@ stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
stl_patch.start()
if stl_patch:
- from yardstick.network_services.vnf_generic.vnf.prox_vnf import ProxApproxVnf
+ from yardstick.network_services.vnf_generic.vnf import prox_vnf
from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
@@ -187,7 +188,7 @@ class TestProxApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens513f0',
- 'vld_id': ProxApproxVnf.DOWNLINK,
+ 'vld_id': prox_vnf.ProxApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.20',
'dst_mac': '00:00:00:00:00:01',
@@ -221,7 +222,7 @@ class TestProxApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens785f0',
- 'vld_id': ProxApproxVnf.UPLINK,
+ 'vld_id': prox_vnf.ProxApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.20',
'dst_mac': '00:00:00:00:00:02',
@@ -252,7 +253,7 @@ class TestProxApproxVnf(unittest.TestCase):
'interfaces': {
'xe0': {
'local_iface_name': 'ens786f0',
- 'vld_id': ProxApproxVnf.UPLINK,
+ 'vld_id': prox_vnf.ProxApproxVnf.UPLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.100.19',
'dst_mac': '00:00:00:00:00:04',
@@ -264,7 +265,7 @@ class TestProxApproxVnf(unittest.TestCase):
},
'xe1': {
'local_iface_name': 'ens786f1',
- 'vld_id': ProxApproxVnf.DOWNLINK,
+ 'vld_id': prox_vnf.ProxApproxVnf.DOWNLINK,
'netmask': '255.255.255.0',
'local_ip': '152.16.40.19',
'dst_mac': '00:00:00:00:00:03',
@@ -316,16 +317,21 @@ class TestProxApproxVnf(unittest.TestCase):
@mock.patch(SSH_HELPER)
def test___init__(self, ssh, *args):
mock_ssh(ssh)
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
self.assertIsNone(prox_approx_vnf._vnf_process)
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
def test_collect_kpi_no_client(self, ssh, *args):
mock_ssh(ssh)
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {prox_approx_vnf.name: "mock"}
+ }
prox_approx_vnf.resource_helper = None
expected = {
+ 'physical_node': 'mock_node',
'packets_in': 0,
'packets_dropped': 0,
'packets_fwd': 0,
@@ -334,6 +340,7 @@ class TestProxApproxVnf(unittest.TestCase):
result = prox_approx_vnf.collect_kpi()
self.assertEqual(result, expected)
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
def test_collect_kpi(self, ssh, *args):
mock_ssh(ssh)
@@ -343,10 +350,14 @@ class TestProxApproxVnf(unittest.TestCase):
[2, 1, 2, 3, 4, 5], [3, 1, 2, 3, 4, 5]]
resource_helper.collect_collectd_kpi.return_value = {'core': {'result': 234}}
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {prox_approx_vnf.name: "mock"}
+ }
prox_approx_vnf.resource_helper = resource_helper
expected = {
+ 'physical_node': 'mock_node',
'packets_in': 4,
'packets_dropped': 4,
'packets_fwd': 8,
@@ -359,13 +370,16 @@ class TestProxApproxVnf(unittest.TestCase):
self.assertNotEqual(result['packets_fwd'], 0)
self.assertNotEqual(result['packets_fwd'], 0)
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
def test_collect_kpi_error(self, ssh, *args):
mock_ssh(ssh)
resource_helper = mock.MagicMock()
-
- prox_approx_vnf = ProxApproxVnf(NAME, deepcopy(self.VNFD0))
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, deepcopy(self.VNFD0))
+ prox_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {prox_approx_vnf.name: "mock"}
+ }
prox_approx_vnf.resource_helper = resource_helper
prox_approx_vnf.vnfd_helper['vdu'][0]['external-interface'] = []
prox_approx_vnf.vnfd_helper.port_pairs.interfaces = []
@@ -385,7 +399,7 @@ class TestProxApproxVnf(unittest.TestCase):
def test_run_prox(self, ssh, *_):
mock_ssh(ssh)
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
prox_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG
prox_approx_vnf.ssh_helper.join_bin_path.return_value = '/tool_path12/tool_file34'
prox_approx_vnf.setup_helper.remote_path = 'configs/file56.cfg'
@@ -399,7 +413,7 @@ class TestProxApproxVnf(unittest.TestCase):
@mock.patch(SSH_HELPER)
def bad_test_instantiate(self, *args):
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
prox_approx_vnf.scenario_helper = mock.MagicMock()
prox_approx_vnf.setup_helper = mock.MagicMock()
# we can't mock super
@@ -409,7 +423,7 @@ class TestProxApproxVnf(unittest.TestCase):
@mock.patch(SSH_HELPER)
def test_wait_for_instantiate_panic(self, ssh, *args):
mock_ssh(ssh, exec_result=(1, "", ""))
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
prox_approx_vnf._vnf_process = mock.MagicMock(**{"is_alive.return_value": True})
prox_approx_vnf._run_prox = mock.Mock(return_value=0)
prox_approx_vnf.WAIT_TIME = 0
@@ -421,7 +435,7 @@ class TestProxApproxVnf(unittest.TestCase):
@mock.patch(SSH_HELPER)
def test_terminate(self, ssh, *args):
mock_ssh(ssh)
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
prox_approx_vnf._vnf_process = mock.MagicMock()
prox_approx_vnf._vnf_process.terminate = mock.Mock()
prox_approx_vnf.ssh_helper = mock.MagicMock()
@@ -433,7 +447,7 @@ class TestProxApproxVnf(unittest.TestCase):
@mock.patch(SSH_HELPER)
def test__vnf_up_post(self, ssh, *args):
mock_ssh(ssh)
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
prox_approx_vnf.resource_helper = resource_helper = mock.Mock()
prox_approx_vnf._vnf_up_post()
@@ -442,7 +456,7 @@ class TestProxApproxVnf(unittest.TestCase):
@mock.patch(SSH_HELPER)
def test_vnf_execute_oserror(self, ssh, *args):
mock_ssh(ssh)
- prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+ prox_approx_vnf = prox_vnf.ProxApproxVnf(NAME, self.VNFD0)
prox_approx_vnf.resource_helper = resource_helper = mock.Mock()
resource_helper.execute.side_effect = OSError(errno.EPIPE, "")
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py
index 5574c6770..edd0ff796 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_router_vnf.py
@@ -18,6 +18,7 @@ import mock
from yardstick.tests import STL_MOCKS
from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.benchmark.contexts import base as ctx_base
STLClient = mock.MagicMock()
@@ -214,15 +215,25 @@ class TestRouterVNF(unittest.TestCase):
stats = RouterVNF.get_stats(self.IP_SHOW_STATS_OUTPUT)
self.assertDictEqual(stats, self.STATS)
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@mock.patch(SSH_HELPER)
- def test_collect_kpi(self, ssh, _):
+ def test_collect_kpi(self, ssh, *args):
m = mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
router_vnf = RouterVNF(name, vnfd)
+ router_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {router_vnf.name: "mock"}
+ }
router_vnf.ssh_helper = m
- result = {'packets_dropped': 0, 'packets_fwd': 0, 'packets_in': 0, 'link_stats': {}}
+ result = {
+ 'physical_node': 'mock_node',
+ 'packets_dropped': 0,
+ 'packets_fwd': 0,
+ 'packets_in': 0,
+ 'link_stats': {}
+ }
self.assertEqual(result, router_vnf.collect_kpi())
@mock.patch(SSH_HELPER)
@@ -235,9 +246,9 @@ class TestRouterVNF(unittest.TestCase):
router_vnf._run()
router_vnf.ssh_helper.drop_connection.assert_called_once()
- @mock.patch("yardstick.network_services.vnf_generic.vnf.router_vnf.Context")
+ @mock.patch.object(ctx_base, 'Context')
@mock.patch(SSH_HELPER)
- def test_instantiate(self, ssh, _):
+ def test_instantiate(self, ssh, *args):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
index ce849d174..331e80d00 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py
@@ -18,7 +18,6 @@ import unittest
import mock
import six
-from yardstick.benchmark.contexts.base import Context
from yardstick.common import exceptions as y_exceptions
from yardstick.common import utils
from yardstick.network_services.nfvi.resource import ResourceProfile
@@ -35,6 +34,7 @@ from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNF
from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNFTrafficGen
from yardstick.network_services.vnf_generic.vnf.sample_vnf import DpdkVnfSetupEnvHelper
from yardstick.tests.unit.network_services.vnf_generic.vnf import test_base
+from yardstick.benchmark.contexts import base as ctx_base
class MockError(Exception):
@@ -1533,33 +1533,20 @@ class TestSampleVnf(unittest.TestCase):
self.assertIsNotNone(sample_vnf.queue_wrapper)
self.assertIsNotNone(sample_vnf._vnf_process)
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context')
@mock.patch("yardstick.ssh.SSH")
- def test_instantiate(self, ssh):
+ def test_instantiate(self, ssh, *args):
test_base.mock_ssh(ssh)
-
nodes = {
'vnf1': 'name1',
'vnf2': 'name2',
}
- context1 = mock.Mock()
- context1._get_server.return_value = None
- context2 = mock.Mock()
- context2._get_server.return_value = context2
-
- try:
- Context.list.clear()
- except AttributeError:
- # clear() but works in Py2.7
- Context.list[:] = []
-
- Context.list.extend([
- context1,
- context2,
- ])
-
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
sample_vnf = SampleVNF('vnf1', vnfd)
+ sample_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {sample_vnf.name: 'mock'}
+ }
sample_vnf.APP_NAME = 'sample1'
sample_vnf._start_server = mock.Mock(return_value=0)
sample_vnf._vnf_process = mock.MagicMock()
@@ -1572,7 +1559,6 @@ class TestSampleVnf(unittest.TestCase):
}
self.assertIsNone(sample_vnf.instantiate(scenario_cfg, {}))
- self.assertEqual(sample_vnf.nfvi_context, context2)
def test__update_collectd_options(self):
scenario_cfg = {'options':
@@ -1709,9 +1695,13 @@ class TestSampleVnf(unittest.TestCase):
self.assertEqual(sample_vnf.get_stats(), 'the stats')
- def test_collect_kpi(self):
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
+ def test_collect_kpi(self, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
sample_vnf = SampleVNF('vnf1', vnfd)
+ sample_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {sample_vnf.name: "mock"}
+ }
sample_vnf.APP_NAME = 'sample1'
sample_vnf.COLLECT_KPI = r'\s(\d+)\D*(\d+)\D*(\d+)'
sample_vnf.COLLECT_MAP = {
@@ -1728,18 +1718,24 @@ class TestSampleVnf(unittest.TestCase):
'k2': 34,
'k3': 91,
'collect_stats': {},
+ 'physical_node': 'mock_node'
}
result = sample_vnf.collect_kpi()
self.assertDictEqual(result, expected)
- def test_collect_kpi_default(self):
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
+ def test_collect_kpi_default(self, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
sample_vnf = SampleVNF('vnf1', vnfd)
+ sample_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {sample_vnf.name: "mock"}
+ }
sample_vnf.APP_NAME = 'sample1'
sample_vnf.COLLECT_KPI = r'\s(\d+)\D*(\d+)\D*(\d+)'
sample_vnf.get_stats = mock.Mock(return_value='')
expected = {
+ 'physical_node': 'mock_node',
'packets_in': 0,
'packets_fwd': 0,
'packets_dropped': 0,
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
index 59594a3c3..6858cf70a 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py
@@ -22,6 +22,7 @@ import unittest
from yardstick import ssh
from yardstick.common import utils
from yardstick.tests import STL_MOCKS
+from yardstick.benchmark.contexts import base as ctx_base
STLClient = mock.MagicMock()
@@ -137,17 +138,26 @@ class TestIxLoadTrafficGen(unittest.TestCase):
ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
self.assertIsNone(ixload_traffic_gen.resource_helper.data)
- def test_collect_kpi(self):
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
+ def test_collect_kpi(self, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
mock.Mock(return_value=(0, "", ""))
ssh.from_node.return_value = ssh_mock
+
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
+ ixload_traffic_gen.scenario_helper.scenario_cfg = {
+ 'nodes': {ixload_traffic_gen.name: "mock"}
+ }
ixload_traffic_gen.data = {}
restult = ixload_traffic_gen.collect_kpi()
- self.assertEqual({}, restult)
+ expected = {
+ 'physical_node': 'mock_node',
+ 'collect_stats': {},
+ }
+ self.assertEqual(expected, restult)
def test_listen_traffic(self):
with mock.patch("yardstick.ssh.SSH") as ssh:
@@ -161,8 +171,10 @@ class TestIxLoadTrafficGen(unittest.TestCase):
@mock.patch.object(utils, 'find_relative_file')
@mock.patch.object(utils, 'makedirs')
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server')
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.shutil")
- def test_instantiate(self, *args):
+ def test_instantiate(self, shutil, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
@@ -176,6 +188,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
'ixia_profile': "ixload.cfg",
'task_path': "/path/to/task"}
ixload_traffic_gen.RESULTS_MOUNT = "/tmp/result"
+ shutil.copy = mock.Mock()
scenario_cfg.update({'options': {'packetsize': 64, 'traffic_type': 4,
'rfc2544': {'allowed_drop_rate': '0.8 - 1'},
'vnf__1': {'rules': 'acl_1rule.yaml',
@@ -185,17 +198,21 @@ class TestIxLoadTrafficGen(unittest.TestCase):
'1C/1T',
'worker_threads': 1}}
}})
+ scenario_cfg.update({
+ 'nodes': {ixload_traffic_gen.name: "mock"}
+ })
with mock.patch.object(six.moves.builtins, 'open',
create=True) as mock_open:
mock_open.return_value = mock.MagicMock()
ixload_traffic_gen.instantiate(scenario_cfg, {})
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.open")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.min")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.max")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.len")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.shutil")
- def test_run_traffic(self, *args):
+ def test_run_traffic(self, shutil, *args):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -216,15 +233,17 @@ class TestIxLoadTrafficGen(unittest.TestCase):
sut.connection = mock.Mock()
sut.connection.run = mock.Mock()
sut._traffic_runner = mock.Mock(return_value=0)
+ shutil.copy = mock.Mock()
result = sut.run_traffic(mock_traffic_profile)
self.assertIsNone(result)
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.open")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.min")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.max")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.len")
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.shutil")
- def test_run_traffic_csv(self, *args):
+ def test_run_traffic_csv(self, shutil, *args):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -245,6 +264,7 @@ class TestIxLoadTrafficGen(unittest.TestCase):
sut.connection = mock.Mock()
sut.connection.run = mock.Mock()
sut._traffic_runner = mock.Mock(return_value=0)
+ shutil.copy = mock.Mock()
subprocess.call(["touch", "/tmp/1.csv"])
sut.rel_bin_path = mock.Mock(return_value="/tmp/*.csv")
result = sut.run_traffic(mock_traffic_profile)
@@ -257,8 +277,9 @@ class TestIxLoadTrafficGen(unittest.TestCase):
ixload_traffic_gen = IxLoadTrafficGen(NAME, vnfd)
self.assertIsNone(ixload_traffic_gen.terminate())
- @mock.patch("yardstick.ssh.SSH")
- def test_parse_csv_read(self, mock_ssh):
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
+ @mock.patch.object(ssh, 'SSH')
+ def test_parse_csv_read(self, mock_ssh, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
kpi_data = {
'HTTP Total Throughput (Kbps)': 1,
@@ -280,8 +301,9 @@ class TestIxLoadTrafficGen(unittest.TestCase):
for key_left, key_right in IxLoadResourceHelper.KPI_LIST.items():
self.assertEqual(result[key_left][-1], int(kpi_data[key_right]))
- @mock.patch("yardstick.ssh.SSH")
- def test_parse_csv_read_value_error(self, mock_ssh):
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
+ @mock.patch.object(ssh, 'SSH')
+ def test_parse_csv_read_value_error(self, mock_ssh, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
http_reader = [{
'HTTP Total Throughput (Kbps)': 1,
@@ -301,8 +323,9 @@ class TestIxLoadTrafficGen(unittest.TestCase):
ixload_traffic_gen.resource_helper.parse_csv_read(http_reader)
self.assertDictEqual(ixload_traffic_gen.resource_helper.result, init_value)
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ixload.call")
@mock.patch.object(ssh, 'SSH')
- def test_parse_csv_read_error(self, mock_ssh):
+ def test_parse_csv_read_error(self, mock_ssh, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
http_reader = [{
'HTTP Total Throughput (Kbps)': 1,
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
index 14e0db788..d774bb9f7 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
@@ -21,6 +21,7 @@ import unittest
from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from yardstick.tests import STL_MOCKS
+from yardstick.benchmark.contexts import base as ctx_base
SSH_HELPER = "yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper"
@@ -253,14 +254,25 @@ class TestPingTrafficGen(unittest.TestCase):
self.assertNotEqual(ext_ifs[0]['virtual-interface']['local_iface_name'], 'if_name_1')
self.assertNotEqual(ext_ifs[1]['virtual-interface']['local_iface_name'], 'if_name_2')
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch("yardstick.ssh.SSH")
- def test_collect_kpi(self, ssh):
+ def test_collect_kpi(self, ssh, *args):
mock_ssh(ssh, exec_result=(0, "success", ""))
+
ping_traffic_gen = PingTrafficGen('vnf1', self.VNFD_0)
+ ping_traffic_gen.scenario_helper.scenario_cfg = {
+ 'nodes': {ping_traffic_gen.name: "mock"}
+ }
ping_traffic_gen._queue = Queue()
ping_traffic_gen._queue.put({})
- ping_traffic_gen.collect_kpi()
- self.assertEqual(ping_traffic_gen._result, {})
+ expected = {
+ 'physical_node': 'mock_node',
+ 'collect_stats': {}
+ }
+ # NOTE: Why we check _result but not collect_kpi() return value
+ # self.assertEqual(ping_traffic_gen._result, {})
+ self.assertEqual(ping_traffic_gen.collect_kpi(), expected)
+
@mock.patch(SSH_HELPER)
def test_instantiate(self, ssh):
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
index f581ec8d9..050aa4aa0 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py
@@ -18,6 +18,7 @@ import mock
from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from yardstick.tests import STL_MOCKS
+from yardstick.benchmark.contexts import base as ctx_base
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -324,15 +325,22 @@ class TestProxTrafficGen(unittest.TestCase):
self.assertIsNone(prox_traffic_gen._tg_process)
self.assertIsNone(prox_traffic_gen._traffic_process)
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
def test_collect_kpi(self, ssh, *args):
mock_ssh(ssh)
-
prox_traffic_gen = ProxTrafficGen(NAME, self.VNFD0)
+ prox_traffic_gen.scenario_helper.scenario_cfg = {
+ 'nodes': {prox_traffic_gen.name: "mock"}
+ }
prox_traffic_gen._vnf_wrapper.resource_helper.resource = mock.MagicMock(
**{"self.check_if_system_agent_running.return_value": [False]})
prox_traffic_gen._vnf_wrapper.vnf_execute = mock.Mock(return_value="")
- self.assertEqual({}, prox_traffic_gen.collect_kpi())
+ expected = {
+ 'collect_stats': {},
+ 'physical_node': 'mock_node'
+ }
+ self.assertEqual(prox_traffic_gen.collect_kpi(), expected)
@mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.find_relative_file')
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
index dca8098fa..42ac40b50 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py
@@ -21,6 +21,7 @@ import unittest
from yardstick.network_services.libs.ixia_libs.ixnet import ixnet_api
from yardstick.network_services.traffic_profile import base as tp_base
from yardstick.network_services.vnf_generic.vnf import tg_rfc2544_ixia
+from yardstick.benchmark.contexts import base as ctx_base
TEST_FILE_YAML = 'nsb_test_case.yaml'
@@ -186,6 +187,7 @@ class TestIXIATrafficGen(unittest.TestCase):
ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd)
self.assertIsNone(ixnet_traffic_gen.listen_traffic({}))
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context')
def test_instantiate(self, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
@@ -212,6 +214,9 @@ class TestIXIATrafficGen(unittest.TestCase):
'lb_count': 1,
'worker_config': '1C/1T',
'worker_threads': 1}}}})
+ scenario_cfg.update({
+ 'nodes': {ixnet_traffic_gen.name: "mock"}
+ })
ixnet_traffic_gen.topology = ""
ixnet_traffic_gen.get_ixobj = mock.MagicMock()
ixnet_traffic_gen._ixia_traffic_gen = mock.MagicMock()
@@ -220,17 +225,26 @@ class TestIXIATrafficGen(unittest.TestCase):
IOError,
ixnet_traffic_gen.instantiate(scenario_cfg, {}))
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
def test_collect_kpi(self, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
mock.Mock(return_value=(0, "", ""))
ssh.from_node.return_value = ssh_mock
+
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
ixnet_traffic_gen = tg_rfc2544_ixia.IxiaTrafficGen(NAME, vnfd)
+ ixnet_traffic_gen.scenario_helper.scenario_cfg = {
+ 'nodes': {ixnet_traffic_gen.name: "mock"}
+ }
ixnet_traffic_gen.data = {}
restult = ixnet_traffic_gen.collect_kpi()
- self.assertEqual({}, restult)
+
+ expected = {'collect_stats': {},
+ 'physical_node': 'mock_node'}
+
+ self.assertEqual(expected, restult)
def test_terminate(self, *args):
with mock.patch("yardstick.ssh.SSH") as ssh:
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
index 9531b90c4..4d3e4ff0b 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
@@ -18,6 +18,7 @@ import unittest
from yardstick.network_services.traffic_profile import base as tp_base
from yardstick.network_services.vnf_generic.vnf import sample_vnf
from yardstick.network_services.vnf_generic.vnf import tg_rfc2544_trex
+from yardstick.benchmark.contexts import base as ctx_base
class TestTrexRfcResouceHelper(unittest.TestCase):
@@ -224,7 +225,20 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC('vnf1', self.VNFD_0)
self.assertIsNotNone(trex_traffic_gen.resource_helper._terminated.value)
- def test_instantiate(self):
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
+ def test_collect_kpi(self, *args):
+ trex_traffic_gen = tg_rfc2544_trex.TrexTrafficGenRFC('vnf1', self.VNFD_0)
+ trex_traffic_gen.scenario_helper.scenario_cfg = {
+ 'nodes': {trex_traffic_gen.name: "mock"}
+ }
+ expected = {
+ 'physical_node': 'mock_node',
+ 'collect_stats': {},
+ }
+ self.assertEqual(trex_traffic_gen.collect_kpi(), expected)
+
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context')
+ def test_instantiate(self, *args):
mock_traffic_profile = mock.Mock(autospec=tp_base.TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -255,10 +269,11 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
},
}
tg_rfc2544_trex.WAIT_TIME = 3
- scenario_cfg.update({"nodes": ["tg_1", "vnf_1"]})
+ scenario_cfg.update({"nodes": {"tg_1": {}, "vnf1": {}}})
self.assertIsNone(trex_traffic_gen.instantiate(scenario_cfg, {}))
- def test_instantiate_error(self):
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context')
+ def test_instantiate_error(self, *args):
mock_traffic_profile = mock.Mock(autospec=tp_base.TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -268,10 +283,10 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
trex_traffic_gen.setup_helper.setup_vnf_environment = mock.MagicMock()
scenario_cfg = {
"tc": "tc_baremetal_rfc2544_ipv4_1flow_64B",
- "nodes": [
- "tg_1",
- "vnf_1",
- ],
+ "nodes": {
+ "tg_1": {},
+ "vnf1": {}
+ },
"topology": 'nsb_test_case.yaml',
'options': {
'packetsize': 64,
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
index 4f8742477..350ba8448 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
@@ -21,9 +21,10 @@ from yardstick.network_services.traffic_profile import base as tp_base
from yardstick.network_services.traffic_profile import rfc2544
from yardstick.network_services.vnf_generic.vnf import sample_vnf
from yardstick.network_services.vnf_generic.vnf import tg_trex
+from yardstick.benchmark.contexts import base as ctx_base
-NAME = 'vnf_1'
+NAME = 'vnf__1'
class TestTrexTrafficGen(unittest.TestCase):
@@ -303,19 +304,28 @@ class TestTrexTrafficGen(unittest.TestCase):
self.assertIsInstance(trex_traffic_gen.resource_helper,
tg_trex.TrexResourceHelper)
- def test_collect_kpi(self):
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
+ def test_collect_kpi(self, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd)
+ trex_traffic_gen.scenario_helper.scenario_cfg = {
+ 'nodes': {trex_traffic_gen.name: "mock"}
+ }
trex_traffic_gen.resource_helper._queue.put({})
result = trex_traffic_gen.collect_kpi()
- self.assertEqual({}, result)
+ expected = {
+ 'physical_node': 'mock_node',
+ 'collect_stats': {}
+ }
+ self.assertEqual(expected, result)
def test_listen_traffic(self):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd)
self.assertIsNone(trex_traffic_gen.listen_traffic({}))
- def test_instantiate(self):
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context')
+ def test_instantiate(self, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd)
trex_traffic_gen._start_server = mock.Mock(return_value=0)
@@ -329,7 +339,8 @@ class TestTrexTrafficGen(unittest.TestCase):
self.assertIsNone(trex_traffic_gen.instantiate(self.SCENARIO_CFG,
self.CONTEXT_CFG))
- def test_instantiate_error(self):
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server', return_value='fake_context')
+ def test_instantiate_error(self, *args):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
trex_traffic_gen = tg_trex.TrexTrafficGen(NAME, vnfd)
trex_traffic_gen._start_server = mock.Mock(return_value=0)
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
index 05a0ead71..1c4ced303 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py
@@ -19,6 +19,7 @@ import os
from yardstick.tests import STL_MOCKS
from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
+from yardstick.benchmark.contexts import base as ctx_base
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -330,6 +331,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
self.assertIsNone(udp_replay_approx_vnf._vnf_process)
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
def test_collect_kpi(self, ssh, *args):
mock_ssh(ssh)
@@ -341,14 +343,21 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
"0\t\t7374156\t\t7374136\t\t\t0\t\t\t0\r\n" \
"1\t\t7374316\t\t7374315\t\t\t0\t\t\t0\r\n\r\nReplay>\r\r\nReplay>"
udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, vnfd)
+ udp_replay_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {udp_replay_approx_vnf.name: "mock"}
+ }
udp_replay_approx_vnf.q_in = mock.MagicMock()
udp_replay_approx_vnf.q_out = mock.MagicMock()
udp_replay_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
udp_replay_approx_vnf.all_ports = ["xe0", "xe1"]
udp_replay_approx_vnf.get_stats = mock.Mock(return_value=get_stats_ret_val)
-
- result = {'collect_stats': {}, 'packets_dropped': 0,
- 'packets_fwd': 14748451, 'packets_in': 14748472}
+ result = {
+ 'physical_node': 'mock_node',
+ 'collect_stats': {},
+ 'packets_dropped': 0,
+ 'packets_fwd': 14748451,
+ 'packets_in': 14748472
+ }
self.assertEqual(result, udp_replay_approx_vnf.collect_kpi())
@mock.patch(SSH_HELPER)
@@ -372,14 +381,18 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
file_path = os.path.join(curr_path, filename)
return file_path
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server')
@mock.patch(SSH_HELPER)
- def test__build_config(self, ssh, mock_context, *args):
+ def test__build_config(self, ssh, mock_get_ctx, *args):
mock_ssh(ssh)
+ nfvi_context = mock.Mock()
+ nfvi_context.attrs = {'nfvi_type': 'baremetal'}
+ mock_get_ctx.return_value = nfvi_context
+
udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
udp_replay_approx_vnf.queue_wrapper = mock.MagicMock()
- udp_replay_approx_vnf.nfvi_context = mock_context
+ udp_replay_approx_vnf.nfvi_context = mock_get_ctx
udp_replay_approx_vnf.nfvi_context.attrs = {'nfvi_type': 'baremetal'}
udp_replay_approx_vnf.setup_helper.bound_pci = []
udp_replay_approx_vnf.ssh_helper.provision_tool = mock.MagicMock(return_value="tool_path")
@@ -393,13 +406,16 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
self.assertEqual(cmd_line, expected)
@mock.patch('yardstick.network_services.vnf_generic.vnf.udp_replay.open')
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server')
@mock.patch(SSH_HELPER)
- def test__build_pipeline_kwargs(self, ssh, mock_context, *args):
+ def test__build_pipeline_kwargs(self, ssh, mock_get_ctx, *args):
mock_ssh(ssh)
+
+ nfvi_context = mock.Mock()
+ nfvi_context.attrs = {'nfvi_type': "baremetal"}
+ mock_get_ctx.return_value = nfvi_context
+
udp_replay_approx_vnf = UdpReplayApproxVnf(NAME, self.VNFD_0)
- udp_replay_approx_vnf.nfvi_context = mock_context
- udp_replay_approx_vnf.nfvi_context.attrs = {'nfvi_type': 'baremetal'}
udp_replay_approx_vnf.setup_helper.bound_pci = ['0000:00:0.1', '0000:00:0.3']
udp_replay_approx_vnf.all_ports = ["xe0", "xe1"]
udp_replay_approx_vnf.ssh_helper.provision_tool = mock.MagicMock(return_value="tool_path")
@@ -430,7 +446,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
udp_replay_approx_vnf.ssh_helper.run.assert_called_once()
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server')
@mock.patch(SSH_HELPER)
def test_instantiate(self, ssh, *args):
mock_ssh(ssh)
@@ -449,7 +465,7 @@ class TestUdpReplayApproxVnf(unittest.TestCase):
self.assertEqual(udp_replay_approx_vnf.wait_for_instantiate(), 0)
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server')
@mock.patch('yardstick.ssh.SSH')
@mock.patch(SSH_HELPER)
def test_instantiate_panic(self, *args):
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
index a0a0794ea..b67a3cdee 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py
@@ -21,7 +21,7 @@ from yardstick.tests import STL_MOCKS
from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from yardstick.common import utils
-
+from yardstick.benchmark.contexts import base as ctx_base
STLClient = mock.MagicMock()
stl_patch = mock.patch.dict("sys.modules", STL_MOCKS)
@@ -259,12 +259,15 @@ pipeline>
""" # noqa
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
def test_collect_kpi(self, ssh, *args):
mock_ssh(ssh)
-
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
vfw_approx_vnf = FWApproxVnf(name, vnfd)
+ vfw_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {vfw_approx_vnf.name: "mock"}
+ }
vfw_approx_vnf.q_in = mock.MagicMock()
vfw_approx_vnf.q_out = mock.MagicMock()
vfw_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
@@ -273,6 +276,7 @@ pipeline>
**{'collect_kpi.return_value': {"core": {}}})
vfw_approx_vnf.vnf_execute = mock.Mock(return_value=self.STATS)
result = {
+ 'physical_node': 'mock_node',
'packets_dropped': 0,
'packets_fwd': 6007180,
'packets_in': 6007180,
@@ -334,7 +338,7 @@ pipeline>
vfw_approx_vnf.ssh_helper.run.assert_called_once()
@mock.patch.object(utils, 'find_relative_file')
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
+ @mock.patch.object(ctx_base.Context, 'get_context_from_server')
@mock.patch(SSH_HELPER)
def test_instantiate(self, ssh, *args):
mock_ssh(ssh)
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
index 73f91d1b1..f91852f74 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
@@ -26,6 +26,7 @@ from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import File
from yardstick.tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from yardstick.network_services.vnf_generic.vnf.base import QueueFileWrapper
from yardstick.network_services.vnf_generic.vnf.base import VnfdHelper
+from yardstick.benchmark.contexts import base as ctx_base
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
@@ -547,8 +548,9 @@ class TestVpeApproxVnf(unittest.TestCase):
vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
self.assertIsNone(vpe_approx_vnf._vnf_process)
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
- def test_collect_kpi_sa_not_running(self, ssh):
+ def test_collect_kpi_sa_not_running(self, ssh, *args):
mock_ssh(ssh)
resource = mock.Mock(autospec=ResourceProfile)
@@ -557,12 +559,16 @@ class TestVpeApproxVnf(unittest.TestCase):
resource.check_if_system_agent_running.return_value = (1, None)
vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {vpe_approx_vnf.name: "mock"}
+ }
vpe_approx_vnf.q_in = mock.MagicMock()
vpe_approx_vnf.q_out = mock.MagicMock()
vpe_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
vpe_approx_vnf.resource_helper.resource = resource
expected = {
+ 'physical_node': 'mock_node',
'pkt_in_down_stream': 0,
'pkt_in_up_stream': 0,
'pkt_drop_down_stream': 0,
@@ -571,8 +577,9 @@ class TestVpeApproxVnf(unittest.TestCase):
}
self.assertEqual(vpe_approx_vnf.collect_kpi(), expected)
+ @mock.patch.object(ctx_base.Context, 'get_physical_node_from_server', return_value='mock_node')
@mock.patch(SSH_HELPER)
- def test_collect_kpi_sa_running(self, ssh):
+ def test_collect_kpi_sa_running(self, ssh, *args):
mock_ssh(ssh)
resource = mock.Mock(autospec=ResourceProfile)
@@ -580,12 +587,16 @@ class TestVpeApproxVnf(unittest.TestCase):
resource.amqp_collect_nfvi_kpi.return_value = {'foo': 234}
vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0)
+ vpe_approx_vnf.scenario_helper.scenario_cfg = {
+ 'nodes': {vpe_approx_vnf.name: "mock"}
+ }
vpe_approx_vnf.q_in = mock.MagicMock()
vpe_approx_vnf.q_out = mock.MagicMock()
vpe_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
vpe_approx_vnf.resource_helper.resource = resource
expected = {
+ 'physical_node': 'mock_node',
'pkt_in_down_stream': 0,
'pkt_in_up_stream': 0,
'pkt_drop_down_stream': 0,
@@ -634,7 +645,6 @@ class TestVpeApproxVnf(unittest.TestCase):
self.assertIsNone(vpe_approx_vnf._run())
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig")
- @mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
@mock.patch("yardstick.network_services.vnf_generic.vnf.vpe_vnf.ConfigCreate")
@mock.patch("six.moves.builtins.open")
@mock.patch(SSH_HELPER)