Merge "Complete Feature 6297"
[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 # Relation needs to map to the vdu providing or
114 # requiring, so that we can map to the deployed app.
115 relation:
116 - provides: dataVM:db
117 requires: mgmtVM:app
118 initial-config-primitive:
119 - seq: '1'
120 name: test
121 - id: dataVM
122 name: dataVM
123 image: xenial
124 count: '1'
125 vm-flavor:
126 vcpu-count: '1'
127 memory-mb: '1024'
128 storage-gb: '10'
129 interface:
130 - name: dataVM-eth0
131 position: '1'
132 type: EXTERNAL
133 virtual-interface:
134 type: VIRTIO
135 external-connection-point-ref: vnf-mgmt
136 - name: dataVM-eth1
137 position: '2'
138 type: INTERNAL
139 virtual-interface:
140 type: VIRTIO
141 internal-connection-point-ref: dataVM-internal
142 internal-connection-point:
143 - id: dataVM-internal
144 name: dataVM-internal
145 short-name: dataVM-internal
146 type: VPORT
147 cloud-init-file: cloud-config.txt
148 vdu-configuration:
149 juju:
150 charm: proxy-ci
151 proxy: true
152 initial-config-primitive:
153 - seq: '1'
154 name: test
155
156 """
157
158 # @pytest.mark.serial
159 @pytest.mark.asyncio
160 async def test_multivdu_relate(self, event_loop):
161 """Deploy and execute the initial-config-primitive of a VNF."""
162
163 if self.nsd and self.vnfd:
164 vnf_index = 0
165
166 for config in self.get_config():
167 juju = config['juju']
168 charm = juju['charm']
169
170 await self.deploy(
171 vnf_index,
172 charm,
173 config,
174 event_loop,
175 )
176 vnf_index += 1
177
178 while await self.running():
179 logging.debug("Waiting for test to finish...")
180 await asyncio.sleep(15)
181
182 # assert False
183 logging.debug("test_multivdu_relate stopped")
184
185 return 'ok'