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