Initial refactor of N2VC
[osm/N2VC.git] / tests / integration / test_multivdu_multicharm.py
1 # Copyright 2019 Canonical Ltd.
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 #
14
15 """
16 Deploy a multi-vdu, multi-charm VNF
17 """
18
19 import asyncio
20 import logging
21 import pytest
22 from .. import base
23
24
25 # @pytest.mark.serial
26 class TestCharm(base.TestN2VC):
27
28 NSD_YAML = """
29 nsd:nsd-catalog:
30 nsd:
31 - id: multivdumulticharm-ns
32 name: multivdumulticharm-ns
33 short-name: multivdumulticharm-ns
34 description: NS with 1 VNF connected by datanet and mgmtnet VLs
35 version: '1.0'
36 logo: osm.png
37 constituent-vnfd:
38 - vnfd-id-ref: multivdumulticharm-vnf
39 member-vnf-index: '1'
40 vld:
41 - id: mgmtnet
42 name: mgmtnet
43 short-name: mgmtnet
44 type: ELAN
45 mgmt-network: 'true'
46 vim-network-name: mgmt
47 vnfd-connection-point-ref:
48 - vnfd-id-ref: multivdumulticharm-vnf
49 member-vnf-index-ref: '1'
50 vnfd-connection-point-ref: vnf-mgmt
51 - vnfd-id-ref: multivdumulticharm-vnf
52 member-vnf-index-ref: '2'
53 vnfd-connection-point-ref: vnf-mgmt
54 - id: datanet
55 name: datanet
56 short-name: datanet
57 type: ELAN
58 vnfd-connection-point-ref:
59 - vnfd-id-ref: multivdumulticharm-vnf
60 member-vnf-index-ref: '1'
61 vnfd-connection-point-ref: vnf-data
62 - vnfd-id-ref: multivdumulticharm-vnf
63 member-vnf-index-ref: '2'
64 vnfd-connection-point-ref: vnf-data
65 """
66
67 VNFD_YAML = """
68 vnfd:vnfd-catalog:
69 vnfd:
70 - id: multivdumulticharm-vnf
71 name: multivdumulticharm-vnf
72 short-name: multivdumulticharm-vnf
73 version: '1.0'
74 description: A VNF consisting of 1 VDUs w/proxy charm
75 logo: osm.png
76 connection-point:
77 - id: vnf-mgmt
78 name: vnf-mgmt
79 short-name: vnf-mgmt
80 type: VPORT
81 - id: vnf-data
82 name: vnf-data
83 short-name: vnf-data
84 type: VPORT
85 mgmt-interface:
86 cp: vnf-mgmt
87 internal-vld:
88 - id: internal
89 name: internal
90 short-name: internal
91 type: ELAN
92 internal-connection-point:
93 - id-ref: mgmtVM-internal
94 - id-ref: dataVM-internal
95 vdu:
96 - id: mgmtVM
97 name: mgmtVM
98 image: xenial
99 count: '1'
100 vm-flavor:
101 vcpu-count: '1'
102 memory-mb: '1024'
103 storage-gb: '10'
104 interface:
105 - name: mgmtVM-eth0
106 position: '1'
107 type: EXTERNAL
108 virtual-interface:
109 type: VIRTIO
110 external-connection-point-ref: vnf-mgmt
111 - name: mgmtVM-eth1
112 position: '2'
113 type: INTERNAL
114 virtual-interface:
115 type: VIRTIO
116 internal-connection-point-ref: mgmtVM-internal
117 internal-connection-point:
118 - id: mgmtVM-internal
119 name: mgmtVM-internal
120 short-name: mgmtVM-internal
121 type: VPORT
122 cloud-init-file: cloud-config.txt
123 vdu-configuration:
124 juju:
125 charm: proxy-ci
126 proxy: true
127 initial-config-primitive:
128 - seq: '1'
129 name: test
130 - id: dataVM
131 name: dataVM
132 image: xenial
133 count: '1'
134 vm-flavor:
135 vcpu-count: '1'
136 memory-mb: '1024'
137 storage-gb: '10'
138 interface:
139 - name: dataVM-eth0
140 position: '1'
141 type: EXTERNAL
142 virtual-interface:
143 type: VIRTIO
144 external-connection-point-ref: vnf-mgmt
145 - name: dataVM-eth1
146 position: '2'
147 type: INTERNAL
148 virtual-interface:
149 type: VIRTIO
150 internal-connection-point-ref: dataVM-internal
151 internal-connection-point:
152 - id: dataVM-internal
153 name: dataVM-internal
154 short-name: dataVM-internal
155 type: VPORT
156 cloud-init-file: cloud-config.txt
157 vdu-configuration:
158 juju:
159 charm: proxy-ci
160 proxy: true
161 # Relation needs to map to the vdu providing or
162 # requiring, so that we can map to the deployed app.
163 relation:
164 - provides: dataVM:db
165 requires: mgmtVM:app
166 initial-config-primitive:
167 - seq: '1'
168 name: test
169
170 """
171
172 # @pytest.mark.serial
173 @pytest.mark.asyncio
174 async def test_multivdu_multicharm(self, event_loop):
175 """Deploy and execute the initial-config-primitive of a VNF."""
176
177 if self.nsd and self.vnfd:
178 vnf_index = 0
179
180 for config in self.get_config():
181 juju = config['juju']
182 charm = juju['charm']
183
184 await self.deploy(
185 vnf_index,
186 charm,
187 config,
188 event_loop,
189 )
190 vnf_index += 1
191
192 while await self.running():
193 logging.debug("Waiting for test to finish...")
194 await asyncio.sleep(15)
195 # assert False
196 logging.debug("test_multivdu_multicharm stopped")
197
198 return 'ok'