Fix logging in Juju K8s code
[osm/N2VC.git] / tests / integration / test_no_parameter.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 Describe what this test is meant to do.
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: noparam-ns
31 name: noparam-ns
32 short-name: noparam-ns
33 description: NS with 1 VNFs noparam-vnf connected by datanet and mgmtnet VLs
34 version: '1.0'
35 logo: osm.png
36 constituent-vnfd:
37 - vnfd-id-ref: noparam-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: noparam-vnf
48 member-vnf-index-ref: '1'
49 vnfd-connection-point-ref: vnf-mgmt
50 - vnfd-id-ref: noparam-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: noparam-vnf
59 member-vnf-index-ref: '1'
60 vnfd-connection-point-ref: vnf-data
61 - vnfd-id-ref: noparam-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: noparam-vnf
70 name: noparam-vnf
71 short-name: noparam-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 vdu-configuration:
123 juju:
124 charm: native-ci
125 proxy: false
126 initial-config-primitive:
127 - seq: '1'
128 name: test
129 """
130
131 # @pytest.mark.serial
132 @pytest.mark.asyncio
133 async def test_charm_no_parameter(self, event_loop):
134 """Deploy and execute the initial-config-primitive of a VNF."""
135 logging.warning("event_loop: {}".format(event_loop))
136 if self.nsd and self.vnfd:
137 vnf_index = 0
138
139 for config in self.get_config():
140 juju = config['juju']
141 charm = juju['charm']
142
143 await self.deploy(
144 vnf_index,
145 charm,
146 config,
147 event_loop,
148 )
149
150 while await self.running():
151 print("Waiting for test to finish...")
152 await asyncio.sleep(15)
153
154 return 'ok'