Fixes for scaling proxy and native charm
[osm/N2VC.git] / tests / integration / test_simplecharm.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 Exercise the simplecharm hackfest example:
17 https://osm-download.etsi.org/ftp/osm-4.0-four/4th-hackfest/packages/hackfest_simplecharm_vnf.tar.gz
18 """
19
20 import asyncio
21 import logging
22 import pytest
23 from .. import base
24
25
26 # @pytest.mark.serial
27 class TestCharm(base.TestN2VC):
28
29 NSD_YAML = """
30 nsd:nsd-catalog:
31 nsd:
32 - id: charmproxy-ns
33 name: charmproxy-ns
34 short-name: charmproxy-ns
35 description: NS with 1 VNF connected by datanet and mgmtnet VLs
36 version: '1.0'
37 logo: osm.png
38 constituent-vnfd:
39 - vnfd-id-ref: charmproxy-vnf
40 member-vnf-index: '1'
41 vld:
42 - id: mgmtnet
43 name: mgmtnet
44 short-name: mgmtnet
45 type: ELAN
46 mgmt-network: 'true'
47 vim-network-name: mgmt
48 vnfd-connection-point-ref:
49 - vnfd-id-ref: charmproxy-vnf
50 member-vnf-index-ref: '1'
51 vnfd-connection-point-ref: vnf-mgmt
52 - vnfd-id-ref: charmproxy-vnf
53 member-vnf-index-ref: '2'
54 vnfd-connection-point-ref: vnf-mgmt
55 - id: datanet
56 name: datanet
57 short-name: datanet
58 type: ELAN
59 vnfd-connection-point-ref:
60 - vnfd-id-ref: charmproxy-vnf
61 member-vnf-index-ref: '1'
62 vnfd-connection-point-ref: vnf-data
63 - vnfd-id-ref: charmproxy-vnf
64 member-vnf-index-ref: '2'
65 vnfd-connection-point-ref: vnf-data
66 """
67
68 VNFD_YAML = """
69 vnfd:vnfd-catalog:
70 vnfd:
71 - id: hackfest-simplecharm-vnf
72 name: hackfest-simplecharm-vnf
73 short-name: hackfest-simplecharm-vnf
74 version: '1.0'
75 description: A VNF consisting of 2 VDUs connected to an internal VL, and one VDU with cloud-init
76 logo: osm.png
77 connection-point:
78 - id: vnf-mgmt
79 name: vnf-mgmt
80 short-name: vnf-mgmt
81 type: VPORT
82 - id: vnf-data
83 name: vnf-data
84 short-name: vnf-data
85 type: VPORT
86 mgmt-interface:
87 cp: vnf-mgmt
88 internal-vld:
89 - id: internal
90 name: internal
91 short-name: internal
92 type: ELAN
93 internal-connection-point:
94 - id-ref: mgmtVM-internal
95 - id-ref: dataVM-internal
96 vdu:
97 - id: mgmtVM
98 name: mgmtVM
99 image: hackfest3-mgmt
100 count: '1'
101 vm-flavor:
102 vcpu-count: '1'
103 memory-mb: '1024'
104 storage-gb: '10'
105 interface:
106 - name: mgmtVM-eth0
107 position: '1'
108 type: EXTERNAL
109 virtual-interface:
110 type: PARAVIRT
111 external-connection-point-ref: vnf-mgmt
112 - name: mgmtVM-eth1
113 position: '2'
114 type: INTERNAL
115 virtual-interface:
116 type: PARAVIRT
117 internal-connection-point-ref: mgmtVM-internal
118 internal-connection-point:
119 - id: mgmtVM-internal
120 name: mgmtVM-internal
121 short-name: mgmtVM-internal
122 type: VPORT
123 cloud-init-file: cloud-config.txt
124 - id: dataVM
125 name: dataVM
126 image: hackfest3-mgmt
127 count: '1'
128 vm-flavor:
129 vcpu-count: '1'
130 memory-mb: '1024'
131 storage-gb: '10'
132 interface:
133 - name: dataVM-eth0
134 position: '1'
135 type: INTERNAL
136 virtual-interface:
137 type: PARAVIRT
138 internal-connection-point-ref: dataVM-internal
139 - name: dataVM-xe0
140 position: '2'
141 type: EXTERNAL
142 virtual-interface:
143 type: PARAVIRT
144 external-connection-point-ref: vnf-data
145 internal-connection-point:
146 - id: dataVM-internal
147 name: dataVM-internal
148 short-name: dataVM-internal
149 type: VPORT
150 vnf-configuration:
151 juju:
152 charm: simple
153 proxy: true
154 initial-config-primitive:
155 - seq: '1'
156 name: touch
157 parameter:
158 - name: filename
159 value: '/home/ubuntu/first-touch'
160 config-primitive:
161 - name: touch
162 parameter:
163 - name: filename
164 data-type: STRING
165 default-value: '/home/ubuntu/touched'
166 """
167
168 # @pytest.mark.serial
169 @pytest.mark.asyncio
170 async def test_charm_proxy(self, event_loop):
171 """Deploy and execute the initial-config-primitive of a VNF."""
172
173 if self.nsd and self.vnfd:
174 vnf_index = 0
175
176 for config in self.get_config():
177 juju = config['juju']
178 charm = juju['charm']
179
180 await self.deploy(
181 vnf_index,
182 charm,
183 config,
184 event_loop,
185 )
186
187 while await self.running():
188 print("Waiting for test to finish...")
189 await asyncio.sleep(15)
190 logging.debug("test_charm_proxy stopped")
191
192 return 'ok'