aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/benchmark')
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_model.py75
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py37
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_sriov.py2
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_monitor_command.py39
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_serviceha.py32
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_util.py39
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_cyclictest.py2
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_qemumigrate.py2
-rw-r--r--tests/unit/benchmark/scenarios/compute/test_unixbench.py2
-rw-r--r--tests/unit/benchmark/scenarios/dummy/test_dummy.py4
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_check_numa_info.py9
-rw-r--r--tests/unit/benchmark/scenarios/lib/test_create_volume.py83
-rwxr-xr-xtests/unit/benchmark/scenarios/networking/test_netperf.py2
-rwxr-xr-xtests/unit/benchmark/scenarios/networking/test_netperf_node.py2
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_nstat.py28
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_ping6.py2
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen.py36
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py69
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py33
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vsperf.py6
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py99
-rw-r--r--tests/unit/benchmark/scenarios/parser/test_parser.py67
-rw-r--r--tests/unit/benchmark/scenarios/storage/test_fio.py4
23 files changed, 404 insertions, 270 deletions
diff --git a/tests/unit/benchmark/contexts/standalone/test_model.py b/tests/unit/benchmark/contexts/standalone/test_model.py
index 31ec2b7d1..6090356b6 100644
--- a/tests/unit/benchmark/contexts/standalone/test_model.py
+++ b/tests/unit/benchmark/contexts/standalone/test_model.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,9 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Unittest for yardstick.benchmark.contexts.standalone.model
-
-from __future__ import absolute_import
import copy
import os
import unittest
@@ -24,9 +19,9 @@ import mock
from xml.etree import ElementTree
+from yardstick.benchmark.contexts.standalone.model import Libvirt
from yardstick.benchmark.contexts.standalone import model
from yardstick.network_services import utils
-from yardstick.network_services.helpers import cpu
XML_SAMPLE = """<?xml version="1.0"?>
@@ -134,9 +129,9 @@ class ModelLibvirtTestCase(unittest.TestCase):
as mock_parse:
xml = copy.deepcopy(self.xml)
mock_parse.return_value = xml
- vf_pci = '0001:05:04.2'
+ vm_pci = '0001:05:04.2'
model.Libvirt.add_sriov_interfaces(
- self.pci_address_str, vf_pci, self.mac, xml_input)
+ vm_pci, self.pci_address_str, self.mac, xml_input)
mock_parse.assert_called_once_with(xml_input)
self.mock_write_xml.assert_called_once_with(xml_input)
interface = xml.find('devices').find('interface')
@@ -145,8 +140,29 @@ class ModelLibvirtTestCase(unittest.TestCase):
mac = interface.find('mac')
self.assertEqual(self.mac, mac.get('address'))
source = interface.find('source')
+ source_address = source.find('address')
self.assertIsNotNone(source.find('address'))
- self.assertIsNotNone(interface.find('address'))
+
+ self.assertEqual('pci', source_address.get('type'))
+ self.assertEqual('0x' + self.pci_address_str.split(':')[0],
+ source_address.get('domain'))
+ self.assertEqual('0x' + self.pci_address_str.split(':')[1],
+ source_address.get('bus'))
+ self.assertEqual('0x' + self.pci_address_str.split(':')[2].split('.')[0],
+ source_address.get('slot'))
+ self.assertEqual('0x' + self.pci_address_str.split(':')[2].split('.')[1],
+ source_address.get('function'))
+
+ interface_address = interface.find('address')
+ self.assertEqual('pci', interface_address.get('type'))
+ self.assertEqual('0x' + vm_pci.split(':')[0],
+ interface_address.get('domain'))
+ self.assertEqual('0x' + vm_pci.split(':')[1],
+ interface_address.get('bus'))
+ self.assertEqual('0x' + vm_pci.split(':')[2].split('.')[0],
+ interface_address.get('slot'))
+ self.assertEqual('0x' + vm_pci.split(':')[2].split('.')[1],
+ interface_address.get('function'))
def test_create_snapshot_qemu(self):
result = "/var/lib/libvirt/images/0.qcow2"
@@ -164,6 +180,8 @@ class ModelLibvirtTestCase(unittest.TestCase):
*args):
# NOTE(ralonsoh): this test doesn't cover function execution. This test
# should also check mocked function calls.
+ cfg_file = 'test_config_file.cfg'
+ self.addCleanup(os.remove, cfg_file)
result = [4]
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
@@ -172,7 +190,7 @@ class ModelLibvirtTestCase(unittest.TestCase):
ssh.return_value = ssh_mock
mock_create_snapshot_qemu.return_value = "0.img"
- status = model.Libvirt.build_vm_xml(ssh_mock, {}, "test", "vm_0", 0)
+ status = model.Libvirt.build_vm_xml(ssh_mock, {}, cfg_file, 'vm_0', 0)
self.assertEqual(status[0], result[0])
def test_update_interrupts_hugepages_perf(self):
@@ -181,21 +199,23 @@ class ModelLibvirtTestCase(unittest.TestCase):
ssh_mock.execute = \
mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- # NOTE(ralonsoh): this test doesn't cover function execution. This test
- # should also check mocked function calls.
- model.Libvirt.update_interrupts_hugepages_perf(ssh_mock)
-
- @mock.patch.object(cpu.CpuSysCores, 'get_core_socket')
- def test_pin_vcpu_for_perf(self, mock_get_core_socket):
- mock_get_core_socket.return_value = {
- 'cores_per_socket': 1,
- 'thread_per_core': 1,
- '0': [1, 2]
- }
- # NOTE(ralonsoh): this test doesn't cover function execution. This
- # function needs more tests.
- model.Libvirt.pin_vcpu_for_perf(mock.Mock())
-
+ # NOTE(ralonsoh): 'update_interrupts_hugepages_perf' always return
+ # None, this check is trivial.
+ #status = Libvirt.update_interrupts_hugepages_perf(ssh_mock)
+ #self.assertIsNone(status)
+ Libvirt.update_interrupts_hugepages_perf(ssh_mock)
+
+ @mock.patch("yardstick.benchmark.contexts.standalone.model.CpuSysCores")
+ @mock.patch.object(model.Libvirt, 'update_interrupts_hugepages_perf')
+ def test_pin_vcpu_for_perf(self, *args):
+ # NOTE(ralonsoh): test mocked methods/variables.
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh_mock.execute = \
+ mock.Mock(return_value=(0, "a", ""))
+ ssh.return_value = ssh_mock
+ status = Libvirt.pin_vcpu_for_perf(ssh_mock, 4)
+ self.assertIsNotNone(status)
class StandaloneContextHelperTestCase(unittest.TestCase):
@@ -247,8 +267,7 @@ class StandaloneContextHelperTestCase(unittest.TestCase):
def test_get_nic_details(self, mock_get_kernel_module):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(1, "i40e ixgbe", ""))
+ ssh_mock.execute = mock.Mock(return_value=(1, "i40e ixgbe", ""))
ssh.return_value = ssh_mock
mock_get_kernel_module.return_value = "i40e"
# NOTE(ralonsoh): this test doesn't cover function execution. This test
@@ -296,6 +315,7 @@ class StandaloneContextHelperTestCase(unittest.TestCase):
@mock.patch('yardstick.ssh.SSH')
def test_get_mgmt_ip(self, *args):
+ # NOTE(ralonsoh): test mocked methods/variables.
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = mock.Mock(
@@ -309,6 +329,7 @@ class StandaloneContextHelperTestCase(unittest.TestCase):
@mock.patch('yardstick.ssh.SSH')
def test_get_mgmt_ip_no(self, *args):
+ # NOTE(ralonsoh): test mocked methods/variables.
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
diff --git a/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py b/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
index 5d1b0421c..e39ecf4f2 100644
--- a/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
+++ b/tests/unit/benchmark/contexts/standalone/test_ovs_dpdk.py
@@ -17,12 +17,9 @@
from __future__ import absolute_import
import os
import unittest
-import errno
import mock
-from yardstick.common import constants as consts
from yardstick.benchmark.contexts.standalone import ovs_dpdk
-from yardstick.network_services.utils import PciAddress
class OvsDpdkContextTestCase(unittest.TestCase):
@@ -68,7 +65,7 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.helper = mock_helper
self.ovs_dpdk.vnf_node = mock_server
self.assertIsNone(self.ovs_dpdk.file_path)
- self.assertEqual(self.ovs_dpdk.first_run, True)
+ self.assertTrue(self.ovs_dpdk.first_run)
def test_init(self):
self.ovs_dpdk.helper.parse_pod_file = mock.Mock(return_value=[{}, {}, {}])
@@ -149,12 +146,9 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.assertRaises(Exception, self.ovs_dpdk.check_ovs_dpdk_env)
@mock.patch('yardstick.ssh.SSH')
- def test_deploy(self, mock_ssh):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "a", ""))
- ssh.return_value = ssh_mock
+ def test_deploy(self, ssh_mock):
+ ssh_mock.execute.return_value = (0, "a", "")
+
self.ovs_dpdk.vm_deploy = False
self.assertIsNone(self.ovs_dpdk.deploy())
@@ -168,22 +162,21 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.setup_ovs_bridge_add_flows = mock.Mock(return_value={})
self.ovs_dpdk.setup_ovs_dpdk_context = mock.Mock(return_value={})
self.ovs_dpdk.wait_for_vnfs_to_start = mock.Mock(return_value={})
+ # TODO(elfoley): This test should check states/sideeffects instead of
+ # output.
self.assertIsNone(self.ovs_dpdk.deploy())
- @mock.patch('yardstick.benchmark.contexts.standalone.ovs_dpdk.Libvirt')
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.Libvirt')
@mock.patch('yardstick.ssh.SSH')
- def test_undeploy(self, mock_ssh, mock_libvirt):
- with mock.patch("yardstick.ssh.SSH") as ssh:
- ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(0, "a", ""))
- ssh.return_value = ssh_mock
+ def test_undeploy(self, ssh_mock, _):
+ ssh_mock.execute.return_value = (0, "a", "")
+
self.ovs_dpdk.vm_deploy = False
self.assertIsNone(self.ovs_dpdk.undeploy())
self.ovs_dpdk.vm_deploy = True
- self.ovs_dpdk.connection = ssh_mock
self.ovs_dpdk.vm_names = ['vm_0', 'vm_1']
+ self.ovs_dpdk.connection = ssh_mock
self.ovs_dpdk.drivers = ['vm_0', 'vm_1']
self.ovs_dpdk.cleanup_ovs_dpdk_env = mock.Mock()
self.ovs_dpdk.networks = self.NETWORKS
@@ -326,8 +319,8 @@ class OvsDpdkContextTestCase(unittest.TestCase):
self.ovs_dpdk.get_vf_datas = mock.Mock(return_value="")
self.assertIsNone(self.ovs_dpdk.configure_nics_for_ovs_dpdk())
- @mock.patch('yardstick.benchmark.contexts.standalone.ovs_dpdk.Libvirt')
- def test__enable_interfaces(self, mock_add_ovs_interface):
+ @mock.patch('yardstick.benchmark.contexts.standalone.model.Libvirt.add_ovs_interface')
+ def test__enable_interfaces(self, _):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
@@ -343,7 +336,7 @@ class OvsDpdkContextTestCase(unittest.TestCase):
@mock.patch('yardstick.benchmark.contexts.standalone.ovs_dpdk.Libvirt')
@mock.patch('yardstick.benchmark.contexts.standalone.model.Server')
- def test_setup_ovs_dpdk_context(self, mock_server, mock_libvirt):
+ def test_setup_ovs_dpdk_context(self, _, mock_libvirt):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \
@@ -372,6 +365,6 @@ class OvsDpdkContextTestCase(unittest.TestCase):
mock_libvirt.build_vm_xml = mock.Mock(return_value=[6, "00:00:00:00:00:01"])
self.ovs_dpdk._enable_interfaces = mock.Mock(return_value="")
mock_libvirt.virsh_create_vm = mock.Mock(return_value="")
- mock_libvirt.pin_vcpu_for_perf= mock.Mock(return_value="")
+ mock_libvirt.pin_vcpu_for_perf = mock.Mock(return_value="")
self.ovs_dpdk.vnf_node.generate_vnf_instance = mock.Mock(return_value={})
self.assertIsNotNone(self.ovs_dpdk.setup_ovs_dpdk_context())
diff --git a/tests/unit/benchmark/contexts/standalone/test_sriov.py b/tests/unit/benchmark/contexts/standalone/test_sriov.py
index 3ea673abc..7f11a7d59 100644
--- a/tests/unit/benchmark/contexts/standalone/test_sriov.py
+++ b/tests/unit/benchmark/contexts/standalone/test_sriov.py
@@ -70,7 +70,7 @@ class SriovContextTestCase(unittest.TestCase):
self.sriov.helper = mock_helper
self.sriov.vnf_node = mock_server
self.assertIsNone(self.sriov.file_path)
- self.assertEqual(self.sriov.first_run, True)
+ self.assertTrue(self.sriov.first_run)
def test_init(self):
self.sriov.helper.parse_pod_file = mock.Mock(return_value=[{}, {}, {}])
diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py b/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
index 6a9b3b157..b84cef23c 100644
--- a/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
+++ b/tests/unit/benchmark/scenarios/availability/test_monitor_command.py
@@ -19,30 +19,26 @@ import unittest
from yardstick.benchmark.scenarios.availability.monitor import monitor_command
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.monitor.monitor_command'
- '.subprocess')
+@mock.patch('subprocess.check_output')
class ExecuteShellTestCase(unittest.TestCase):
- def test__fun_execute_shell_command_successful(self, mock_subprocess):
+ def test__fun_execute_shell_command_successful(self, mock_subprocess_check_output):
cmd = "env"
- mock_subprocess.check_output.return_value = (0, 'unittest')
- exitcode, output = monitor_command._execute_shell_command(cmd)
+ mock_subprocess_check_output.return_value = (0, 'unittest')
+ exitcode, _ = monitor_command._execute_shell_command(cmd)
self.assertEqual(exitcode, 0)
@mock.patch('yardstick.benchmark.scenarios.availability.monitor.monitor_command.LOG')
def test__fun_execute_shell_command_fail_cmd_exception(self, mock_log,
- mock_subprocess):
+ mock_subprocess_check_output):
cmd = "env"
- mock_subprocess.check_output.side_effect = RuntimeError
- exitcode, output = monitor_command._execute_shell_command(cmd)
+ mock_subprocess_check_output.side_effect = RuntimeError
+ exitcode, _ = monitor_command._execute_shell_command(cmd)
self.assertEqual(exitcode, -1)
mock_log.error.assert_called_once()
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.monitor.monitor_command'
- '.subprocess')
+@mock.patch('subprocess.check_output')
class MonitorOpenstackCmdTestCase(unittest.TestCase):
def setUp(self):
@@ -59,24 +55,24 @@ class MonitorOpenstackCmdTestCase(unittest.TestCase):
'sla': {'max_outage_time': 5}
}
- def test__monitor_command_monitor_func_successful(self, mock_subprocess):
+ def test__monitor_command_monitor_func_successful(self, mock_subprocess_check_output):
instance = monitor_command.MonitorOpenstackCmd(self.config, None, {"nova-api": 10})
instance.setup()
- mock_subprocess.check_output.return_value = (0, 'unittest')
+ mock_subprocess_check_output.return_value = (0, 'unittest')
ret = instance.monitor_func()
- self.assertEqual(ret, True)
+ self.assertTrue(ret)
instance._result = {"outage_time": 0}
instance.verify_SLA()
@mock.patch('yardstick.benchmark.scenarios.availability.monitor.monitor_command.LOG')
- def test__monitor_command_monitor_func_failure(self, mock_log, mock_subprocess):
- mock_subprocess.check_output.return_value = (1, 'unittest')
+ def test__monitor_command_monitor_func_failure(self, mock_log, mock_subprocess_check_output):
+ mock_subprocess_check_output.return_value = (1, 'unittest')
instance = monitor_command.MonitorOpenstackCmd(self.config, None, {"nova-api": 10})
instance.setup()
- mock_subprocess.check_output.side_effect = RuntimeError
+ mock_subprocess_check_output.side_effect = RuntimeError
ret = instance.monitor_func()
- self.assertEqual(ret, False)
+ self.assertFalse(ret)
mock_log.error.assert_called_once()
instance._result = {"outage_time": 10}
instance.verify_SLA()
@@ -84,12 +80,13 @@ class MonitorOpenstackCmdTestCase(unittest.TestCase):
@mock.patch(
'yardstick.benchmark.scenarios.availability.monitor.monitor_command'
'.ssh')
- def test__monitor_command_ssh_monitor_successful(self, mock_ssh,
- mock_subprocess):
+ def test__monitor_command_ssh_monitor_successful(self, mock_ssh, mock_subprocess_check_output):
+ mock_subprocess_check_output.return_value = (0, 'unittest')
self.config["host"] = "node1"
instance = monitor_command.MonitorOpenstackCmd(
self.config, self.context, {"nova-api": 10})
instance.setup()
mock_ssh.SSH.from_node().execute.return_value = (0, "0", '')
ret = instance.monitor_func()
+ self.assertTrue(ret)
diff --git a/tests/unit/benchmark/scenarios/availability/test_serviceha.py b/tests/unit/benchmark/scenarios/availability/test_serviceha.py
index 4ae508958..97d534894 100644
--- a/tests/unit/benchmark/scenarios/availability/test_serviceha.py
+++ b/tests/unit/benchmark/scenarios/availability/test_serviceha.py
@@ -18,9 +18,6 @@ import unittest
from yardstick.benchmark.scenarios.availability import serviceha
-@mock.patch('yardstick.benchmark.scenarios.availability.serviceha.basemonitor')
-@mock.patch(
- 'yardstick.benchmark.scenarios.availability.serviceha.baseattacker')
class ServicehaTestCase(unittest.TestCase):
def setUp(self):
@@ -51,27 +48,32 @@ class ServicehaTestCase(unittest.TestCase):
sla = {"outage_time": 5}
self.args = {"options": options, "sla": sla}
- def test__serviceha_setup_run_successful(self, mock_attacker,
+ @mock.patch('yardstick.benchmark.scenarios.availability.serviceha.basemonitor')
+ @mock.patch(
+ 'yardstick.benchmark.scenarios.availability.serviceha.baseattacker')
+ def test__serviceha_setup_run_successful(self, _,
mock_monitor):
p = serviceha.ServiceHA(self.args, self.ctx)
p.setup()
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
mock_monitor.MonitorMgr().verify_SLA.return_value = True
ret = {}
p.run(ret)
p.teardown()
-"""
- def test__serviceha_run_sla_error(self, mock_attacker, mock_monitor):
- p = serviceha.ServiceHA(self.args, self.ctx)
p.setup()
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
- result = {}
- result["outage_time"] = 10
- mock_monitor.Monitor().get_result.return_value = result
+# def test__serviceha_run_sla_error(self, mock_attacker, mock_monitor):
+# p = serviceha.ServiceHA(self.args, self.ctx)
- ret = {}
- self.assertRaises(AssertionError, p.run, ret)
-"""
+# p.setup()
+# self.assertTrue(p.setup_done)
+#
+# result = {}
+# result["outage_time"] = 10
+# mock_monitor.Monitor().get_result.return_value = result
+
+# ret = {}
+# self.assertRaises(AssertionError, p.run, ret)
diff --git a/tests/unit/benchmark/scenarios/availability/test_util.py b/tests/unit/benchmark/scenarios/availability/test_util.py
index 0974f385a..548efe91b 100644
--- a/tests/unit/benchmark/scenarios/availability/test_util.py
+++ b/tests/unit/benchmark/scenarios/availability/test_util.py
@@ -16,36 +16,43 @@ import unittest
from yardstick.benchmark.scenarios.availability import util
-@mock.patch('yardstick.benchmark.scenarios.availability.util.subprocess')
+
class ExecuteShellTestCase(unittest.TestCase):
def setUp(self):
self.param_config = {'serviceName': '@serviceName', 'value': 1}
self.intermediate_variables = {'@serviceName': 'nova-api'}
self.std_output = '| id | 1 |'
- self.cmd_config = {'cmd':'ls','param':'-a'}
+ self.cmd_config = {'cmd': 'ls', 'param': '-a'}
+
+ self._mock_subprocess = mock.patch.object(util, 'subprocess')
+ self.mock_subprocess = self._mock_subprocess.start()
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_subprocess.stop()
- def test_util_build_command_shell(self,mock_subprocess):
+ def test_util_build_command_shell(self):
result = util.build_shell_command(self.param_config, True,
self.intermediate_variables)
- self.assertEqual("nova-api" in result, True)
+ self.assertIn("nova-api", result)
- def test_read_stdout_item(self,mock_subprocess):
- result = util.read_stdout_item(self.std_output,'id')
- self.assertEquals('1',result)
+ def test_read_stdout_item(self):
+ result = util.read_stdout_item(self.std_output, 'id')
+ self.assertEqual('1', result)
- def test_buildshellparams(self,mock_subprocess):
- result = util.buildshellparams(self.cmd_config,True)
- self.assertEquals('/bin/bash -s {0} {1}', result)
+ def test_buildshellparams(self):
+ result = util.buildshellparams(self.cmd_config, True)
+ self.assertEqual('/bin/bash -s {0} {1}', result)
- def test__fun_execute_shell_command_successful(self, mock_subprocess):
+ def test__fun_execute_shell_command_successful(self):
cmd = "env"
- mock_subprocess.check_output.return_value = (0, 'unittest')
- exitcode, output = util.execute_shell_command(cmd)
+ self.mock_subprocess.check_output.return_value = (0, 'unittest')
+ exitcode, _ = util.execute_shell_command(cmd)
self.assertEqual(exitcode, 0)
- def test__fun_execute_shell_command_fail_cmd_exception(self, mock_subprocess):
+ def test__fun_execute_shell_command_fail_cmd_exception(self):
cmd = "env"
- mock_subprocess.check_output.side_effect = RuntimeError
- exitcode, output = util.execute_shell_command(cmd)
+ self.mock_subprocess.check_output.side_effect = RuntimeError
+ exitcode, _ = util.execute_shell_command(cmd)
self.assertEqual(exitcode, -1)
diff --git a/tests/unit/benchmark/scenarios/compute/test_cyclictest.py b/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
index dc52a80c7..51ffd2488 100644
--- a/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
+++ b/tests/unit/benchmark/scenarios/compute/test_cyclictest.py
@@ -74,7 +74,7 @@ class CyclictestTestCase(unittest.TestCase):
c.setup()
self.assertIsNotNone(c.guest)
self.assertIsNotNone(c.host)
- self.assertEqual(c.setup_done, True)
+ self.assertTrue(c.setup_done)
def test_cyclictest_successful_no_sla(self, mock_ssh):
result = {}
diff --git a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py b/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
index 1f0ff3c29..fb55b809f 100644
--- a/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
+++ b/tests/unit/benchmark/scenarios/compute/test_qemumigrate.py
@@ -71,7 +71,7 @@ class QemuMigrateTestCase(unittest.TestCase):
q.setup()
self.assertIsNotNone(q.host)
- self.assertEqual(q.setup_done, True)
+ self.assertTrue(q.setup_done)
def test_qemu_migrate_successful_no_sla(self, mock_ssh):
result = {}
diff --git a/tests/unit/benchmark/scenarios/compute/test_unixbench.py b/tests/unit/benchmark/scenarios/compute/test_unixbench.py
index 7d071e91c..fec355b45 100644
--- a/tests/unit/benchmark/scenarios/compute/test_unixbench.py
+++ b/tests/unit/benchmark/scenarios/compute/test_unixbench.py
@@ -40,7 +40,7 @@ class UnixbenchTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
self.assertIsNotNone(u.client)
- self.assertEqual(u.setup_done, True)
+ self.assertTrue(u.setup_done)
def test_unixbench_successful_no_sla(self, mock_ssh):
diff --git a/tests/unit/benchmark/scenarios/dummy/test_dummy.py b/tests/unit/benchmark/scenarios/dummy/test_dummy.py
index 560675d09..bc5131806 100644
--- a/tests/unit/benchmark/scenarios/dummy/test_dummy.py
+++ b/tests/unit/benchmark/scenarios/dummy/test_dummy.py
@@ -24,11 +24,11 @@ class DummyTestCase(unittest.TestCase):
self.assertIsNone(self.test_context.scenario_cfg)
self.assertIsNone(self.test_context.context_cfg)
- self.assertEqual(self.test_context.setup_done, False)
+ self.assertFalse(self.test_context.setup_done)
def test_run(self):
result = {}
self.test_context.run(result)
self.assertEqual(result["hello"], "yardstick")
- self.assertEqual(self.test_context.setup_done, True)
+ self.assertTrue(self.test_context.setup_done)
diff --git a/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py b/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py
index bdf1e66e5..1dd461d41 100644
--- a/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py
+++ b/tests/unit/benchmark/scenarios/lib/test_check_numa_info.py
@@ -14,7 +14,8 @@ from yardstick.benchmark.scenarios.lib.check_numa_info import CheckNumaInfo
class CheckNumaInfoTestCase(unittest.TestCase):
- @mock.patch('yardstick.benchmark.scenarios.lib.check_numa_info.CheckNumaInfo._check_vm2_status')
+ @mock.patch(
+ 'yardstick.benchmark.scenarios.lib.check_numa_info.CheckNumaInfo._check_vm2_status')
def test_check_numa_info(self, mock_check_vm2):
scenario_cfg = {'info1': {}, 'info2': {}}
obj = CheckNumaInfo(scenario_cfg, {})
@@ -37,7 +38,7 @@ class CheckNumaInfoTestCase(unittest.TestCase):
scenario_cfg = {'info1': info1, 'info2': info2}
obj = CheckNumaInfo(scenario_cfg, {})
status = obj._check_vm2_status(info1, info2)
- self.assertEqual(status, True)
+ self.assertTrue(status)
def test_check_vm2_status_length_gt_1(self):
info1 = {
@@ -55,7 +56,7 @@ class CheckNumaInfoTestCase(unittest.TestCase):
scenario_cfg = {'info1': info1, 'info2': info2}
obj = CheckNumaInfo(scenario_cfg, {})
status = obj._check_vm2_status(info1, info2)
- self.assertEqual(status, False)
+ self.assertFalse(status)
def test_check_vm2_status_length_not_in_set(self):
info1 = {
@@ -73,7 +74,7 @@ class CheckNumaInfoTestCase(unittest.TestCase):
scenario_cfg = {'info1': info1, 'info2': info2}
obj = CheckNumaInfo(scenario_cfg, {})
status = obj._check_vm2_status(info1, info2)
- self.assertEqual(status, False)
+ self.assertFalse(status)
def main():
diff --git a/tests/unit/benchmark/scenarios/lib/test_create_volume.py b/tests/unit/benchmark/scenarios/lib/test_create_volume.py
index fc633139e..ef2c0ccaf 100644
--- a/tests/unit/benchmark/scenarios/lib/test_create_volume.py
+++ b/tests/unit/benchmark/scenarios/lib/test_create_volume.py
@@ -9,28 +9,79 @@
import unittest
import mock
-from yardstick.benchmark.scenarios.lib.create_volume import CreateVolume
+import yardstick.benchmark.scenarios.lib.create_volume
class CreateVolumeTestCase(unittest.TestCase):
+ def setUp(self):
+ self._mock_cinder_client = mock.patch(
+ 'yardstick.common.openstack_utils.get_cinder_client')
+ self.mock_cinder_client = self._mock_cinder_client.start()
+ self._mock_glance_client = mock.patch(
+ 'yardstick.common.openstack_utils.get_glance_client')
+ self.mock_glance_client = self._mock_glance_client.start()
+ self.addCleanup(self._stop_mock)
+
+ self.scenario_cfg = {
+ "options" :
+ {
+ 'volume_name': 'yardstick_test_volume_01',
+ 'size': '256',
+ 'image': 'cirros-0.3.5'
+ }
+ }
+
+ self.scenario = (
+ yardstick.benchmark.scenarios.lib.create_volume.CreateVolume(
+ scenario_cfg=self.scenario_cfg,
+ context_cfg={}))
+
+ def _stop_mock(self):
+ self._mock_cinder_client.stop()
+ self._mock_glance_client.stop()
+
+ def test_init(self):
+ self.mock_cinder_client.return_value = "All volumes are equal"
+ self.mock_glance_client.return_value = "Images are more equal"
+
+ expected_vol_name = self.scenario_cfg["options"]["volume_name"]
+ expected_vol_size = self.scenario_cfg["options"]["size"]
+ expected_im_name = self.scenario_cfg["options"]["image"]
+ expected_im_id = None
+
+ scenario = (
+ yardstick.benchmark.scenarios.lib.create_volume.CreateVolume(
+ scenario_cfg=self.scenario_cfg,
+ context_cfg={}))
+
+ self.assertEqual(expected_vol_name, scenario.volume_name)
+ self.assertEqual(expected_vol_size, scenario.volume_size)
+ self.assertEqual(expected_im_name, scenario.image_name)
+ self.assertEqual(expected_im_id, scenario.image_id)
+ self.assertEqual("All volumes are equal", scenario.cinder_client)
+ self.assertEqual("Images are more equal", scenario.glance_client)
+
+ def test_setup(self):
+ self.assertFalse(self.scenario.setup_done)
+ self.scenario.setup()
+ self.assertTrue(self.scenario.setup_done)
+
@mock.patch('yardstick.common.openstack_utils.create_volume')
@mock.patch('yardstick.common.openstack_utils.get_image_id')
- @mock.patch('yardstick.common.openstack_utils.get_cinder_client')
- @mock.patch('yardstick.common.openstack_utils.get_glance_client')
- def test_create_volume(self, mock_get_glance_client, mock_get_cinder_client, mock_image_id, mock_create_volume):
- options = {
- 'volume_name': 'yardstick_test_volume_01',
- 'size': '256',
- 'image': 'cirros-0.3.5'
- }
- args = {"options": options}
- obj = CreateVolume(args, {})
- obj.run({})
- self.assertTrue(mock_create_volume.called)
- self.assertTrue(mock_image_id.called)
- self.assertTrue(mock_get_glance_client.called)
- self.assertTrue(mock_get_cinder_client.called)
+ def test_run(self, mock_image_id, mock_create_volume):
+ self.scenario.run()
+
+ mock_image_id.assert_called_once()
+ mock_create_volume.assert_called_once()
+
+ @mock.patch.object(
+ yardstick.benchmark.scenarios.lib.create_volume.CreateVolume, 'setup')
+ def test_run_no_setup(self, scenario_setup):
+ self.scenario.setup_done = False
+ self.scenario.run()
+ scenario_setup.assert_called_once()
+
def main():
unittest.main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_netperf.py b/tests/unit/benchmark/scenarios/networking/test_netperf.py
index d0f862fb5..d82a00931 100755
--- a/tests/unit/benchmark/scenarios/networking/test_netperf.py
+++ b/tests/unit/benchmark/scenarios/networking/test_netperf.py
@@ -48,7 +48,7 @@ class NetperfTestCase(unittest.TestCase):
p.setup()
self.assertIsNotNone(p.server)
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
def test_netperf_successful_no_sla(self, mock_ssh):
diff --git a/tests/unit/benchmark/scenarios/networking/test_netperf_node.py b/tests/unit/benchmark/scenarios/networking/test_netperf_node.py
index 62874cc44..8be9bb94d 100755
--- a/tests/unit/benchmark/scenarios/networking/test_netperf_node.py
+++ b/tests/unit/benchmark/scenarios/networking/test_netperf_node.py
@@ -48,7 +48,7 @@ class NetperfNodeTestCase(unittest.TestCase):
p.setup()
self.assertIsNotNone(p.server)
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
def test_netperf_node_successful_no_sla(self, mock_ssh):
diff --git a/tests/unit/benchmark/scenarios/networking/test_nstat.py b/tests/unit/benchmark/scenarios/networking/test_nstat.py
index fe44cfdf4..4b58e06c1 100644
--- a/tests/unit/benchmark/scenarios/networking/test_nstat.py
+++ b/tests/unit/benchmark/scenarios/networking/test_nstat.py
@@ -19,6 +19,7 @@ import mock
from yardstick.benchmark.scenarios.networking import nstat
+
@mock.patch('yardstick.benchmark.scenarios.networking.nstat.ssh')
class NstatTestCase(unittest.TestCase):
@@ -38,7 +39,7 @@ class NstatTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
self.assertIsNotNone(n.client)
- self.assertEqual(n.setup_done, True)
+ self.assertTrue(n.setup_done)
def test_nstat_successful_no_sla(self, mock_ssh):
@@ -51,17 +52,17 @@ class NstatTestCase(unittest.TestCase):
n = nstat.Nstat(args, self.ctx)
result = {}
- sample_output = '#kernel\nIpInReceives 1837 0.0\nIpInHdrErrors 0 0.0\nIpInAddrErrors 2 0.0\nIcmpInMsgs 319 0.0\nIcmpInErrors 0 0.0\nTcpInSegs 36 0.0\nTcpInErrs 0 0.0\nUdpInDatagrams 1318 0.0\nUdpInErrors 0 0.0\n'
+ sample_output = '#kernel\nIpInReceives 1837 0.0\nIpInHdrErrors 0 0.0\nIpInAddrErrors 2 0.0\nIcmpInMsgs 319 0.0\nIcmpInErrors 0 0.0\nTcpInSegs 36 0.0\nTcpInErrs 0 0.0\nUdpInDatagrams 1318 0.0\nUdpInErrors 0 0.0\n' # pylint: disable=line-too-long
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
n.run(result)
expected_result = {"TcpInErrs": 0, "UdpInDatagrams": 1318,
- "Tcp_segment_error_rate": 0.0, "IpInAddrErrors": 2,
- "IpInHdrErrors": 0, "IcmpInErrors": 0, "IpErrors": 2,
- "TcpInSegs": 36, "IpInReceives": 1837, "IcmpInMsgs": 319,
- "IP_datagram_error_rate": 0.001, "Udp_datagram_error_rate": 0.0,
- "Icmp_message_error_rate": 0.0, "UdpInErrors": 0}
+ "Tcp_segment_error_rate": 0.0, "IpInAddrErrors": 2,
+ "IpInHdrErrors": 0, "IcmpInErrors": 0, "IpErrors": 2,
+ "TcpInSegs": 36, "IpInReceives": 1837, "IcmpInMsgs": 319,
+ "IP_datagram_error_rate": 0.001, "Udp_datagram_error_rate": 0.0,
+ "Icmp_message_error_rate": 0.0, "UdpInErrors": 0}
self.assertEqual(result, expected_result)
def test_nstat_successful_sla(self, mock_ssh):
@@ -79,17 +80,17 @@ class NstatTestCase(unittest.TestCase):
n = nstat.Nstat(args, self.ctx)
result = {}
- sample_output = '#kernel\nIpInReceives 1837 0.0\nIpInHdrErrors 0 0.0\nIpInAddrErrors 2 0.0\nIcmpInMsgs 319 0.0\nIcmpInErrors 0 0.0\nTcpInSegs 36 0.0\nTcpInErrs 0 0.0\nUdpInDatagrams 1318 0.0\nUdpInErrors 0 0.0\n'
+ sample_output = '#kernel\nIpInReceives 1837 0.0\nIpInHdrErrors 0 0.0\nIpInAddrErrors 2 0.0\nIcmpInMsgs 319 0.0\nIcmpInErrors 0 0.0\nTcpInSegs 36 0.0\nTcpInErrs 0 0.0\nUdpInDatagrams 1318 0.0\nUdpInErrors 0 0.0\n' # pylint: disable=line-too-long
mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
n.run(result)
expected_result = {"TcpInErrs": 0, "UdpInDatagrams": 1318,
- "Tcp_segment_error_rate": 0.0, "IpInAddrErrors": 2,
- "IpInHdrErrors": 0, "IcmpInErrors": 0, "IpErrors": 2,
- "TcpInSegs": 36, "IpInReceives": 1837, "IcmpInMsgs": 319,
- "IP_datagram_error_rate": 0.001, "Udp_datagram_error_rate": 0.0,
- "Icmp_message_error_rate": 0.0, "UdpInErrors": 0}
+ "Tcp_segment_error_rate": 0.0, "IpInAddrErrors": 2,
+ "IpInHdrErrors": 0, "IcmpInErrors": 0, "IpErrors": 2,
+ "TcpInSegs": 36, "IpInReceives": 1837, "IcmpInMsgs": 319,
+ "IP_datagram_error_rate": 0.001, "Udp_datagram_error_rate": 0.0,
+ "Icmp_message_error_rate": 0.0, "UdpInErrors": 0}
self.assertEqual(result, expected_result)
def test_nstat_unsuccessful_cmd_error(self, mock_ssh):
@@ -114,5 +115,6 @@ class NstatTestCase(unittest.TestCase):
def main():
unittest.main()
+
if __name__ == '__main__':
main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_ping6.py b/tests/unit/benchmark/scenarios/networking/test_ping6.py
index ecce7cee5..d2be6f576 100644
--- a/tests/unit/benchmark/scenarios/networking/test_ping6.py
+++ b/tests/unit/benchmark/scenarios/networking/test_ping6.py
@@ -59,7 +59,7 @@ class PingTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '0', '')
p.setup()
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
@mock.patch('yardstick.benchmark.scenarios.networking.ping6.ssh')
def test_ping_successful_no_sla(self, mock_ssh):
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen.py b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
index 3928aacde..005b53177 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen.py
@@ -50,7 +50,7 @@ class PktgenTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
self.assertIsNotNone(p.server)
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
def test_pktgen_successful_iptables_setup(self, mock_ssh):
@@ -632,9 +632,13 @@ class PktgenTestCase(unittest.TestCase):
def test_pktgen_run_with_setup_done(self, mock_ssh):
args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10, 'duration': 20, 'multiqueue': True},
- 'sla': {'max_ppm': 1}
- }
+ 'options': {
+ 'packetsize': 60,
+ 'number_of_ports': 10,
+ 'duration': 20,
+ 'multiqueue': True},
+ 'sla': {
+ 'max_ppm': 1}}
result = {}
p = pktgen.Pktgen(args, self.ctx)
p.server = mock_ssh.SSH.from_node()
@@ -659,9 +663,13 @@ class PktgenTestCase(unittest.TestCase):
def test_pktgen_run_with_ovs_multiqueque(self, mock_ssh):
args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10, 'duration': 20, 'multiqueue': True},
- 'sla': {'max_ppm': 1}
- }
+ 'options': {
+ 'packetsize': 60,
+ 'number_of_ports': 10,
+ 'duration': 20,
+ 'multiqueue': True},
+ 'sla': {
+ 'max_ppm': 1}}
result = {}
p = pktgen.Pktgen(args, self.ctx)
@@ -683,7 +691,7 @@ class PktgenTestCase(unittest.TestCase):
mock_result3 = mock.Mock()
mock_result3.return_value = 4
- p._enable_ovs_multiqueue = mock_result3
+ p._enable_ovs_multiqueue = mock_result3
mock_result4 = mock.Mock()
p._setup_irqmapping_ovs = mock_result4
@@ -704,9 +712,13 @@ class PktgenTestCase(unittest.TestCase):
def test_pktgen_run_with_sriov_multiqueque(self, mock_ssh):
args = {
- 'options': {'packetsize': 60, 'number_of_ports': 10, 'duration': 20, 'multiqueue': True},
- 'sla': {'max_ppm': 1}
- }
+ 'options': {
+ 'packetsize': 60,
+ 'number_of_ports': 10,
+ 'duration': 20,
+ 'multiqueue': True},
+ 'sla': {
+ 'max_ppm': 1}}
result = {}
p = pktgen.Pktgen(args, self.ctx)
@@ -739,8 +751,10 @@ class PktgenTestCase(unittest.TestCase):
expected_result["packetsize"] = 60
self.assertEqual(result, expected_result)
+
def main():
unittest.main()
+
if __name__ == '__main__':
main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
index b4b87522c..c9eec4b94 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
@@ -20,8 +20,6 @@ import yardstick.common.utils as utils
from yardstick.benchmark.scenarios.networking import pktgen_dpdk
-@mock.patch('yardstick.benchmark.scenarios.networking.pktgen_dpdk.time')
-@mock.patch('yardstick.benchmark.scenarios.networking.pktgen_dpdk.ssh')
class PktgenDPDKLatencyTestCase(unittest.TestCase):
def setUp(self):
@@ -39,7 +37,20 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
}
}
- def test_pktgen_dpdk_successful_setup(self, mock_ssh, mock_time):
+ self._mock_ssh = mock.patch(
+ 'yardstick.benchmark.scenarios.networking.pktgen_dpdk.ssh')
+ self.mock_ssh = self._mock_ssh.start()
+ self._mock_time = mock.patch(
+ 'yardstick.benchmark.scenarios.networking.pktgen_dpdk.time')
+ self.mock_time = self._mock_time.start()
+
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_ssh.stop()
+ self._mock_time.stop()
+
+ def test_pktgen_dpdk_successful_setup(self):
args = {
'options': {'packetsize': 60},
@@ -47,66 +58,66 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
p.setup()
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
self.assertIsNotNone(p.server)
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
- def test_pktgen_dpdk_successful_get_port_ip(self, mock_ssh, mock_time):
+ def test_pktgen_dpdk_successful_get_port_ip(self):
args = {
'options': {'packetsize': 60},
}
p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
+ p.server = self.mock_ssh.SSH.from_node()
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
utils.get_port_ip(p.server, "eth1")
- mock_ssh.SSH.from_node().execute.assert_called_with(
+ self.mock_ssh.SSH.from_node().execute.assert_called_with(
"ifconfig eth1 |grep 'inet addr' |awk '{print $2}' |cut -d ':' -f2 ")
- def test_pktgen_dpdk_unsuccessful_get_port_ip(self, mock_ssh, mock_time):
+ def test_pktgen_dpdk_unsuccessful_get_port_ip(self):
args = {
'options': {'packetsize': 60},
}
p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
+ p.server = self.mock_ssh.SSH.from_node()
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
+ self.mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, utils.get_port_ip, p.server, "eth1")
- def test_pktgen_dpdk_successful_get_port_mac(self, mock_ssh, mock_time):
+ def test_pktgen_dpdk_successful_get_port_mac(self):
args = {
'options': {'packetsize': 60},
}
p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
+ p.server = self.mock_ssh.SSH.from_node()
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
utils.get_port_mac(p.server, "eth1")
- mock_ssh.SSH.from_node().execute.assert_called_with(
+ self.mock_ssh.SSH.from_node().execute.assert_called_with(
"ifconfig |grep HWaddr |grep eth1 |awk '{print $5}' ")
- def test_pktgen_dpdk_unsuccessful_get_port_mac(self, mock_ssh, mock_time):
+ def test_pktgen_dpdk_unsuccessful_get_port_mac(self):
args = {
'options': {'packetsize': 60},
}
p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
+ p.server = self.mock_ssh.SSH.from_node()
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
+ self.mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, utils.get_port_mac, p.server, "eth1")
- def test_pktgen_dpdk_successful_no_sla(self, mock_ssh, mock_time):
+ def test_pktgen_dpdk_successful_no_sla(self):
args = {
'options': {'packetsize': 60},
@@ -116,7 +127,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
sample_output = '100\n110\n112\n130\n149\n150\n90\n150\n200\n162\n'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
# with python 3 we get float, might be due python division changes
@@ -125,7 +136,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
delta = result['avg_latency'] - 132
self.assertLessEqual(delta, 1)
- def test_pktgen_dpdk_successful_sla(self, mock_ssh, mock_time):
+ def test_pktgen_dpdk_successful_sla(self):
args = {
'options': {'packetsize': 60},
@@ -136,13 +147,13 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
sample_output = '100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
p.run(result)
self.assertEqual(result, {"avg_latency": 100})
- def test_pktgen_dpdk_unsuccessful_sla(self, mock_ssh, mock_time):
+ def test_pktgen_dpdk_unsuccessful_sla(self):
args = {
'options': {'packetsize': 60},
@@ -152,14 +163,14 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- p.server = mock_ssh.SSH.from_node()
- p.client = mock_ssh.SSH.from_node()
+ p.server = self.mock_ssh.SSH.from_node()
+ p.client = self.mock_ssh.SSH.from_node()
sample_output = '100\n110\n112\n130\n149\n150\n90\n150\n200\n162\n'
- mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
self.assertRaises(AssertionError, p.run, result)
- def test_pktgen_dpdk_unsuccessful_script_error(self, mock_ssh, mock_time):
+ def test_pktgen_dpdk_unsuccessful_script_error(self):
args = {
'options': {'packetsize': 60},
@@ -169,7 +180,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
- mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
+ self.mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, p.run, result)
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
index d34097008..c2e35af75 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
@@ -20,7 +20,6 @@ from yardstick.benchmark.scenarios.networking import pktgen_dpdk_throughput
@mock.patch('yardstick.benchmark.scenarios.networking.pktgen_dpdk_throughput.ssh')
-@mock.patch('yardstick.benchmark.scenarios.networking.pktgen_dpdk_throughput.time')
class PktgenDPDKTestCase(unittest.TestCase):
def setUp(self):
@@ -37,7 +36,16 @@ class PktgenDPDKTestCase(unittest.TestCase):
}
}
- def test_pktgen_dpdk_throughput_successful_setup(self, mock__time, mock_ssh):
+ self._mock_time = mock.patch(
+ 'yardstick.benchmark.scenarios.networking.pktgen_dpdk_throughput.time')
+ self.mock_time = self._mock_time.start()
+
+ self.addCleanup(self._cleanup)
+
+ def _cleanup(self):
+ self._mock_time.stop()
+
+ def test_pktgen_dpdk_throughput_successful_setup(self, mock_ssh):
args = {
'options': {'packetsize': 60},
}
@@ -47,9 +55,9 @@ class PktgenDPDKTestCase(unittest.TestCase):
mock_ssh.SSH().execute.return_value = (0, '', '')
self.assertIsNotNone(p.server)
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
- def test_pktgen_dpdk_throughput_successful_no_sla(self, mock__time, mock_ssh):
+ def test_pktgen_dpdk_throughput_successful_no_sla(self, mock_ssh):
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
}
@@ -75,7 +83,7 @@ class PktgenDPDKTestCase(unittest.TestCase):
expected_result["packetsize"] = 60
self.assertEqual(result, expected_result)
- def test_pktgen_dpdk_throughput_successful_sla(self, mock__time, mock_ssh):
+ def test_pktgen_dpdk_throughput_successful_sla(self, mock_ssh):
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
'sla': {'max_ppm': 10000}
@@ -101,7 +109,7 @@ class PktgenDPDKTestCase(unittest.TestCase):
expected_result["packetsize"] = 60
self.assertEqual(result, expected_result)
- def test_pktgen_dpdk_throughput_unsuccessful_sla(self, mock__time, mock_ssh):
+ def test_pktgen_dpdk_throughput_unsuccessful_sla(self, mock_ssh):
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
'sla': {'max_ppm': 1000}
@@ -122,7 +130,8 @@ class PktgenDPDKTestCase(unittest.TestCase):
mock_ssh.SSH().execute.return_value = (0, sample_output, '')
self.assertRaises(AssertionError, p.run, result)
- def test_pktgen_dpdk_throughput_unsuccessful_script_error(self, mock__time, mock_ssh):
+ def test_pktgen_dpdk_throughput_unsuccessful_script_error(
+ self, mock_ssh):
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
'sla': {'max_ppm': 1000}
@@ -137,7 +146,7 @@ class PktgenDPDKTestCase(unittest.TestCase):
mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR')
self.assertRaises(RuntimeError, p.run, result)
- def test_pktgen_dpdk_throughput_is_dpdk_setup(self, mock__time, mock_ssh):
+ def test_pktgen_dpdk_throughput_is_dpdk_setup(self, mock_ssh):
args = {
'options': {'packetsize': 60},
}
@@ -151,7 +160,7 @@ class PktgenDPDKTestCase(unittest.TestCase):
mock_ssh.SSH().execute.assert_called_with(
"ip a | grep eth1 2>/dev/null")
- def test_pktgen_dpdk_throughput_dpdk_setup(self, mock__time, mock_ssh):
+ def test_pktgen_dpdk_throughput_dpdk_setup(self, mock_ssh):
args = {
'options': {'packetsize': 60},
}
@@ -163,9 +172,9 @@ class PktgenDPDKTestCase(unittest.TestCase):
p.dpdk_setup()
- self.assertEqual(p.dpdk_setup_done, True)
+ self.assertTrue(p.dpdk_setup_done)
- def test_pktgen_dpdk_throughput_dpdk_get_result(self, mock__time, mock_ssh):
+ def test_pktgen_dpdk_throughput_dpdk_get_result(self, mock_ssh):
args = {
'options': {'packetsize': 60},
}
@@ -180,8 +189,10 @@ class PktgenDPDKTestCase(unittest.TestCase):
mock_ssh.SSH().execute.assert_called_with(
"sudo /dpdk/destdir/bin/dpdk-procinfo -- --stats-reset > /dev/null 2>&1")
+
def main():
unittest.main()
+
if __name__ == '__main__':
main()
diff --git a/tests/unit/benchmark/scenarios/networking/test_vsperf.py b/tests/unit/benchmark/scenarios/networking/test_vsperf.py
index cbbfc2b34..be8ac55d0 100644
--- a/tests/unit/benchmark/scenarios/networking/test_vsperf.py
+++ b/tests/unit/benchmark/scenarios/networking/test_vsperf.py
@@ -66,7 +66,7 @@ class VsperfTestCase(unittest.TestCase):
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
def test_vsperf_teardown(self, mock_ssh, mock_subprocess):
p = vsperf.Vsperf(self.args, self.ctx)
@@ -77,10 +77,10 @@ class VsperfTestCase(unittest.TestCase):
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
p.teardown()
- self.assertEqual(p.setup_done, False)
+ self.assertFalse(p.setup_done)
def test_vsperf_run_ok(self, mock_ssh, mock_subprocess):
p = vsperf.Vsperf(self.args, self.ctx)
diff --git a/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py b/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
index 5759f0a90..fbe3ed804 100644
--- a/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
+++ b/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
@@ -27,7 +27,6 @@ from yardstick.benchmark.scenarios.networking import vsperf_dpdk
@mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.subprocess')
-@mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.ssh')
class VsperfDPDKTestCase(unittest.TestCase):
def setUp(self):
@@ -63,7 +62,16 @@ class VsperfDPDKTestCase(unittest.TestCase):
}
}
- def test_vsperf_dpdk_setup(self, mock_ssh, mock_subprocess):
+ self._mock_ssh = mock.patch(
+ 'yardstick.benchmark.scenarios.networking.vsperf_dpdk.ssh')
+ self.mock_ssh = self._mock_ssh.start()
+
+ self.addCleanup(self._cleanup)
+
+ def _cleanup(self):
+ self._mock_ssh.stop()
+
+ def test_vsperf_dpdk_setup(self, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
@@ -71,9 +79,9 @@ class VsperfDPDKTestCase(unittest.TestCase):
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
- def test_vsperf_dpdk_teardown(self, mock_ssh, mock_subprocess):
+ def test_vsperf_dpdk_teardown(self, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
@@ -81,12 +89,12 @@ class VsperfDPDKTestCase(unittest.TestCase):
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
p.teardown()
- self.assertEqual(p.setup_done, False)
+ self.assertFalse(p.setup_done)
- def test_vsperf_dpdk_is_dpdk_setup_no(self, mock_ssh, mock_subprocess):
+ def test_vsperf_dpdk_is_dpdk_setup_no(self, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
@@ -94,15 +102,15 @@ class VsperfDPDKTestCase(unittest.TestCase):
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
# is_dpdk_setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, 'dummy', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, 'dummy', '')
result = p._is_dpdk_setup()
- self.assertEqual(result, False)
+ self.assertFalse(result)
- def test_vsperf_dpdk_is_dpdk_setup_yes(self, mock_ssh, mock_subprocess):
+ def test_vsperf_dpdk_is_dpdk_setup_yes(self, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
@@ -110,16 +118,16 @@ class VsperfDPDKTestCase(unittest.TestCase):
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
# is_dpdk_setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
result = p._is_dpdk_setup()
- self.assertEqual(result, True)
+ self.assertTrue(result)
- @mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.time')
- def test_vsperf_dpdk_dpdk_setup_first(self, mock_time, mock_ssh, mock_subprocess):
+ @mock.patch('time.sleep')
+ def test_vsperf_dpdk_dpdk_setup_first(self, _, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
@@ -127,61 +135,61 @@ class VsperfDPDKTestCase(unittest.TestCase):
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
# is_dpdk_setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, 'dummy', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, 'dummy', '')
p.dpdk_setup()
- self.assertEqual(p._is_dpdk_setup(), False)
- self.assertEqual(p.dpdk_setup_done, True)
+ self.assertFalse(p._is_dpdk_setup())
+ self.assertTrue(p.dpdk_setup_done)
- @mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.time')
- def test_vsperf_dpdk_dpdk_setup_next(self, mock_time, mock_ssh, mock_subprocess):
+ @mock.patch('time.sleep')
+ def test_vsperf_dpdk_dpdk_setup_next(self, _, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
p.dpdk_setup()
- self.assertEqual(p._is_dpdk_setup(), True)
- self.assertEqual(p.dpdk_setup_done, True)
+ self.assertTrue(p._is_dpdk_setup())
+ self.assertTrue(p.dpdk_setup_done)
- @mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.time')
- def test_vsperf_dpdk_dpdk_setup_fail(self, mock_time, mock_ssh, mock_subprocess):
+ @mock.patch('time.sleep')
+ def test_vsperf_dpdk_dpdk_setup_fail(self, _, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()
self.assertIsNotNone(p.client)
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
- self.assertEqual(p.setup_done, True)
+ self.mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
+ self.assertTrue(p.setup_done)
self.assertRaises(RuntimeError, p.dpdk_setup)
- @mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.time')
- def test_vsperf_dpdk_run_ok(self, mock_time, mock_ssh, mock_subprocess):
+ @mock.patch('time.sleep')
+ def test_vsperf_dpdk_run_ok(self, _, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
# run() specific mocks
mock_subprocess.call().execute.return_value = None
- mock_ssh.SSH.from_node().execute.return_value = (
+ self.mock_ssh.SSH.from_node().execute.return_value = (
0, 'throughput_rx_fps\r\n14797660.000\r\n', '')
result = {}
@@ -189,42 +197,41 @@ class VsperfDPDKTestCase(unittest.TestCase):
self.assertEqual(result['throughput_rx_fps'], '14797660.000')
- def test_vsperf_dpdk_run_falied_vsperf_execution(self, mock_ssh,
- mock_subprocess):
+ def test_vsperf_dpdk_run_falied_vsperf_execution(self, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
# run() specific mocks
mock_subprocess.call().execute.return_value = None
mock_subprocess.call().execute.return_value = None
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
result = {}
self.assertRaises(RuntimeError, p.run, result)
- def test_vsperf_dpdk_run_falied_csv_report(self, mock_ssh, mock_subprocess):
+ def test_vsperf_dpdk_run_falied_csv_report(self, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
# run() specific mocks
mock_subprocess.call().execute.return_value = None
mock_subprocess.call().execute.return_value = None
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
- mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
+ self.mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
result = {}
self.assertRaises(RuntimeError, p.run, result)
diff --git a/tests/unit/benchmark/scenarios/parser/test_parser.py b/tests/unit/benchmark/scenarios/parser/test_parser.py
index 59b98a092..ee2bbc07d 100644
--- a/tests/unit/benchmark/scenarios/parser/test_parser.py
+++ b/tests/unit/benchmark/scenarios/parser/test_parser.py
@@ -9,50 +9,67 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Unittest for yardstick.benchmark.scenarios.parser.Parser
-
-from __future__ import absolute_import
+import subprocess
import unittest
-
import mock
+
from oslo_serialization import jsonutils
from yardstick.benchmark.scenarios.parser import parser
-@mock.patch('yardstick.benchmark.scenarios.parser.parser.subprocess')
class ParserTestCase(unittest.TestCase):
def setUp(self):
- pass
-
- def test_parser_successful_setup(self, mock_subprocess):
-
- p = parser.Parser({}, {})
- mock_subprocess.call().return_value = 0
- p.setup()
- self.assertEqual(p.setup_done, True)
-
- def test_parser_successful(self, mock_subprocess):
args = {
'options': {'yangfile': '/root/yardstick/samples/yang.yaml',
'toscafile': '/root/yardstick/samples/tosca.yaml'},
}
- p = parser.Parser(args, {})
+ self.scenario = parser.Parser(scenario_cfg=args, context_cfg={})
+
+ self._mock_popen = mock.patch.object(subprocess, 'Popen')
+ self.mock_popen = self._mock_popen.start()
+ self._mock_call = mock.patch.object(subprocess, 'call')
+ self.mock_call = self._mock_call.start()
+
+ self.addCleanup(self._stop_mock)
+
+ def _stop_mock(self):
+ self._mock_popen.stop()
+ self._mock_call.stop()
+
+ def test_setup_successful(self):
+
+ self.mock_call.return_value = 0
+ self.scenario.setup()
+ self.assertTrue(self.scenario.setup_done)
+
+ def test_run_successful(self):
+
result = {}
- mock_subprocess.call().return_value = 0
- sample_output = '{"yangtotosca": "success"}'
- p.run(result)
- expected_result = jsonutils.loads(sample_output)
+ self.mock_popen().returncode = 0
+
+ expected_result = jsonutils.loads('{"yangtotosca": "success"}')
+
+ self.scenario.run(result)
+ self.assertEqual(result, expected_result)
+
+ def test_run_fail(self):
+ result = {}
+
+ self.mock_popen().returncode = 1
+ expected_result = jsonutils.loads('{"yangtotosca": "fail"}')
+
+ self.scenario.run(result)
+ self.assertEqual(result, expected_result)
- def test_parser_teardown_successful(self, mock_subprocess):
+ def test_teardown_successful(self):
- p = parser.Parser({}, {})
- mock_subprocess.call().return_value = 0
- p.teardown()
- self.assertEqual(p.teardown_done, True)
+ self.mock_call.return_value = 0
+ self.scenario.teardown()
+ self.assertTrue(self.scenario.teardown_done)
def main():
diff --git a/tests/unit/benchmark/scenarios/storage/test_fio.py b/tests/unit/benchmark/scenarios/storage/test_fio.py
index 17594b9f4..0cffea224 100644
--- a/tests/unit/benchmark/scenarios/storage/test_fio.py
+++ b/tests/unit/benchmark/scenarios/storage/test_fio.py
@@ -53,7 +53,7 @@ class FioTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
def test_fio_job_file_successful_setup(self, mock_ssh):
@@ -67,7 +67,7 @@ class FioTestCase(unittest.TestCase):
mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
+ self.assertTrue(p.setup_done)
def test_fio_successful_no_sla(self, mock_ssh):