implements blueprint: #vnf-scaling Change-Id: I29269369faf57766ac51c2d12e10fecc1331e474changes/73/363573/15
parent
cf7f677fc7
commit
f291eda290
@ -0,0 +1,50 @@
|
||||
|
||||
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
|
||||
|
||||
description: sample-tosca-vnfd-scaling
|
||||
|
||||
metadata:
|
||||
template_name: sample-tosca-vnfd-scaling
|
||||
|
||||
topology_template:
|
||||
node_templates:
|
||||
VDU1:
|
||||
type: tosca.nodes.nfv.VDU.Tacker
|
||||
capabilities:
|
||||
nfv_compute:
|
||||
properties:
|
||||
num_cpus: 1
|
||||
mem_size: 512 MB
|
||||
disk_size: 1 GB
|
||||
properties:
|
||||
image: cirros-0.3.4-x86_64-uec
|
||||
mgmt_driver: noop
|
||||
availability_zone: nova
|
||||
|
||||
CP1:
|
||||
type: tosca.nodes.nfv.CP.Tacker
|
||||
properties:
|
||||
management: true
|
||||
anti_spoofing_protection: false
|
||||
requirements:
|
||||
- virtualLink:
|
||||
node: VL1
|
||||
- virtualBinding:
|
||||
node: VDU1
|
||||
|
||||
VL1:
|
||||
type: tosca.nodes.nfv.VL
|
||||
properties:
|
||||
network_name: net_mgmt
|
||||
vendor: Tacker
|
||||
|
||||
policies:
|
||||
- SP1:
|
||||
type: tosca.policy.tacker.Scaling
|
||||
properties:
|
||||
increment: 1
|
||||
cooldown: 60
|
||||
min_instances: 1
|
||||
max_instances: 3
|
||||
default_instances: 2
|
||||
targets: [VDU1]
|
@ -0,0 +1,86 @@
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import time
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from tacker.tests import constants
|
||||
from tacker.tests.functional import base
|
||||
from tacker.tests.utils import read_file
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class VnfTestToscaScale(base.BaseTackerTest):
|
||||
def test_vnf_tosca_scale(self):
|
||||
data = dict()
|
||||
data['tosca'] = read_file('sample-tosca-scale-all.yaml')
|
||||
vnfd_name = 'test_tosca_vnf_scale_all'
|
||||
toscal = data['tosca']
|
||||
tosca_arg = {'vnfd': {'name': vnfd_name,
|
||||
'attributes': {'vnfd': toscal}}}
|
||||
|
||||
# Create vnfd with tosca template
|
||||
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
|
||||
self.assertIsNotNone(vnfd_instance)
|
||||
|
||||
# Create vnf with vnfd_id
|
||||
vnfd_id = vnfd_instance['vnfd']['id']
|
||||
vnf_name = 'test_tosca_vnf_scale_all'
|
||||
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
|
||||
vnf_instance = self.client.create_vnf(body=vnf_arg)
|
||||
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
|
||||
# TODO(kanagaraj-manickam) once load-balancer support is enabled,
|
||||
# update this logic to validate the scaling
|
||||
def _wait(count):
|
||||
self.wait_until_vnf_active(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
vnf = self.client.show_vnf(vnf_id)['vnf']
|
||||
|
||||
# {"VDU1": ["10.0.0.14", "10.0.0.5"]}
|
||||
self.assertEqual(count, len(json.loads(vnf['mgmt_url'])['VDU1']))
|
||||
|
||||
_wait(2)
|
||||
|
||||
def _scale(type, count):
|
||||
body = {"scale": {'type': type, 'policy': 'SP1'}}
|
||||
self.client.scale_vnf(vnf_id, body)
|
||||
_wait(count)
|
||||
|
||||
# scale out
|
||||
time.sleep(constants.SCALE_WINDOW_SLEEP_TIME)
|
||||
_scale('out', 3)
|
||||
|
||||
# scale in
|
||||
time.sleep(constants.SCALE_WINDOW_SLEEP_TIME)
|
||||
_scale('in', 2)
|
||||
|
||||
# Delete vnf_instance with vnf_id
|
||||
try:
|
||||
self.client.delete_vnf(vnf_id)
|
||||
except Exception:
|
||||
assert False, "vnf Delete failed"
|
||||
|
||||
# Delete vnfd_instance
|
||||
self.addCleanup(self.client.delete_vnfd, vnfd_id)
|
||||
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
|
||||
constants.VNF_CIRROS_DELETE_TIMEOUT)
|
Loading…
Reference in new issue