aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docker/Dockerfile2
-rw-r--r--docker/Dockerfile.aarch64.patch2
-rw-r--r--samples/vnf_samples/nsut/prox/tc_prox_ovs_l2fwd-4.yaml109
-rw-r--r--samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd-4.yaml99
-rw-r--r--samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd_pktTouch-2.yaml83
-rw-r--r--samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd_pktTouch-4.yaml99
-rw-r--r--yardstick/benchmark/contexts/standalone/ovs_dpdk.py7
-rw-r--r--yardstick/benchmark/contexts/standalone/sriov.py4
-rw-r--r--yardstick/benchmark/scenarios/storage/storperf.py37
-rw-r--r--yardstick/common/utils.py17
-rw-r--r--yardstick/network_services/vnf_generic/vnf/sample_vnf.py17
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py23
-rw-r--r--yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py14
-rw-r--r--yardstick/tests/unit/common/test_utils.py17
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py47
15 files changed, 489 insertions, 88 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index d594b46b9..29319e056 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -26,7 +26,7 @@ ENV YARDSTICK_REPO_DIR="${REPOS_DIR}/yardstick/" \
RUN apt-get update && apt-get install -y git python python-setuptools python-pip iputils-ping && apt-get -y autoremove && apt-get clean
RUN easy_install -U setuptools==30.0.0
-RUN pip install appdirs==1.4.0 pyopenssl==17.5.0 openstacksdk==0.9.17 python-openstackclient==3.12.1 python-heatclient==1.11.1 ansible==2.5.5
+RUN pip install appdirs==1.4.0 pyopenssl==17.5.0 openstacksdk==0.11.3 python-openstackclient==3.14.2 python-heatclient==1.14.0 ansible==2.5.5
RUN mkdir -p ${REPOS_DIR}
diff --git a/docker/Dockerfile.aarch64.patch b/docker/Dockerfile.aarch64.patch
index 6c32404ca..cae9dbb2f 100644
--- a/docker/Dockerfile.aarch64.patch
+++ b/docker/Dockerfile.aarch64.patch
@@ -31,7 +31,7 @@ index 71ce6b58..fce7c116 100644
+RUN apt-get update && apt-get install -y git python python-setuptools python-pip iputils-ping && apt-get -y autoremove && \
+ apt-get install -y libssl-dev && apt-get -y install libffi-dev && apt-get clean
RUN easy_install -U setuptools==30.0.0
- RUN pip install appdirs==1.4.0 pyopenssl==17.5.0 openstacksdk==0.9.17 python-openstackclient==3.12.1 python-heatclient==1.11.1 ansible==2.5.5
+ RUN pip install appdirs==1.4.0 pyopenssl==17.5.0 openstacksdk==0.11.3 python-openstackclient==3.14.2 python-heatclient==1.14.0 ansible==2.5.5
@@ -40,7 +41,8 @@ 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}
diff --git a/samples/vnf_samples/nsut/prox/tc_prox_ovs_l2fwd-4.yaml b/samples/vnf_samples/nsut/prox/tc_prox_ovs_l2fwd-4.yaml
new file mode 100644
index 000000000..f04cb60a5
--- /dev/null
+++ b/samples/vnf_samples/nsut/prox/tc_prox_ovs_l2fwd-4.yaml
@@ -0,0 +1,109 @@
+# Copyright (c) 2016-2018 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.
+
+---
+schema: "yardstick:task:0.1"
+
+scenarios:
+-
+ type: NSPerf
+ traffic_profile: ../../traffic_profiles/prox_binsearch.yaml
+ topology: prox-tg-topology-4.yaml
+
+ nodes:
+ tg__0: tg__0.yardstick
+ vnf__0: vnf__0.yardstick
+
+ options:
+ interface_speed_gbps: 10
+
+ vnf__0:
+ prox_path: /opt/nsb_bin/prox
+ prox_config: "configs/handle_l2fwd-4.cfg"
+ prox_args:
+ "-t": ""
+
+ tg__0:
+ prox_path: /opt/nsb_bin/prox
+ prox_config: "configs/gen_l2fwd-4.cfg"
+ prox_args:
+ "-e": ""
+ "-t": ""
+
+ runner:
+ type: Duration
+ # we kill after duration, independent of test duration, so set this high
+ duration: 300
+
+contexts:
+ - name: yardstick
+ type: Node
+ file: prox_tg_bm.yaml
+ - name: yardstick
+ type: StandaloneOvsDpdk
+ file: /etc/yardstick/nodes/standalone/host_ovs.yaml
+ vm_deploy: True
+ ovs_properties:
+ version:
+ ovs: 2.8.0
+ dpdk: 17.05.2
+ pmd_threads: 2
+ ram:
+ socket_0: 2048
+ socket_1: 2048
+ queues: 4
+ vpath: "/usr/local"
+ flavor:
+ images: "/var/lib/libvirt/images/yardstick-nsb-image.img"
+ ram: 16384
+ extra_specs:
+ hw:cpu_sockets: 1
+ hw:cpu_cores: 10
+ hw:cpu_threads: 2
+ servers:
+ vnf__0:
+ network_ports:
+ mgmt:
+ cidr: '1.1.1.62/24'
+ xe0:
+ - uplink_0
+ xe1:
+ - downlink_0
+ xe2:
+ - uplink_1
+ xe3:
+ - downlink_1
+
+ networks:
+ uplink_0:
+ phy_port: "0000:05:00.0"
+ vpci: "0000:00:0a.0"
+ cidr: '152.16.100.10/24'
+ gateway_ip: '152.16.100.20'
+ downlink_0:
+ phy_port: "0000:05:00.1"
+ vpci: "0000:00:0b.0"
+ cidr: '152.16.40.10/24'
+ gateway_ip: '152.16.100.20'
+ uplink_1:
+ phy_port: "0000:05:00.2"
+ vpci: "0000:00:0c.0"
+ cidr: '152.16.50.10/24'
+ gateway_ip: '152.16.100.20'
+ downlink_1:
+ phy_port: "0000:05:00.3"
+ vpci: "0000:00:0d.0"
+ cidr: '152.16.30.10/24'
+ gateway_ip: '152.16.100.20'
+
diff --git a/samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd-4.yaml b/samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd-4.yaml
new file mode 100644
index 000000000..aeca1cef2
--- /dev/null
+++ b/samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd-4.yaml
@@ -0,0 +1,99 @@
+# Copyright (c) 2016-2018 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.
+
+---
+schema: "yardstick:task:0.1"
+
+scenarios:
+-
+ type: NSPerf
+ traffic_profile: ../../traffic_profiles/prox_binsearch.yaml
+ topology: prox-tg-topology-4.yaml
+
+ nodes:
+ tg__0: tg__0.yardstick
+ vnf__0: vnf__0.yardstick
+
+ options:
+ interface_speed_gbps: 10
+
+ vnf__0:
+ prox_path: /opt/nsb_bin/prox
+ prox_config: "configs/handle_l2fwd-4.cfg"
+ prox_args:
+ "-t": ""
+
+ tg__0:
+ prox_path: /opt/nsb_bin/prox
+ prox_config: "configs/gen_l2fwd-4.cfg"
+ prox_args:
+ "-e": ""
+ "-t": ""
+
+ runner:
+ type: Duration
+ # we kill after duration, independent of test duration, so set this high
+ duration: 300
+
+contexts:
+ - name: yardstick
+ type: Node
+ file: prox_tg_bm.yaml
+ - name: yardstick
+ type: StandaloneSriov
+ file: /etc/yardstick/nodes/standalone/host_sriov.yaml
+ vm_deploy: True
+ flavor:
+ images: "/var/lib/libvirt/images/yardstick-nsb-image.img"
+ ram: 16384
+ extra_specs:
+ hw:cpu_sockets: 1
+ hw:cpu_cores: 10
+ hw:cpu_threads: 2
+ servers:
+ vnf__0:
+ network_ports:
+ mgmt:
+ cidr: '1.1.1.61/24'
+ xe0:
+ - uplink_0
+ xe1:
+ - downlink_0
+ xe2:
+ - uplink_1
+ xe3:
+ - downlink_1
+
+ networks:
+ uplink_0:
+ phy_port: "0000:05:00.0"
+ vpci: "0000:00:0a.0"
+ cidr: '152.16.100.10/24'
+ gateway_ip: '152.16.100.20'
+ downlink_0:
+ phy_port: "0000:05:00.1"
+ vpci: "0000:00:0b.0"
+ cidr: '152.16.40.10/24'
+ gateway_ip: '152.16.100.20'
+ uplink_1:
+ phy_port: "0000:05:00.2"
+ vpci: "0000:00:0c.0"
+ cidr: '152.16.50.10/24'
+ gateway_ip: '152.16.100.20'
+ downlink_1:
+ phy_port: "0000:05:00.3"
+ vpci: "0000:00:0d.0"
+ cidr: '152.16.30.10/24'
+ gateway_ip: '152.16.100.20'
+
diff --git a/samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd_pktTouch-2.yaml b/samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd_pktTouch-2.yaml
new file mode 100644
index 000000000..660fce508
--- /dev/null
+++ b/samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd_pktTouch-2.yaml
@@ -0,0 +1,83 @@
+# Copyright (c) 2016-2018 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.
+
+---
+schema: "yardstick:task:0.1"
+
+scenarios:
+-
+ type: NSPerf
+ traffic_profile: ../../traffic_profiles/prox_binsearch.yaml
+ topology: prox-tg-topology-2.yaml
+
+ nodes:
+ tg__0: tg__0.yardstick
+ vnf__0: vnf__0.yardstick
+
+ options:
+ interface_speed_gbps: 10
+
+ vnf__0:
+ prox_path: /opt/nsb_bin/prox
+ prox_config: "configs/handle_l2fwd_pktTouch-2.cfg"
+ prox_args:
+ "-t": ""
+
+ tg__0:
+ prox_path: /opt/nsb_bin/prox
+ prox_config: "configs/gen_l2fwd_pktTouch-2.cfg"
+ prox_args:
+ "-e": ""
+ "-t": ""
+
+ runner:
+ type: Duration
+ # we kill after duration, independent of test duration, so set this high
+ duration: 300
+
+contexts:
+ - name: yardstick
+ type: Node
+ file: prox_tg_bm.yaml
+ - name: yardstick
+ type: StandaloneSriov
+ file: /etc/yardstick/nodes/standalone/host_sriov.yaml
+ vm_deploy: True
+ flavor:
+ images: "/var/lib/libvirt/images/yardstick-nsb-image.img"
+ ram: 16384
+ extra_specs:
+ hw:cpu_sockets: 1
+ hw:cpu_cores: 10
+ hw:cpu_threads: 2
+ servers:
+ vnf__0:
+ network_ports:
+ mgmt:
+ cidr: '1.1.1.61/24'
+ xe0:
+ - uplink_0
+ xe1:
+ - downlink_0
+ networks:
+ uplink_0:
+ phy_port: "0000:05:00.0"
+ vpci: "0000:00:0a.0"
+ cidr: '152.16.100.10/24'
+ gateway_ip: '152.16.100.20'
+ downlink_0:
+ phy_port: "0000:05:00.1"
+ vpci: "0000:00:0b.0"
+ cidr: '152.16.40.10/24'
+ gateway_ip: '152.16.100.20'
diff --git a/samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd_pktTouch-4.yaml b/samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd_pktTouch-4.yaml
new file mode 100644
index 000000000..1571f2ffe
--- /dev/null
+++ b/samples/vnf_samples/nsut/prox/tc_prox_sriov_l2fwd_pktTouch-4.yaml
@@ -0,0 +1,99 @@
+# Copyright (c) 2016-2018 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.
+
+---
+schema: "yardstick:task:0.1"
+
+scenarios:
+-
+ type: NSPerf
+ traffic_profile: ../../traffic_profiles/prox_binsearch.yaml
+ topology: prox-tg-topology-4.yaml
+
+ nodes:
+ tg__0: tg__0.yardstick
+ vnf__0: vnf__0.yardstick
+
+ options:
+ interface_speed_gbps: 10
+
+ vnf__0:
+ prox_path: /opt/nsb_bin/prox
+ prox_config: "configs/handle_l2fwd_pktTouch-4.cfg"
+ prox_args:
+ "-t": ""
+
+ tg__0:
+ prox_path: /opt/nsb_bin/prox
+ prox_config: "configs/gen_l2fwd_pktTouch-4.cfg"
+ prox_args:
+ "-e": ""
+ "-t": ""
+
+ runner:
+ type: Duration
+ # we kill after duration, independent of test duration, so set this high
+ duration: 300
+
+contexts:
+ - name: yardstick
+ type: Node
+ file: prox_tg_bm.yaml
+ - name: yardstick
+ type: StandaloneSriov
+ file: /etc/yardstick/nodes/standalone/host_sriov.yaml
+ vm_deploy: True
+ flavor:
+ images: "/var/lib/libvirt/images/yardstick-nsb-image.img"
+ ram: 16384
+ extra_specs:
+ hw:cpu_sockets: 1
+ hw:cpu_cores: 10
+ hw:cpu_threads: 2
+ servers:
+ vnf__0:
+ network_ports:
+ mgmt:
+ cidr: '1.1.1.61/24'
+ xe0:
+ - uplink_0
+ xe1:
+ - downlink_0
+ xe2:
+ - uplink_1
+ xe3:
+ - downlink_1
+
+ networks:
+ uplink_0:
+ phy_port: "0000:05:00.0"
+ vpci: "0000:00:0a.0"
+ cidr: '152.16.100.10/24'
+ gateway_ip: '152.16.100.20'
+ downlink_0:
+ phy_port: "0000:05:00.1"
+ vpci: "0000:00:0b.0"
+ cidr: '152.16.40.10/24'
+ gateway_ip: '152.16.100.20'
+ uplink_1:
+ phy_port: "0000:05:00.2"
+ vpci: "0000:00:0c.0"
+ cidr: '152.16.50.10/24'
+ gateway_ip: '152.16.100.20'
+ downlink_1:
+ phy_port: "0000:05:00.3"
+ vpci: "0000:00:0d.0"
+ cidr: '152.16.30.10/24'
+ gateway_ip: '152.16.100.20'
+
diff --git a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
index c2707fd9a..42a275455 100644
--- a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
+++ b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
@@ -24,6 +24,7 @@ from yardstick.benchmark import contexts
from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
from yardstick.common import exceptions
+from yardstick.common import utils as common_utils
from yardstick.network_services import utils
from yardstick.network_services.utils import get_nsb_option
@@ -242,7 +243,6 @@ class OvsDpdkContext(base.Context):
def check_ovs_dpdk_env(self):
self.cleanup_ovs_dpdk_env()
- self._check_hugepages()
version = self.ovs_properties.get("version", {})
ovs_ver = version.get("ovs", self.DEFAULT_OVS)
@@ -398,6 +398,11 @@ class OvsDpdkContext(base.Context):
self.configure_nics_for_ovs_dpdk()
+ hp_total_mb = int(self.vm_flavor.get('ram', '4096')) * len(self.servers)
+ common_utils.setup_hugepages(self.connection, hp_total_mb * 1024)
+
+ self._check_hugepages()
+
for index, (key, vnf) in enumerate(collections.OrderedDict(
self.servers).items()):
cfg = '/tmp/vm_ovs_%d.xml' % index
diff --git a/yardstick/benchmark/contexts/standalone/sriov.py b/yardstick/benchmark/contexts/standalone/sriov.py
index f1b67a2da..e037dd85a 100644
--- a/yardstick/benchmark/contexts/standalone/sriov.py
+++ b/yardstick/benchmark/contexts/standalone/sriov.py
@@ -21,6 +21,7 @@ from yardstick import ssh
from yardstick.benchmark import contexts
from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
+from yardstick.common import utils
from yardstick.network_services.utils import get_nsb_option
from yardstick.network_services.utils import PciAddress
@@ -222,6 +223,9 @@ class SriovContext(base.Context):
# 1 : modprobe host_driver with num_vfs
self.configure_nics_for_sriov()
+ hp_total_mb = int(self.vm_flavor.get('ram', '4096')) * len(self.servers)
+ utils.setup_hugepages(self.connection, hp_total_mb * 1024)
+
for index, (key, vnf) in enumerate(collections.OrderedDict(
self.servers).items()):
cfg = '/tmp/vm_sriov_%s.xml' % str(index)
diff --git a/yardstick/benchmark/scenarios/storage/storperf.py b/yardstick/benchmark/scenarios/storage/storperf.py
index e4c72dc8f..7c8e5fe66 100644
--- a/yardstick/benchmark/scenarios/storage/storperf.py
+++ b/yardstick/benchmark/scenarios/storage/storperf.py
@@ -102,13 +102,14 @@ class StorPerf(base.Scenario):
setup_res = requests.post('http://%s:5000/api/v1.0/configurations'
% self.target, json=env_args)
- setup_res_content = jsonutils.loads(
- setup_res.content)
if setup_res.status_code != 200:
- raise RuntimeError("Failed to create a stack, error message:",
- setup_res_content["message"])
+ LOG.error("Failed to create stack. %s: %s",
+ setup_res.status_code, setup_res.content)
+ raise RuntimeError("Failed to create stack. %s: %s" %
+ (setup_res.status_code, setup_res.content))
elif setup_res.status_code == 200:
+ setup_res_content = jsonutils.loads(setup_res.content)
LOG.info("stack_id: %s", setup_res_content["stack_id"])
while not self._query_setup_state():
@@ -122,14 +123,15 @@ class StorPerf(base.Scenario):
def _query_job_state(self, job_id):
"""Query the status of the supplied job_id and report on metrics"""
LOG.info("Fetching report for %s...", job_id)
- report_res = requests.get('http://{}:5000/api/v1.0/jobs'.format
- (self.target),
+ report_res = requests.get('http://%s:5000/api/v1.0/jobs' % self.target,
params={'id': job_id, 'type': 'status'})
report_res_content = jsonutils.loads(
report_res.content)
if report_res.status_code != 200:
+ LOG.error("Failed to fetch report, error message: %s",
+ report_res_content["message"])
raise RuntimeError("Failed to fetch report, error message:",
report_res_content["message"])
else:
@@ -186,15 +188,15 @@ class StorPerf(base.Scenario):
LOG.info("Starting a job with parameters %s", job_args)
job_res = requests.post('http://%s:5000/api/%s/jobs' % (self.target,
- api_version),
- json=job_args)
-
- job_res_content = jsonutils.loads(job_res.content)
+ api_version), json=job_args)
if job_res.status_code != 200:
- raise RuntimeError("Failed to start a job, error message:",
- job_res_content["message"])
+ LOG.error("Failed to start job. %s: %s",
+ job_res.status_code, job_res.content)
+ raise RuntimeError("Failed to start job. %s: %s" %
+ (job_res.status_code, job_res.content))
elif job_res.status_code == 200:
+ job_res_content = jsonutils.loads(job_res.content)
job_id = job_res_content["job_id"]
LOG.info("Started job id: %s...", job_id)
@@ -247,13 +249,14 @@ class StorPerf(base.Scenario):
job_res = requests.post('http://%s:5000/api/v1.0/initializations' %
self.target, json=job_args)
- job_res_content = jsonutils.loads(job_res.content)
if job_res.status_code != 200:
- raise RuntimeError(
- "Failed to start initialization job, error message:",
- job_res_content["message"])
+ LOG.error("Failed to start initialization job, error message: %s: %s",
+ job_res.status_code, job_res.content)
+ raise RuntimeError("Failed to start initialization job, error message: %s: %s" %
+ (job_res.status_code, job_res.content))
elif job_res.status_code == 200:
+ job_res_content = jsonutils.loads(job_res.content)
job_id = job_res_content["job_id"]
LOG.info("Started initialization as job id: %s...", job_id)
@@ -271,6 +274,8 @@ class StorPerf(base.Scenario):
if teardown_res.status_code == 400:
teardown_res_content = jsonutils.loads(
teardown_res.json_data)
+ LOG.error("Failed to reset environment, error message: %s",
+ teardown_res_content['message'])
raise RuntimeError("Failed to reset environment, error message:",
teardown_res_content['message'])
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py
index 31885c073..205247947 100644
--- a/yardstick/common/utils.py
+++ b/yardstick/common/utils.py
@@ -499,6 +499,23 @@ def read_meminfo(ssh_client):
return output
+def setup_hugepages(ssh_client, size_kb):
+ """Setup needed number of hugepages for the size specified"""
+
+ NR_HUGEPAGES_PATH = '/proc/sys/vm/nr_hugepages'
+ meminfo = read_meminfo(ssh_client)
+ hp_size_kb = int(meminfo['Hugepagesize'])
+ hp_number = int(abs(size_kb / hp_size_kb))
+ ssh_client.execute(
+ 'echo %s | sudo tee %s' % (hp_number, NR_HUGEPAGES_PATH))
+ hp = six.BytesIO()
+ ssh_client.get_file_obj(NR_HUGEPAGES_PATH, hp)
+ hp_number_set = int(hp.getvalue().decode('utf-8').splitlines()[0])
+ logger.info('Hugepages size (kB): %s, number claimed: %s, number set: %s',
+ hp_size_kb, hp_number, hp_number_set)
+ return hp_size_kb, hp_number, hp_number_set
+
+
def find_relative_file(path, task_path):
"""
Find file in one of places: in abs of path or relative to a directory path,
diff --git a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
index 21719cbf0..b2c5a98bc 100644
--- a/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/sample_vnf.py
@@ -22,7 +22,6 @@ import uuid
import subprocess
import time
-import six
from trex_stl_lib.trex_stl_client import LoggerApi
from trex_stl_lib.trex_stl_client import STLClient
@@ -114,19 +113,6 @@ class DpdkVnfSetupEnvHelper(SetupEnvHelper):
self.used_drivers = None
self.dpdk_bind_helper = DpdkBindHelper(ssh_helper)
- def _setup_hugepages(self):
- meminfo = utils.read_meminfo(self.ssh_helper)
- hp_size_kb = int(meminfo['Hugepagesize'])
- hugepages_gb = self.scenario_helper.all_options.get('hugepages_gb', 16)
- nr_hugepages = int(abs(hugepages_gb * 1024 * 1024 / hp_size_kb))
- self.ssh_helper.execute('echo %s | sudo tee %s' %
- (nr_hugepages, self.NR_HUGEPAGES_PATH))
- hp = six.BytesIO()
- self.ssh_helper.get_file_obj(self.NR_HUGEPAGES_PATH, hp)
- nr_hugepages_set = int(hp.getvalue().decode('utf-8').splitlines()[0])
- LOG.info('Hugepages size (kB): %s, number claimed: %s, number set: %s',
- hp_size_kb, nr_hugepages, nr_hugepages_set)
-
def build_config(self):
vnf_cfg = self.scenario_helper.vnf_cfg
task_path = self.scenario_helper.task_path
@@ -239,7 +225,8 @@ class DpdkVnfSetupEnvHelper(SetupEnvHelper):
def _setup_dpdk(self):
"""Setup DPDK environment needed for VNF to run"""
- self._setup_hugepages()
+ hugepages_gb = self.scenario_helper.all_options.get('hugepages_gb', 16)
+ utils.setup_hugepages(self.ssh_helper, hugepages_gb * 1024 * 1024)
self.dpdk_bind_helper.load_dpdk_driver()
exit_status = self.dpdk_bind_helper.check_dpdk_driver()
diff --git a/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
index a03d9082b..190e83d5f 100644
--- a/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
@@ -24,6 +24,7 @@ from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
from yardstick.benchmark.contexts.standalone import ovs_dpdk
from yardstick.common import exceptions
+from yardstick.common import utils as common_utils
from yardstick.network_services import utils
@@ -171,11 +172,9 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.wait_for_vswitchd = 0
self.assertIsNone(self.ovs_dpdk.cleanup_ovs_dpdk_env())
- @mock.patch.object(ovs_dpdk.OvsDpdkContext, '_check_hugepages')
@mock.patch.object(utils, 'get_nsb_option')
@mock.patch.object(model.OvsDeploy, 'ovs_deploy')
- def test_check_ovs_dpdk_env(self, mock_ovs_deploy, mock_get_nsb_option,
- mock_check_hugepages):
+ def test_check_ovs_dpdk_env(self, mock_ovs_deploy, mock_get_nsb_option):
self.ovs_dpdk.connection = mock.Mock()
self.ovs_dpdk.connection.execute = mock.Mock(
return_value=(1, 0, 0))
@@ -189,11 +188,9 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.check_ovs_dpdk_env()
mock_ovs_deploy.assert_called_once()
- mock_check_hugepages.assert_called_once()
mock_get_nsb_option.assert_called_once_with('bin_path')
- @mock.patch.object(ovs_dpdk.OvsDpdkContext, '_check_hugepages')
- def test_check_ovs_dpdk_env_wrong_version(self, mock_check_hugepages):
+ def test_check_ovs_dpdk_env_wrong_version(self):
self.ovs_dpdk.connection = mock.Mock()
self.ovs_dpdk.connection.execute = mock.Mock(
return_value=(1, 0, 0))
@@ -206,7 +203,6 @@ class OvsDpdkContextTestCase(unittest.TestCase):
with self.assertRaises(exceptions.OVSUnsupportedVersion):
self.ovs_dpdk.check_ovs_dpdk_env()
- mock_check_hugepages.assert_called_once()
@mock.patch('yardstick.ssh.SSH')
def test_deploy(self, *args):
@@ -391,13 +387,18 @@ class OvsDpdkContextTestCase(unittest.TestCase):
'fake_path', 0, self.NETWORKS['private_0']['vpci'],
self.NETWORKS['private_0']['mac'], 'test', 1)
+ @mock.patch.object(ovs_dpdk.OvsDpdkContext, '_check_hugepages')
+ @mock.patch.object(common_utils, 'setup_hugepages')
@mock.patch.object(model.StandaloneContextHelper, 'check_update_key')
@mock.patch.object(model.Libvirt, 'write_file')
@mock.patch.object(model.Libvirt, 'build_vm_xml')
@mock.patch.object(model.Libvirt, 'check_if_vm_exists_and_delete')
@mock.patch.object(model.Libvirt, 'virsh_create_vm')
- def test_setup_ovs_dpdk_context(self, mock_create_vm, mock_check_if_exists, mock_build_xml,
- mock_write_file, mock_check_update_key):
+ def test_setup_ovs_dpdk_context(self, mock_create_vm, mock_check_if_exists,
+ mock_build_xml, mock_write_file,
+ mock_check_update_key,
+ mock_setup_hugepages,
+ mock__check_hugepages):
self.ovs_dpdk.vm_deploy = True
self.ovs_dpdk.connection = mock.Mock()
self.ovs_dpdk.vm_names = ['vm-0', 'vm-1']
@@ -413,7 +414,7 @@ class OvsDpdkContextTestCase(unittest.TestCase):
}
self.ovs_dpdk.networks = self.NETWORKS
self.ovs_dpdk.host_mgmt = {}
- self.ovs_dpdk.flavor = {}
+ self.ovs_dpdk.vm_flavor = {'ram': '1024'}
self.ovs_dpdk.file_path = '/var/lib/libvirt/images/cdrom-0.img'
self.ovs_dpdk.configure_nics_for_ovs_dpdk = mock.Mock(return_value="")
self.ovs_dpdk._name_task_id = 'fake_name'
@@ -429,6 +430,8 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.assertEqual([vnf_instance_2],
self.ovs_dpdk.setup_ovs_dpdk_context())
+ mock_setup_hugepages.assert_called_once_with(self.ovs_dpdk.connection, 1024 * 1024)
+ mock__check_hugepages.assert_called_once()
mock_create_vm.assert_called_once_with(
self.ovs_dpdk.connection, '/tmp/vm_ovs_0.xml')
mock_check_if_exists.assert_called_once_with(
diff --git a/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py b/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
index 316aca72a..0809a983a 100644
--- a/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
+++ b/yardstick/tests/unit/benchmark/contexts/standalone/test_sriov.py
@@ -22,6 +22,7 @@ from yardstick.benchmark import contexts
from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
from yardstick.benchmark.contexts.standalone import sriov
+from yardstick.common import utils
class SriovContextTestCase(unittest.TestCase):
@@ -276,13 +277,15 @@ class SriovContextTestCase(unittest.TestCase):
mock_add_sriov.assert_called_once_with(
'0000:00:0a.0', 0, self.NETWORKS['private_0']['mac'], 'test')
+ @mock.patch.object(utils, 'setup_hugepages')
@mock.patch.object(model.StandaloneContextHelper, 'check_update_key')
@mock.patch.object(model.Libvirt, 'build_vm_xml')
@mock.patch.object(model.Libvirt, 'check_if_vm_exists_and_delete')
@mock.patch.object(model.Libvirt, 'write_file')
@mock.patch.object(model.Libvirt, 'virsh_create_vm')
- def test_setup_sriov_context(self, mock_create_vm, mock_write_file, mock_check,
- mock_build_vm_xml, mock_check_update_key):
+ def test_setup_sriov_context(self, mock_create_vm, mock_write_file,
+ mock_check, mock_build_vm_xml,
+ mock_check_update_key, mock_setup_hugepages):
self.sriov.servers = {
'vnf_0': {
'network_ports': {
@@ -295,7 +298,7 @@ class SriovContextTestCase(unittest.TestCase):
connection = mock.Mock()
self.sriov.connection = connection
self.sriov.host_mgmt = {'ip': '1.2.3.4'}
- self.sriov.vm_flavor = 'flavor'
+ self.sriov.vm_flavor = {'ram': '1024'}
self.sriov.networks = 'networks'
self.sriov.configure_nics_for_sriov = mock.Mock()
self.sriov._name_task_id = 'fake_name'
@@ -314,15 +317,16 @@ class SriovContextTestCase(unittest.TestCase):
mock_vnf_node.generate_vnf_instance = mock.Mock(
return_value='node_1')
nodes_out = self.sriov.setup_sriov_context()
+ mock_setup_hugepages.assert_called_once_with(connection, 1024*1024)
mock_check_update_key.assert_called_once_with(connection, 'node_1', vm_name,
self.sriov._name_task_id, cdrom_img,
mac)
self.assertEqual(['node_2'], nodes_out)
mock_vnf_node.generate_vnf_instance.assert_called_once_with(
- 'flavor', 'networks', '1.2.3.4', 'vnf_0',
+ self.sriov.vm_flavor, 'networks', '1.2.3.4', 'vnf_0',
self.sriov.servers['vnf_0'], '00:00:00:00:00:01')
mock_build_vm_xml.assert_called_once_with(
- connection, 'flavor', vm_name, 0, cdrom_img)
+ connection, self.sriov.vm_flavor, vm_name, 0, cdrom_img)
mock_create_vm.assert_called_once_with(connection, cfg)
mock_check.assert_called_once_with(vm_name, connection)
mock_write_file.assert_called_once_with(cfg, 'out_xml')
diff --git a/yardstick/tests/unit/common/test_utils.py b/yardstick/tests/unit/common/test_utils.py
index 3cf6c4d05..c0c928916 100644
--- a/yardstick/tests/unit/common/test_utils.py
+++ b/yardstick/tests/unit/common/test_utils.py
@@ -1407,3 +1407,20 @@ class SafeCaseTestCase(unittest.TestCase):
def test_default_value(self):
self.assertEqual(0, utils.safe_cast('', 'int', 0))
+
+
+class SetupHugepagesTestCase(unittest.TestCase):
+
+ @mock.patch.object(six, 'BytesIO', return_value=six.BytesIO(b'5\n'))
+ @mock.patch.object(utils, 'read_meminfo',
+ return_value={'Hugepagesize': '1024'})
+ def test_setup_hugepages(self, mock_meminfo, *args):
+ ssh = mock.Mock()
+ ssh.execute = mock.Mock()
+ hp_size_kb, hp_number, hp_number_set = utils.setup_hugepages(ssh, 10 * 1024)
+ mock_meminfo.assert_called_once_with(ssh)
+ ssh.execute.assert_called_once_with(
+ 'echo 10 | sudo tee /proc/sys/vm/nr_hugepages')
+ self.assertEqual(hp_size_kb, 1024)
+ self.assertEqual(hp_number, 10)
+ self.assertEqual(hp_number_set, 5)
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 c9d42fb3e..43682dd07 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
@@ -16,7 +16,6 @@ from copy import deepcopy
import unittest
import mock
-import six
from yardstick.common import exceptions as y_exceptions
from yardstick.common import utils
@@ -521,38 +520,6 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
result = DpdkVnfSetupEnvHelper._update_traffic_type(ip_pipeline_cfg, traffic_options)
self.assertEqual(result, expected)
- @mock.patch.object(six, 'BytesIO', return_value=six.BytesIO(b'100\n'))
- @mock.patch.object(utils, 'read_meminfo',
- return_value={'Hugepagesize': '2048'})
- def test__setup_hugepages_no_hugepages_defined(self, mock_meminfo, *args):
- ssh_helper = mock.Mock()
- scenario_helper = mock.Mock()
- scenario_helper.all_options = {}
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(
- mock.ANY, ssh_helper, scenario_helper)
- with mock.patch.object(sample_vnf.LOG, 'info') as mock_info:
- dpdk_setup_helper._setup_hugepages()
- mock_info.assert_called_once_with(
- 'Hugepages size (kB): %s, number claimed: %s, number set: '
- '%s', 2048, 8192, 100)
- mock_meminfo.assert_called_once_with(ssh_helper)
-
- @mock.patch.object(six, 'BytesIO', return_value=six.BytesIO(b'100\n'))
- @mock.patch.object(utils, 'read_meminfo',
- return_value={'Hugepagesize': '1048576'})
- def test__setup_hugepages_8gb_hugepages_defined(self, mock_meminfo, *args):
- ssh_helper = mock.Mock()
- scenario_helper = mock.Mock()
- scenario_helper.all_options = {'hugepages_gb': 8}
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(
- mock.ANY, ssh_helper, scenario_helper)
- with mock.patch.object(sample_vnf.LOG, 'info') as mock_info:
- dpdk_setup_helper._setup_hugepages()
- mock_info.assert_called_once_with(
- 'Hugepages size (kB): %s, number claimed: %s, number set: '
- '%s', 1048576, 8, 100)
- mock_meminfo.assert_called_once_with(ssh_helper)
-
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.open')
@mock.patch.object(utils, 'find_relative_file')
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.MultiPortConfig')
@@ -638,15 +605,17 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
dpdk_vnf_setup_env_helper.setup_vnf_environment(),
ResourceProfile)
- def test__setup_dpdk(self):
+ @mock.patch.object(utils, 'setup_hugepages')
+ def test__setup_dpdk(self, mock_setup_hugepages):
ssh_helper = mock.Mock()
ssh_helper.execute = mock.Mock()
ssh_helper.execute.return_value = (0, 0, 0)
- dpdk_setup_helper = DpdkVnfSetupEnvHelper(mock.ANY, ssh_helper, mock.ANY)
- with mock.patch.object(dpdk_setup_helper, '_setup_hugepages') as \
- mock_setup_hp:
- dpdk_setup_helper._setup_dpdk()
- mock_setup_hp.assert_called_once()
+ scenario_helper = mock.Mock()
+ scenario_helper.all_options = {'hugepages_gb': 8}
+ dpdk_setup_helper = DpdkVnfSetupEnvHelper(mock.ANY, ssh_helper,
+ scenario_helper)
+ dpdk_setup_helper._setup_dpdk()
+ mock_setup_hugepages.assert_called_once_with(ssh_helper, 8*1024*1024)
ssh_helper.execute.assert_has_calls([
mock.call('sudo modprobe uio && sudo modprobe igb_uio'),
mock.call('lsmod | grep -i igb_uio')