Code Review
/
yardstick.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Modify fuel_baremetal pod config file"
[yardstick.git]
/
tests
/
unit
/
network_services
/
vnf_generic
/
vnf
/
test_cgnapt_vnf.py
diff --git
a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
index
0a4c124
..
f2ce18f
100644
(file)
--- a/
tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
+++ b/
tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py
@@
-15,14
+15,11
@@
# limitations under the License.
#
# limitations under the License.
#
-from __future__ import absolute_import
-
+from copy import deepcopy
import os
import unittest
import mock
import os
import unittest
import mock
-from copy import deepcopy
-
from tests.unit import STL_MOCKS
from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
from tests.unit import STL_MOCKS
from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh
@@
-41,7
+38,7
@@
TEST_FILE_YAML = 'nsb_test_case.yaml'
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper'
-name = 'vnf__
1
'
+name = 'vnf__
0
'
class TestCgnaptApproxSetupEnvHelper(unittest.TestCase):
class TestCgnaptApproxSetupEnvHelper(unittest.TestCase):
@@
-72,13
+69,12
@@
link 1 up
self.assertNotIn("This is a header", out)
def test__get_cgnapt_config(self):
self.assertNotIn("This is a header", out)
def test__get_cgnapt_config(self):
- vnfd_helper = mock.Mock()
+ vnfd_helper = mock.M
agicM
ock()
vnfd_helper.port_pairs.uplink_ports = [{"name": 'a'}, {"name": "b"}, {"name": "c"}]
helper = CgnaptApproxSetupEnvHelper(vnfd_helper, mock.Mock(), mock.Mock())
vnfd_helper.port_pairs.uplink_ports = [{"name": 'a'}, {"name": "b"}, {"name": "c"}]
helper = CgnaptApproxSetupEnvHelper(vnfd_helper, mock.Mock(), mock.Mock())
- helper._get_ports_gateway = mock.Mock(side_effect=[3, 5, 2])
- result = helper._get_cgnapt_config([{"name": 'a'}, {}, {"name": "b"}, {}, {"name": "c"}])
- self.assertEqual(result, [3, 5, 2])
+ result = helper._get_cgnapt_config()
+ self.assertIsNotNone(result)
def test_scale(self):
helper = CgnaptApproxSetupEnvHelper(mock.Mock(), mock.Mock(), mock.Mock())
def test_scale(self):
helper = CgnaptApproxSetupEnvHelper(mock.Mock(), mock.Mock(), mock.Mock())
@@
-162,7
+158,7
@@
class TestCgnaptApproxVnf(unittest.TestCase):
'rfc2544': {
'allowed_drop_rate': '0.8 - 1',
},
'rfc2544': {
'allowed_drop_rate': '0.8 - 1',
},
- 'vnf__
1
': {
+ 'vnf__
0
': {
'napt': 'dynamic',
'vnf_config': {
'lb_config': 'SW',
'napt': 'dynamic',
'vnf_config': {
'lb_config': 'SW',
@@
-172,6
+168,10
@@
class TestCgnaptApproxVnf(unittest.TestCase):
'worker_threads': 1,
},
},
'worker_threads': 1,
},
},
+ 'flow': {'count': 1,
+ 'dst_ip': [{'tg__1': 'xe0'}],
+ 'public_ip': [''],
+ 'src_ip': [{'tg__0': 'xe0'}]},
},
'task_id': 'a70bdf4a-8e67-47a3-9dc1-273c14506eb7',
'task_path': '/tmp',
},
'task_id': 'a70bdf4a-8e67-47a3-9dc1-273c14506eb7',
'task_path': '/tmp',
@@
-185,15
+185,11
@@
class TestCgnaptApproxVnf(unittest.TestCase):
'type': 'Duration',
},
'traffic_profile': 'ipv4_throughput_acl.yaml',
'type': 'Duration',
},
'traffic_profile': 'ipv4_throughput_acl.yaml',
- 'traffic_options': {
- 'flow': 'ipv4_Packets_acl.yaml',
- 'imix': 'imix_voice.yaml',
- },
- 'type': 'ISB',
+ 'type': 'NSPerf',
'nodes': {
'nodes': {
- 'tg__2': 'trafficgen_2.yardstick',
'tg__1': 'trafficgen_1.yardstick',
'tg__1': 'trafficgen_1.yardstick',
- 'vnf__1': 'vnf.yardstick',
+ 'tg__0': 'trafficgen_0.yardstick',
+ 'vnf__0': 'vnf.yardstick',
},
'topology': 'vpe-tg-topology-baremetal.yaml',
}
},
'topology': 'vpe-tg-topology-baremetal.yaml',
}
@@
-253,9
+249,9
@@
class TestCgnaptApproxVnf(unittest.TestCase):
'password': 'r00t',
'VNF model': 'tg_rfc2544_tpl.yaml',
'user': 'root'},
'password': 'r00t',
'VNF model': 'tg_rfc2544_tpl.yaml',
'user': 'root'},
- 'vnf__
1
':
+ 'vnf__
0
':
{'name': 'vnf.yardstick',
{'name': 'vnf.yardstick',
- 'vnfd-id-ref': 'vnf__
1
',
+ 'vnfd-id-ref': 'vnf__
0
',
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens786f0',
'ip': '1.2.1.1',
'interfaces':
{'xe0': {'local_iface_name': 'ens786f0',
@@
-306,18
+302,20
@@
class TestCgnaptApproxVnf(unittest.TestCase):
def setUp(self):
self.scenario_cfg = deepcopy(self.SCENARIO_CFG)
def setUp(self):
self.scenario_cfg = deepcopy(self.SCENARIO_CFG)
- def test___init__(self,
mock_proces
s):
+ def test___init__(self,
*arg
s):
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
self.assertIsNone(cgnapt_approx_vnf._vnf_process)
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch(SSH_HELPER)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
self.assertIsNone(cgnapt_approx_vnf._vnf_process)
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch(SSH_HELPER)
- def test_collect_kpi(self, ssh,
mock_time, mock_proces
s):
+ def test_collect_kpi(self, ssh,
*arg
s):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
+ cgnapt_approx_vnf._vnf_process = mock.MagicMock(
+ **{"is_alive.return_value": True, "exitcode": None})
cgnapt_approx_vnf.q_in = mock.MagicMock()
cgnapt_approx_vnf.q_out = mock.MagicMock()
cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
cgnapt_approx_vnf.q_in = mock.MagicMock()
cgnapt_approx_vnf.q_out = mock.MagicMock()
cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
@@
-327,7
+325,7
@@
class TestCgnaptApproxVnf(unittest.TestCase):
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch(SSH_HELPER)
@mock.patch('yardstick.network_services.vnf_generic.vnf.sample_vnf.time')
@mock.patch(SSH_HELPER)
- def test_vnf_execute_command(self, ssh,
mock_time, mock_proces
s):
+ def test_vnf_execute_command(self, ssh,
*arg
s):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@
-339,7
+337,7
@@
class TestCgnaptApproxVnf(unittest.TestCase):
self.assertEqual("", cgnapt_approx_vnf.vnf_execute(cmd))
@mock.patch(SSH_HELPER)
self.assertEqual("", cgnapt_approx_vnf.vnf_execute(cmd))
@mock.patch(SSH_HELPER)
- def test_get_stats(self, ssh,
mock_proces
s):
+ def test_get_stats(self, ssh,
*arg
s):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@
-361,7
+359,7
@@
class TestCgnaptApproxVnf(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.cgnapt_vnf.eval")
@mock.patch('yardstick.network_services.vnf_generic.vnf.cgnapt_vnf.open')
@mock.patch(SSH_HELPER)
@mock.patch("yardstick.network_services.vnf_generic.vnf.cgnapt_vnf.eval")
@mock.patch('yardstick.network_services.vnf_generic.vnf.cgnapt_vnf.open')
@mock.patch(SSH_HELPER)
- def test_run_vcgnapt(self, ssh,
mock_hex, mock_eval, mock_open, mock_proces
s):
+ def test_run_vcgnapt(self, ssh,
*arg
s):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@
-376,7
+374,7
@@
class TestCgnaptApproxVnf(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
@mock.patch(SSH_HELPER)
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.Context")
@mock.patch(SSH_HELPER)
- def test_instantiate(self, ssh,
mock_context, mock_proces
s):
+ def test_instantiate(self, ssh,
*arg
s):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@
-388,19
+386,13
@@
class TestCgnaptApproxVnf(unittest.TestCase):
'rules': ""}}
cgnapt_approx_vnf.q_out.put("pipeline>")
cgnapt_vnf.WAIT_TIME = 3
'rules': ""}}
cgnapt_approx_vnf.q_out.put("pipeline>")
cgnapt_vnf.WAIT_TIME = 3
- self.scenario_cfg.update({"nodes": {"vnf__
1
": ""}})
+ self.scenario_cfg.update({"nodes": {"vnf__
0
": ""}})
self.assertIsNone(cgnapt_approx_vnf.instantiate(self.scenario_cfg,
self.context_cfg))
self.assertIsNone(cgnapt_approx_vnf.instantiate(self.scenario_cfg,
self.context_cfg))
- def test_scale(self, mock_process):
- vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
- cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
- flavor = ""
- self.assertRaises(NotImplementedError, cgnapt_approx_vnf.scale, flavor)
-
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@mock.patch(SSH_HELPER)
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@mock.patch(SSH_HELPER)
- def test_terminate(self, ssh,
mock_time, mock_proces
s):
+ def test_terminate(self, ssh,
*arg
s):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@
-416,7
+408,7
@@
class TestCgnaptApproxVnf(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@mock.patch(SSH_HELPER)
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@mock.patch(SSH_HELPER)
- def test__vnf_up_post(self, ssh,
mock_time, mock_proces
s):
+ def test__vnf_up_post(self, ssh,
*arg
s):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@
-432,7
+424,7
@@
class TestCgnaptApproxVnf(unittest.TestCase):
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@mock.patch(SSH_HELPER)
@mock.patch("yardstick.network_services.vnf_generic.vnf.sample_vnf.time")
@mock.patch(SSH_HELPER)
- def test__vnf_up_post_short(self, ssh,
mock_time, mock_proces
s):
+ def test__vnf_up_post_short(self, ssh,
*arg
s):
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
mock_ssh(ssh)
vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
@@
-443,7
+435,3
@@
class TestCgnaptApproxVnf(unittest.TestCase):
cgnapt_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg
cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
cgnapt_approx_vnf._vnf_up_post()
cgnapt_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg
cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
cgnapt_approx_vnf._vnf_up_post()
-
-
-if __name__ == '__main__':
- unittest.main()