Merge "Bug 1000: Fix authentication when deleting service"
[osm/N2VC.git] / tests / integration / test_metrics_native.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/native 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: metricsnative-ns
31 name: metricsnative-ns
32 short-name: metricsnative-ns
33 description: NS with 1 VNFs metricsnative-vnf connected by datanet and mgmtnet VLs
34 version: '1.0'
35 logo: osm.png
36 constituent-vnfd:
37 - vnfd-id-ref: metricsnative-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: metricsnative-vnf
48 member-vnf-index-ref: '1'
49 vnfd-connection-point-ref: vnf-mgmt
50 - vnfd-id-ref: metricsnative-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: metricsnative-vnf
59 member-vnf-index-ref: '1'
60 vnfd-connection-point-ref: vnf-data
61 - vnfd-id-ref: metricsnative-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: metricsnative-vnf
70 name: metricsnative-vnf
71 short-name: metricsnative-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-ci
125 proxy: false
126 config-primitive:
127 - name: touch
128 parameter:
129 - name: filename
130 data-type: STRING
131 default-value: '/home/ubuntu/touched'
132 """
133
134 # @pytest.mark.serial
135 @pytest.mark.asyncio
136 async def test_metrics_native(self, event_loop):
137 """Deploy and execute the initial-config-primitive of a VNF."""
138
139 if self.nsd and self.vnfd:
140 vnf_index = 0
141
142 for config in self.get_config():
143 juju = config['juju']
144 charm = juju['charm']
145
146 await self.deploy(
147 vnf_index,
148 charm,
149 config,
150 event_loop,
151 )
152
153 while await self.running():
154 print("Waiting for test to finish...")
155 await asyncio.sleep(15)
156
157 logging.debug("test_metrics_native stopped")
158
159 return 'ok'