Merge "[docs] Resolve "document isn't included in any toctree" warning"
[yardstick.git] / yardstick / tests / unit / network_services / vnf_generic / vnf / test_epc_vnf.py
1 # Copyright (c) 2018 Intel Corporation
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import copy
16 import unittest
17 import uuid
18
19 from yardstick.network_services.vnf_generic.vnf import epc_vnf
20
21 NAME = 'vnf__0'
22
23 VNFD = {
24     'vnfd:vnfd-catalog': {
25         'vnfd': [{
26             'id': 'EPCVnf',  # NSB python class mapping
27             'name': 'EPCVnf',
28             'short-name': 'EPCVnf',
29             'description': 'EPCVnf',
30             'mgmt-interface': {
31                 'vdu-id': 'vepcvnf-baremetal',
32                 'user': 'user',  # Value filled by vnfdgen
33                 'password': 'password',  # Value filled by vnfdgen
34                 'ip': 'ip'  # Value filled by vnfdgen
35             },
36             'vdu': [{
37                 'id': 'vepcvnf-baremetal',
38                 'name': 'vepc-vnf-baremetal',
39                 'description': 'vEPCVnf workload',
40                 'external-interface': []}],
41             'benchmark': {
42                 'kpi': []}}]}}
43
44
45 class TestEPCVnf(unittest.TestCase):
46
47     def setUp(self):
48         self._id = uuid.uuid1().int
49         self.vnfd = VNFD['vnfd:vnfd-catalog']['vnfd'][0]
50         self.epc_vnf = epc_vnf.EPCVnf(NAME, self.vnfd, self._id)
51
52     def test___init__(self, *args):
53         _epc_vnf = epc_vnf.EPCVnf(NAME, self.vnfd, self._id)
54         for x in {'user', 'password', 'ip'}:
55             self.assertEqual(self.vnfd['mgmt-interface'][x],
56                              _epc_vnf.vnfd_helper.mgmt_interface[x])
57         self.assertEqual(NAME, _epc_vnf.name)
58         self.assertEqual([], _epc_vnf.kpi)
59         self.assertEqual({}, _epc_vnf.config)
60         self.assertFalse(_epc_vnf.runs_traffic)
61
62     def test___init__missing_ip(self, *args):
63         _vnfd = copy.deepcopy(self.vnfd)
64         _vnfd['mgmt-interface'].pop('ip')
65         _epc_vnf = epc_vnf.EPCVnf(NAME, _vnfd, self._id)
66         for x in {'user', 'password'}:
67             self.assertEqual(_vnfd['mgmt-interface'][x],
68                              _epc_vnf.vnfd_helper.mgmt_interface[x])
69         self.assertNotIn('ip', _epc_vnf.vnfd_helper.mgmt_interface)
70         self.assertEqual(NAME, _epc_vnf.name)
71         self.assertEqual([], _epc_vnf.kpi)
72         self.assertEqual({}, _epc_vnf.config)
73         self.assertFalse(_epc_vnf.runs_traffic)
74
75     def test_instantiate(self):
76         self.assertIsNone(self.epc_vnf.instantiate({}, {}))
77
78     def test_wait_for_instantiate(self):
79         self.assertIsNone(self.epc_vnf.wait_for_instantiate())
80
81     def test_terminate(self):
82         self.assertIsNone(self.epc_vnf.terminate())
83
84     def test_scale(self):
85         self.assertIsNone(self.epc_vnf.scale())
86
87     def test_collect_kpi(self):
88         self.assertIsNone(self.epc_vnf.collect_kpi())
89
90     def test_start_collect(self):
91         self.assertIsNone(self.epc_vnf.start_collect())
92
93     def test_stop_collect(self):
94         self.assertIsNone(self.epc_vnf.stop_collect())