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