Merge "Revert "Revert "Remove vendored libjuju"" Major code clean-up, approved by...
[osm/N2VC.git] / tests / integration / test_broken_charm.py
1 """
2 Test a charm that breaks post-deployment
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: brokencharm-ns
18 name: brokencharm-ns
19 short-name: brokencharm-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: charmproxy-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: charmproxy-vnf
35 member-vnf-index-ref: '1'
36 vnfd-connection-point-ref: vnf-mgmt
37 - vnfd-id-ref: charmproxy-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: charmproxy-vnf
46 member-vnf-index-ref: '1'
47 vnfd-connection-point-ref: vnf-data
48 - vnfd-id-ref: charmproxy-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: hackfest-simplecharm-vnf
57 name: hackfest-simplecharm-vnf
58 short-name: hackfest-simplecharm-vnf
59 version: '1.0'
60 description: A VNF consisting of 2 VDUs connected to an internal VL, and one VDU with cloud-init
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: hackfest3-mgmt
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: PARAVIRT
96 external-connection-point-ref: vnf-mgmt
97 - name: mgmtVM-eth1
98 position: '2'
99 type: INTERNAL
100 virtual-interface:
101 type: PARAVIRT
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 - id: dataVM
110 name: dataVM
111 image: hackfest3-mgmt
112 count: '1'
113 vm-flavor:
114 vcpu-count: '1'
115 memory-mb: '1024'
116 storage-gb: '10'
117 interface:
118 - name: dataVM-eth0
119 position: '1'
120 type: INTERNAL
121 virtual-interface:
122 type: PARAVIRT
123 internal-connection-point-ref: dataVM-internal
124 - name: dataVM-xe0
125 position: '2'
126 type: EXTERNAL
127 virtual-interface:
128 type: PARAVIRT
129 external-connection-point-ref: vnf-data
130 internal-connection-point:
131 - id: dataVM-internal
132 name: dataVM-internal
133 short-name: dataVM-internal
134 type: VPORT
135 vnf-configuration:
136 juju:
137 charm: broken
138 proxy: true
139 initial-config-primitive:
140 - seq: '1'
141 name: touch
142 parameter:
143 - name: filename
144 value: '/home/ubuntu/first-touch'
145 config-primitive:
146 - name: touch
147 parameter:
148 - name: filename
149 data-type: STRING
150 default-value: '/home/ubuntu/touched'
151 """
152
153 # @pytest.mark.serial
154 @pytest.mark.asyncio
155 async def test_charm_proxy(self, event_loop):
156 """Deploy and execute the initial-config-primitive of a VNF."""
157
158 if self.nsd and self.vnfd:
159 vnf_index = 0
160
161 for config in self.get_config():
162 juju = config['juju']
163 charm = juju['charm']
164
165 await self.deploy(
166 vnf_index,
167 charm,
168 config,
169 event_loop,
170 )
171
172 while await self.running():
173 print("Waiting for test to finish...")
174 await asyncio.sleep(15)
175 logging.debug("test_charm_proxy stopped")
176
177 return 'ok'