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