Merge "Bug 1000: Fix authentication when deleting service"
[osm/N2VC.git] / tests / integration / test_broken_charm.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 Test a charm that breaks post-deployment
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: brokencharm-ns
32 name: brokencharm-ns
33 short-name: brokencharm-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: charmproxy-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: charmproxy-vnf
49 member-vnf-index-ref: '1'
50 vnfd-connection-point-ref: vnf-mgmt
51 - vnfd-id-ref: charmproxy-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: charmproxy-vnf
60 member-vnf-index-ref: '1'
61 vnfd-connection-point-ref: vnf-data
62 - vnfd-id-ref: charmproxy-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: hackfest-simplecharm-vnf
71 name: hackfest-simplecharm-vnf
72 short-name: hackfest-simplecharm-vnf
73 version: '1.0'
74 description: A VNF consisting of 2 VDUs connected to an internal VL, and one VDU with cloud-init
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: hackfest3-mgmt
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: PARAVIRT
110 external-connection-point-ref: vnf-mgmt
111 - name: mgmtVM-eth1
112 position: '2'
113 type: INTERNAL
114 virtual-interface:
115 type: PARAVIRT
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 - id: dataVM
124 name: dataVM
125 image: hackfest3-mgmt
126 count: '1'
127 vm-flavor:
128 vcpu-count: '1'
129 memory-mb: '1024'
130 storage-gb: '10'
131 interface:
132 - name: dataVM-eth0
133 position: '1'
134 type: INTERNAL
135 virtual-interface:
136 type: PARAVIRT
137 internal-connection-point-ref: dataVM-internal
138 - name: dataVM-xe0
139 position: '2'
140 type: EXTERNAL
141 virtual-interface:
142 type: PARAVIRT
143 external-connection-point-ref: vnf-data
144 internal-connection-point:
145 - id: dataVM-internal
146 name: dataVM-internal
147 short-name: dataVM-internal
148 type: VPORT
149 vnf-configuration:
150 juju:
151 charm: broken
152 proxy: true
153 initial-config-primitive:
154 - seq: '1'
155 name: touch
156 parameter:
157 - name: filename
158 value: '/home/ubuntu/first-touch'
159 config-primitive:
160 - name: touch
161 parameter:
162 - name: filename
163 data-type: STRING
164 default-value: '/home/ubuntu/touched'
165 """
166
167 # @pytest.mark.serial
168 @pytest.mark.asyncio
169 async def test_charm_proxy(self, event_loop):
170 """Deploy and execute the initial-config-primitive of a VNF."""
171
172 if self.nsd and self.vnfd:
173 vnf_index = 0
174
175 for config in self.get_config():
176 juju = config['juju']
177 charm = juju['charm']
178
179 await self.deploy(
180 vnf_index,
181 charm,
182 config,
183 event_loop,
184 )
185
186 while await self.running():
187 print("Waiting for test to finish...")
188 await asyncio.sleep(15)
189 logging.debug("test_charm_proxy stopped")
190
191 return 'ok'