Feature 'ns primitive'
[osm/N2VC.git] / tests / integration / test_charm_proxy.py
1 """
2 Deploy a VNF with a proxy charm, executing an initial-config-primitive
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: charmproxy-ns
18 name: charmproxy-ns
19 short-name: charmproxy-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: charmproxy-vnf
57 name: charmproxy-vnf
58 short-name: charmproxy-vnf
59 version: '1.0'
60 description: A VNF consisting of 1 VDUs w/proxy charm
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: xenial
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: VIRTIO
96 external-connection-point-ref: vnf-mgmt
97 - name: mgmtVM-eth1
98 position: '2'
99 type: INTERNAL
100 virtual-interface:
101 type: VIRTIO
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 vdu-configuration:
110 juju:
111 charm: proxy-ci
112 proxy: true
113 initial-config-primitive:
114 - seq: '1'
115 name: test
116 """
117
118 # @pytest.mark.serial
119 @pytest.mark.asyncio
120 async def test_charm_proxy(self, event_loop):
121 """Deploy and execute the initial-config-primitive of a VNF."""
122
123 if self.nsd and self.vnfd:
124 vnf_index = 0
125
126 for config in self.get_config():
127 juju = config['juju']
128 charm = juju['charm']
129
130 await self.deploy(
131 vnf_index,
132 charm,
133 config,
134 event_loop,
135 )
136
137 while await self.running():
138 print("Waiting for test to finish...")
139 await asyncio.sleep(15)
140 logging.debug("test_charm_proxy stopped")
141
142 return 'ok'