e7fa92095a8b28b058ddb9249aaf12a58ddc2429
[osm/N2VC.git] / test_metrics_proxy.py
1 """
2 Deploy a VNF w/proxy charm that collects metrics
3 """
4 import asyncio
5 import logging
6 import pytest
7 from .. import base
8
9
10 # @pytest.mark.serial
11 class TestCharm(base.TestN2VC):
12
13 NSD_YAML = """
14 nsd:nsd-catalog:
15 nsd:
16 - id: metricsproxy-ns
17 name: metricsproxy-ns
18 short-name: metricsproxy-ns
19 description: NS with 1 VNFs metricsproxy-vnf connected by datanet and mgmtnet VLs
20 version: '1.0'
21 logo: osm.png
22 constituent-vnfd:
23 - vnfd-id-ref: metricsproxy-vnf
24 member-vnf-index: '1'
25 vld:
26 - id: mgmtnet
27 name: mgmtnet
28 short-name: mgmtnet
29 type: ELAN
30 mgmt-network: 'true'
31 vim-network-name: mgmt
32 vnfd-connection-point-ref:
33 - vnfd-id-ref: metricsproxy-vnf
34 member-vnf-index-ref: '1'
35 vnfd-connection-point-ref: vnf-mgmt
36 - vnfd-id-ref: metricsproxy-vnf
37 member-vnf-index-ref: '2'
38 vnfd-connection-point-ref: vnf-mgmt
39 - id: datanet
40 name: datanet
41 short-name: datanet
42 type: ELAN
43 vnfd-connection-point-ref:
44 - vnfd-id-ref: metricsproxy-vnf
45 member-vnf-index-ref: '1'
46 vnfd-connection-point-ref: vnf-data
47 - vnfd-id-ref: metricsproxy-vnf
48 member-vnf-index-ref: '2'
49 vnfd-connection-point-ref: vnf-data
50 """
51
52 VNFD_YAML = """
53 vnfd:vnfd-catalog:
54 vnfd:
55 - id: metricsproxy-vnf
56 name: metricsproxy-vnf
57 short-name: metricsproxy-vnf
58 version: '1.0'
59 description: A VNF consisting of 2 VDUs w/charms connected to an internal VL, and one VDU with cloud-init
60 logo: osm.png
61 connection-point:
62 - id: vnf-mgmt
63 name: vnf-mgmt
64 short-name: vnf-mgmt
65 type: VPORT
66 - id: vnf-data
67 name: vnf-data
68 short-name: vnf-data
69 type: VPORT
70 mgmt-interface:
71 cp: vnf-mgmt
72 internal-vld:
73 - id: internal
74 name: internal
75 short-name: internal
76 type: ELAN
77 internal-connection-point:
78 - id-ref: mgmtVM-internal
79 - id-ref: dataVM-internal
80 vdu:
81 - id: mgmtVM
82 name: mgmtVM
83 image: xenial
84 count: '1'
85 vm-flavor:
86 vcpu-count: '1'
87 memory-mb: '1024'
88 storage-gb: '10'
89 interface:
90 - name: mgmtVM-eth0
91 position: '1'
92 type: EXTERNAL
93 virtual-interface:
94 type: VIRTIO
95 external-connection-point-ref: vnf-mgmt
96 - name: mgmtVM-eth1
97 position: '2'
98 type: INTERNAL
99 virtual-interface:
100 type: VIRTIO
101 internal-connection-point-ref: mgmtVM-internal
102 internal-connection-point:
103 - id: mgmtVM-internal
104 name: mgmtVM-internal
105 short-name: mgmtVM-internal
106 type: VPORT
107 cloud-init-file: cloud-config.txt
108 vnf-configuration:
109 juju:
110 charm: metrics-proxy-ci
111 proxy: true
112 """
113
114 # @pytest.mark.serial
115 @pytest.mark.asyncio
116 async def test_metrics_proxy(self, event_loop):
117 """Deploy and execute the initial-config-primitive of a VNF."""
118
119 if self.nsd and self.vnfd:
120 vnf_index = 0
121
122 for config in self.get_config():
123 juju = config['juju']
124 charm = juju['charm']
125
126 await self.deploy(
127 vnf_index,
128 charm,
129 config,
130 event_loop,
131 )
132
133 while await self.running():
134 print("Waiting for test to finish...")
135 await asyncio.sleep(15)
136
137 logging.debug("test_metrics_proxy stopped")
138
139 return 'ok'