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