summaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/benchmark')
-rw-r--r--tests/unit/benchmark/contexts/test_heat.py28
-rw-r--r--tests/unit/benchmark/runner/test_base.py10
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_nstat.py6
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py19
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py17
5 files changed, 44 insertions, 36 deletions
diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py
index c739f33ff..ae57402c0 100644
--- a/tests/unit/benchmark/contexts/test_heat.py
+++ b/tests/unit/benchmark/contexts/test_heat.py
@@ -147,20 +147,20 @@ class HeatContextTestCase(unittest.TestCase):
'c': network2,
}
self.test_context.stack.outputs = {
- 'b': '10.20.30.45',
- 'b-subnet_id': 1,
- 'foo-a-subnet-cidr': '10.20.0.0/15',
- 'foo-a-subnet-gateway_ip': '10.20.30.1',
- 'b-mac_address': '00:01',
- 'b-device_id': 'dev21',
- 'b-network_id': 'net789',
- 'd': '40.30.20.15',
- 'd-subnet_id': 2,
- 'foo-c-subnet-cidr': '40.30.0.0/18',
- 'foo-c-subnet-gateway_ip': '40.30.20.254',
- 'd-mac_address': '00:10',
- 'd-device_id': 'dev43',
- 'd-network_id': 'net987',
+ u'b': u'10.20.30.45',
+ u'b-subnet_id': 1,
+ u'foo-a-subnet-cidr': u'10.20.0.0/15',
+ u'foo-a-subnet-gateway_ip': u'10.20.30.1',
+ u'b-mac_address': u'00:01',
+ u'b-device_id': u'dev21',
+ u'b-network_id': u'net789',
+ u'd': u'40.30.20.15',
+ u'd-subnet_id': 2,
+ u'foo-c-subnet-cidr': u'40.30.0.0/18',
+ u'foo-c-subnet-gateway_ip': u'40.30.20.254',
+ u'd-mac_address': u'00:10',
+ u'd-device_id': u'dev43',
+ u'd-network_id': u'net987',
}
server = mock.MagicMock()
server.ports = OrderedDict([
diff --git a/tests/unit/benchmark/runner/test_base.py b/tests/unit/benchmark/runner/test_base.py
index 6e72fa548..0313ef843 100644
--- a/tests/unit/benchmark/runner/test_base.py
+++ b/tests/unit/benchmark/runner/test_base.py
@@ -15,12 +15,15 @@ from __future__ import absolute_import
import unittest
import time
+from mock import mock
+
from yardstick.benchmark.runners.iteration import IterationRunner
class RunnerTestCase(unittest.TestCase):
- def test_get_output(self):
+ @mock.patch("yardstick.benchmark.runners.iteration.multiprocessing")
+ def test_get_output(self, mock_process):
runner = IterationRunner({})
runner.output_queue.put({'case': 'opnfv_yardstick_tc002'})
runner.output_queue.put({'criteria': 'PASS'})
@@ -30,7 +33,10 @@ class RunnerTestCase(unittest.TestCase):
'criteria': 'PASS'
}
- time.sleep(1)
+ for retries in range(1000):
+ time.sleep(0.01)
+ if not runner.output_queue.empty():
+ break
actual_result = runner.get_output()
self.assertEqual(idle_result, actual_result)
diff --git a/tests/unit/benchmark/scenarios/networking/test_nstat.py b/tests/unit/benchmark/scenarios/networking/test_nstat.py
index d66e91790..fe44cfdf4 100644
--- a/tests/unit/benchmark/scenarios/networking/test_nstat.py
+++ b/tests/unit/benchmark/scenarios/networking/test_nstat.py
@@ -43,7 +43,7 @@ class NstatTestCase(unittest.TestCase):
def test_nstat_successful_no_sla(self, mock_ssh):
options = {
- "duration": 0.1
+ "duration": 0
}
args = {
"options": options,
@@ -67,7 +67,7 @@ class NstatTestCase(unittest.TestCase):
def test_nstat_successful_sla(self, mock_ssh):
options = {
- "duration": 0.1
+ "duration": 0
}
sla = {
"IP_datagram_error_rate": 0.1
@@ -95,7 +95,7 @@ class NstatTestCase(unittest.TestCase):
def test_nstat_unsuccessful_cmd_error(self, mock_ssh):
options = {
- "duration": 0.1
+ "duration": 0
}
sla = {
"IP_datagram_error_rate": 0.1
diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
index e6998e443..b4b87522c 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py
@@ -20,6 +20,7 @@ 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):
@@ -38,7 +39,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
}
}
- def test_pktgen_dpdk_successful_setup(self, mock_ssh):
+ def test_pktgen_dpdk_successful_setup(self, mock_ssh, mock_time):
args = {
'options': {'packetsize': 60},
@@ -51,7 +52,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
self.assertIsNotNone(p.client)
self.assertEqual(p.setup_done, True)
- def test_pktgen_dpdk_successful_get_port_ip(self, mock_ssh):
+ def test_pktgen_dpdk_successful_get_port_ip(self, mock_ssh, mock_time):
args = {
'options': {'packetsize': 60},
@@ -66,7 +67,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
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):
+ def test_pktgen_dpdk_unsuccessful_get_port_ip(self, mock_ssh, mock_time):
args = {
'options': {'packetsize': 60},
@@ -78,7 +79,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
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):
+ def test_pktgen_dpdk_successful_get_port_mac(self, mock_ssh, mock_time):
args = {
'options': {'packetsize': 60},
@@ -93,7 +94,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
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):
+ def test_pktgen_dpdk_unsuccessful_get_port_mac(self, mock_ssh, mock_time):
args = {
'options': {'packetsize': 60},
@@ -105,7 +106,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
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):
+ def test_pktgen_dpdk_successful_no_sla(self, mock_ssh, mock_time):
args = {
'options': {'packetsize': 60},
@@ -124,7 +125,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
delta = result['avg_latency'] - 132
self.assertLessEqual(delta, 1)
- def test_pktgen_dpdk_successful_sla(self, mock_ssh):
+ def test_pktgen_dpdk_successful_sla(self, mock_ssh, mock_time):
args = {
'options': {'packetsize': 60},
@@ -141,7 +142,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
self.assertEqual(result, {"avg_latency": 100})
- def test_pktgen_dpdk_unsuccessful_sla(self, mock_ssh):
+ def test_pktgen_dpdk_unsuccessful_sla(self, mock_ssh, mock_time):
args = {
'options': {'packetsize': 60},
@@ -158,7 +159,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
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):
+ def test_pktgen_dpdk_unsuccessful_script_error(self, mock_ssh, mock_time):
args = {
'options': {'packetsize': 60},
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 0178165f8..d34097008 100644
--- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
+++ b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py
@@ -20,6 +20,7 @@ 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):
@@ -36,7 +37,7 @@ class PktgenDPDKTestCase(unittest.TestCase):
}
}
- def test_pktgen_dpdk_throughput_successful_setup(self, mock_ssh):
+ def test_pktgen_dpdk_throughput_successful_setup(self, mock__time, mock_ssh):
args = {
'options': {'packetsize': 60},
}
@@ -48,7 +49,7 @@ class PktgenDPDKTestCase(unittest.TestCase):
self.assertIsNotNone(p.client)
self.assertEqual(p.setup_done, True)
- def test_pktgen_dpdk_throughput_successful_no_sla(self, mock_ssh):
+ def test_pktgen_dpdk_throughput_successful_no_sla(self, mock__time, mock_ssh):
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
}
@@ -74,7 +75,7 @@ class PktgenDPDKTestCase(unittest.TestCase):
expected_result["packetsize"] = 60
self.assertEqual(result, expected_result)
- def test_pktgen_dpdk_throughput_successful_sla(self, mock_ssh):
+ def test_pktgen_dpdk_throughput_successful_sla(self, mock__time, mock_ssh):
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
'sla': {'max_ppm': 10000}
@@ -100,7 +101,7 @@ class PktgenDPDKTestCase(unittest.TestCase):
expected_result["packetsize"] = 60
self.assertEqual(result, expected_result)
- def test_pktgen_dpdk_throughput_unsuccessful_sla(self, mock_ssh):
+ def test_pktgen_dpdk_throughput_unsuccessful_sla(self, mock__time, mock_ssh):
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
'sla': {'max_ppm': 1000}
@@ -121,7 +122,7 @@ 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_ssh):
+ def test_pktgen_dpdk_throughput_unsuccessful_script_error(self, mock__time, mock_ssh):
args = {
'options': {'packetsize': 60, 'number_of_ports': 10},
'sla': {'max_ppm': 1000}
@@ -136,7 +137,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_ssh):
+ def test_pktgen_dpdk_throughput_is_dpdk_setup(self, mock__time, mock_ssh):
args = {
'options': {'packetsize': 60},
}
@@ -150,7 +151,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_ssh):
+ def test_pktgen_dpdk_throughput_dpdk_setup(self, mock__time, mock_ssh):
args = {
'options': {'packetsize': 60},
}
@@ -164,7 +165,7 @@ class PktgenDPDKTestCase(unittest.TestCase):
self.assertEqual(p.dpdk_setup_done, True)
- def test_pktgen_dpdk_throughput_dpdk_get_result(self, mock_ssh):
+ def test_pktgen_dpdk_throughput_dpdk_get_result(self, mock__time, mock_ssh):
args = {
'options': {'packetsize': 60},
}