Use NS uuid when creating a juju k8s model
[osm/N2VC.git] / tests / integration / test_charm_relate.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: multivdurelate-ns
32 name: multivdurelate-ns
33 short-name: multivdurelate-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: multivdurelate-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: multivdurelate-vnf
49 member-vnf-index-ref: '1'
50 vnfd-connection-point-ref: vnf-mgmt
51 - vnfd-id-ref: multivdurelate-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: multivdurelate-vnf
60 member-vnf-index-ref: '1'
61 vnfd-connection-point-ref: vnf-data
62 - vnfd-id-ref: multivdurelate-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: multivdurelate-vnf
71 name: multivdurelate-vnf
72 short-name: multivdurelate-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 vca-relationships:
128 # Relation needs to map to the vdu providing or
129 # requiring, so that we can map to the deployed app.
130 relation:
131 - provides: dataVM:db
132 requires: mgmtVM:app
133 initial-config-primitive:
134 - seq: '1'
135 name: test
136 - id: dataVM
137 name: dataVM
138 image: xenial
139 count: '1'
140 vm-flavor:
141 vcpu-count: '1'
142 memory-mb: '1024'
143 storage-gb: '10'
144 interface:
145 - name: dataVM-eth0
146 position: '1'
147 type: EXTERNAL
148 virtual-interface:
149 type: VIRTIO
150 external-connection-point-ref: vnf-mgmt
151 - name: dataVM-eth1
152 position: '2'
153 type: INTERNAL
154 virtual-interface:
155 type: VIRTIO
156 internal-connection-point-ref: dataVM-internal
157 internal-connection-point:
158 - id: dataVM-internal
159 name: dataVM-internal
160 short-name: dataVM-internal
161 type: VPORT
162 cloud-init-file: cloud-config.txt
163 vdu-configuration:
164 juju:
165 charm: proxy-ci
166 proxy: true
167 initial-config-primitive:
168 - seq: '1'
169 name: test
170
171 """
172
173 # @pytest.mark.serial
174 @pytest.mark.asyncio
175 async def test_multivdu_relate(self, event_loop):
176 """Deploy and execute the initial-config-primitive of a VNF."""
177
178 if self.nsd and self.vnfd:
179 vnf_index = 0
180
181 for config in self.get_config():
182 juju = config['juju']
183 charm = juju['charm']
184
185 await self.deploy(
186 vnf_index,
187 charm,
188 config,
189 event_loop,
190 )
191 vnf_index += 1
192
193 while await self.running():
194 logging.debug("Waiting for test to finish...")
195 await asyncio.sleep(15)
196
197 # assert False
198 logging.debug("test_multivdu_relate stopped")
199
200 return 'ok'