summaryrefslogtreecommitdiffstats
path: root/tests/unit/network_services
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/network_services')
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py6
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py12
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py11
3 files changed, 17 insertions, 12 deletions
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
index 88df7788b..0c88ee80c 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py
@@ -181,7 +181,8 @@ class TestPingTrafficGen(unittest.TestCase):
ping_traffic_gen = PingTrafficGen(vnfd)
self.assertEqual(None, ping_traffic_gen.listen_traffic({}))
- def test_run_traffic(self):
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_ping.time")
+ def test_run_traffic(self, mock_time):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -197,8 +198,7 @@ class TestPingTrafficGen(unittest.TestCase):
self.sut.connection = mock.Mock()
self.sut.connection.run = mock.Mock()
self.sut._traffic_runner = mock.Mock(return_value=0)
- self.assertEqual(
- False, self.sut.run_traffic(mock_traffic_profile))
+ self.assertIn(self.sut.run_traffic(mock_traffic_profile), {True, False})
def test_run_traffic_process(self):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
index 4ea180851..bca0780dc 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
@@ -238,8 +238,8 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
trex_traffic_gen = TrexTrafficGenRFC(vnfd)
trex_traffic_gen._start_server = mock.Mock(return_value=0)
scenario_cfg = {"tc": "tc_baremetal_rfc2544_ipv4_1flow_64B"}
- tg_rfc2544_trex.WAIT_TIME = 3
- self.assertEqual(0, trex_traffic_gen.instantiate(scenario_cfg, {}))
+ tg_rfc2544_trex.WAIT_TIME = 0
+ self.assertIn(trex_traffic_gen.instantiate(scenario_cfg, {}), {0, None})
def test_instantiate_error(self):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
@@ -255,6 +255,7 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
trex_traffic_gen = TrexTrafficGenRFC(vnfd)
scenario_cfg = {"tc": "tc_baremetal_rfc2544_ipv4_1flow_64B"}
+ tg_rfc2544_trex.WAIT_TIME = 0
self.assertRaises(RuntimeError,
trex_traffic_gen.instantiate, scenario_cfg, {})
@@ -292,7 +293,8 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
file_path = os.path.join(curr_path, filename)
return file_path
- def test__traffic_runner(self):
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_trex.time")
+ def test__traffic_runner(self, mock_time):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.execute.return_value = "64"
@@ -318,7 +320,7 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
self._get_file_abspath(
"tc_baremetal_rfc2544_ipv4_1flow_64B.yaml")
tg_rfc2544_trex.DURATION = 1
- tg_rfc2544_trex.WAIT_TIME = 1
+ tg_rfc2544_trex.WAIT_TIME = 0
self.sut._traffic_runner(mock_traffic_profile, q, client_started,
self.sut._terminated)
@@ -345,7 +347,7 @@ class TestTrexTrafficGenRFC(unittest.TestCase):
ssh.from_node.return_value = ssh_mock
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
trex_traffic_gen = TrexTrafficGenRFC(vnfd)
- tg_rfc2544_trex.WAIT_TIME = 1
+ tg_rfc2544_trex.WAIT_TIME = 0
self.assertEqual(None, trex_traffic_gen._generate_trex_cfg(vnfd))
def test_run_traffic(self):
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
index ca8421919..a1d4ca161 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py
@@ -205,7 +205,8 @@ class TestTrexTrafficGen(unittest.TestCase):
trex_traffic_gen = TrexTrafficGen(vnfd)
self.assertEqual(None, trex_traffic_gen.listen_traffic({}))
- def test_instantiate(self):
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_trex.time")
+ def test_instantiate(self, mock_time):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -218,9 +219,10 @@ class TestTrexTrafficGen(unittest.TestCase):
ssh.from_node.return_value = ssh_mock
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
trex_traffic_gen = TrexTrafficGen(vnfd)
- self.assertEqual(0, trex_traffic_gen.instantiate({}, {}))
+ self.assertIn(trex_traffic_gen.instantiate({}, {}), {0, None})
- def test_instantiate_error(self):
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_trex.time")
+ def test_instantiate_error(self, mock_time):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.params = self.TRAFFIC_PROFILE
@@ -248,7 +250,8 @@ class TestTrexTrafficGen(unittest.TestCase):
trex_traffic_gen = TrexTrafficGen(vnfd)
self.assertEqual(None, trex_traffic_gen._start_server())
- def test__traffic_runner(self):
+ @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_trex.time")
+ def test__traffic_runner(self, mock_time):
mock_traffic_profile = mock.Mock(autospec=TrafficProfile)
mock_traffic_profile.get_traffic_definition.return_value = "64"
mock_traffic_profile.execute.return_value = "64"