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