| Adam Israel | 5e08a0e | 2018-09-06 19:22:47 -0400 | [diff] [blame] | 1 | """ |
| 2 | Deploy a native charm (to LXD) and execute a primitive |
| 3 | """ |
| 4 | |
| 5 | import asyncio |
| Adam Israel | 5e08a0e | 2018-09-06 19:22:47 -0400 | [diff] [blame] | 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: charmnative-ns |
| 17 | name: charmnative-ns |
| 18 | short-name: charmnative-ns |
| 19 | description: NS with 1 VNFs charmnative-vnf connected by datanet and mgmtnet VLs |
| 20 | version: '1.0' |
| 21 | logo: osm.png |
| 22 | constituent-vnfd: |
| 23 | - vnfd-id-ref: charmnative-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: charmnative-vnf |
| 34 | member-vnf-index-ref: '1' |
| 35 | vnfd-connection-point-ref: vnf-mgmt |
| 36 | - vnfd-id-ref: charmnative-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: charmnative-vnf |
| 45 | member-vnf-index-ref: '1' |
| 46 | vnfd-connection-point-ref: vnf-data |
| 47 | - vnfd-id-ref: charmnative-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: charmnative-vnf |
| 56 | name: charmnative-vnf |
| 57 | short-name: charmnative-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 | vdu-configuration: |
| 109 | juju: |
| 110 | charm: native-ci |
| 111 | proxy: false |
| 112 | initial-config-primitive: |
| 113 | - seq: '1' |
| 114 | name: test |
| 115 | """ |
| 116 | |
| 117 | @pytest.mark.asyncio |
| 118 | async def test_charm_native(self, event_loop): |
| 119 | """Deploy and execute the initial-config-primitive of a VNF.""" |
| 120 | |
| 121 | if self.nsd and self.vnfd: |
| 122 | vnf_index = 0 |
| 123 | |
| 124 | for config in self.get_config(): |
| 125 | juju = config['juju'] |
| 126 | charm = juju['charm'] |
| 127 | |
| 128 | await self.deploy( |
| 129 | vnf_index, |
| 130 | charm, |
| 131 | config, |
| 132 | loop=event_loop, |
| 133 | ) |
| 134 | |
| Adam Israel | fc511ed | 2018-09-21 14:20:55 +0200 | [diff] [blame^] | 135 | while await self.running(): |
| 136 | print("Waiting for test to finish...") |
| Adam Israel | 5e08a0e | 2018-09-06 19:22:47 -0400 | [diff] [blame] | 137 | await asyncio.sleep(15) |
| Adam Israel | fc511ed | 2018-09-21 14:20:55 +0200 | [diff] [blame^] | 138 | |
| 139 | print("test_charm_native stopped") |
| Adam Israel | 5e08a0e | 2018-09-06 19:22:47 -0400 | [diff] [blame] | 140 | |
| 141 | return 'ok' |