Merge "Fix the monitor bug"
This commit is contained in:
@@ -27,6 +27,7 @@ topology_template:
|
||||
timeout: 10
|
||||
retry: 5
|
||||
port: 8000
|
||||
config_drive: true
|
||||
user_data_format: RAW
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
|
||||
@@ -16,7 +16,6 @@ topology_template:
|
||||
config: |
|
||||
param0: key1
|
||||
param1: key2
|
||||
mgmt_driver: openwrt
|
||||
monitoring_policy:
|
||||
name: ping
|
||||
actions:
|
||||
@@ -26,11 +25,12 @@ topology_template:
|
||||
interval: 10
|
||||
monitoring_delay: 45
|
||||
timeout: 2
|
||||
config_drive: true
|
||||
user_data_format: RAW
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
echo "my hostname is `hostname`" > /tmp/hostname
|
||||
df -h > /home/openwrt/diskinfo
|
||||
df -h > /tmp/test.txt
|
||||
sleep 90
|
||||
sudo ifdown eth0
|
||||
|
||||
@@ -45,40 +45,8 @@ topology_template:
|
||||
- virtualBinding:
|
||||
node: VDU1
|
||||
|
||||
CP2:
|
||||
type: tosca.nodes.nfv.CP.Tacker
|
||||
properties:
|
||||
anti_spoofing_protection: false
|
||||
requirements:
|
||||
- virtualLink:
|
||||
node: VL2
|
||||
- virtualBinding:
|
||||
node: VDU1
|
||||
|
||||
CP3:
|
||||
type: tosca.nodes.nfv.CP.Tacker
|
||||
properties:
|
||||
anti_spoofing_protection: false
|
||||
requirements:
|
||||
- virtualLink:
|
||||
node: VL3
|
||||
- virtualBinding:
|
||||
node: VDU1
|
||||
|
||||
VL1:
|
||||
type: tosca.nodes.nfv.VL
|
||||
properties:
|
||||
network_name: net_mgmt
|
||||
vendor: ACME
|
||||
|
||||
VL2:
|
||||
type: tosca.nodes.nfv.VL
|
||||
properties:
|
||||
network_name: net0
|
||||
vendor: Tacker
|
||||
|
||||
VL3:
|
||||
type: tosca.nodes.nfv.VL
|
||||
properties:
|
||||
network_name: net1
|
||||
vendor: Tacker
|
||||
|
||||
@@ -103,11 +103,12 @@ topology_template:
|
||||
interval: 10
|
||||
monitoring_delay: 45
|
||||
timeout: 2
|
||||
config_drive: true
|
||||
user_data_format: RAW
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
echo "my hostname is `hostname`" > /tmp/hostname
|
||||
df -h > /home/openwrt/diskinfo
|
||||
df -h > /home/cirros/diskinfo
|
||||
sleep 90
|
||||
sudo ifdown eth0
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ vdus:
|
||||
id: vdu3
|
||||
vm_image: cirros-0.3.4-x86_64-uec
|
||||
instance_type: m1.tiny
|
||||
config_drive: true
|
||||
user_data_format: RAW
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
|
||||
@@ -11,6 +11,7 @@ vdus:
|
||||
id: vdu1
|
||||
vm_image: cirros-0.3.4-x86_64-uec
|
||||
instance_type: m1.tiny
|
||||
config_drive: true
|
||||
user_data_format: RAW
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
|
||||
@@ -11,6 +11,7 @@ vdus:
|
||||
id: vdu1
|
||||
vm_image: cirros-0.3.4-x86_64-uec
|
||||
instance_type: m1.tiny
|
||||
config_drive: true
|
||||
user_data_format: RAW
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
|
||||
@@ -12,6 +12,7 @@ vdus:
|
||||
vm_image: cirros-0.3.4-x86_64-uec
|
||||
instance_type: m1.tiny
|
||||
user_data_format: RAW
|
||||
config_drive: true
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
cd /tmp
|
||||
|
||||
@@ -19,7 +19,6 @@ from oslo_config import cfg
|
||||
from tempest.lib import base
|
||||
import yaml
|
||||
|
||||
from tacker.common import exceptions
|
||||
from tacker.tests import constants
|
||||
from tacker.tests.utils import read_file
|
||||
from tacker import version
|
||||
@@ -66,45 +65,43 @@ class BaseTackerTest(base.BaseTestCase):
|
||||
vim_params['project_name'],
|
||||
vim_params['auth_url'])
|
||||
|
||||
@classmethod
|
||||
def wait_until_vnf_status(cls, vnf_id, target_status, timeout,
|
||||
def wait_until_vnf_status(self, vnf_id, target_status, timeout,
|
||||
sleep_interval):
|
||||
start_time = int(time.time())
|
||||
while True:
|
||||
vnf_result = cls.client.show_vnf(vnf_id)
|
||||
vnf_result = self.client.show_vnf(vnf_id)
|
||||
status = vnf_result['vnf']['status']
|
||||
if (status == target_status) or (
|
||||
(int(time.time()) - start_time) > timeout):
|
||||
break
|
||||
time.sleep(sleep_interval)
|
||||
|
||||
if (status == target_status):
|
||||
return target_status
|
||||
self.assertEqual(status, target_status,
|
||||
"vnf %(vnf_id)s with status %(status)s is"
|
||||
" expected to be %(target)s" %
|
||||
{"vnf_id": vnf_id, "status": status,
|
||||
"target": target_status})
|
||||
|
||||
@classmethod
|
||||
def wait_until_vnf_active(cls, vnf_id, timeout, sleep_interval):
|
||||
return cls.wait_until_vnf_status(vnf_id, 'ACTIVE', timeout,
|
||||
sleep_interval)
|
||||
def wait_until_vnf_active(self, vnf_id, timeout, sleep_interval):
|
||||
self.wait_until_vnf_status(vnf_id, 'ACTIVE', timeout,
|
||||
sleep_interval)
|
||||
|
||||
@classmethod
|
||||
def wait_until_vnf_delete(cls, vnf_id, timeout):
|
||||
def wait_until_vnf_delete(self, vnf_id, timeout):
|
||||
start_time = int(time.time())
|
||||
while True:
|
||||
try:
|
||||
vnf_result = cls.client.show_vnf(vnf_id)
|
||||
vnf_result = self.client.show_vnf(vnf_id)
|
||||
time.sleep(1)
|
||||
except Exception:
|
||||
return
|
||||
status = vnf_result['vnf']['status']
|
||||
if (status != 'PENDING_DELETE') or ((
|
||||
int(time.time()) - start_time) > timeout):
|
||||
raise exceptions.TackerException(_("Failed with status: %s"),
|
||||
status)
|
||||
raise Exception("Failed with status: %s" % status)
|
||||
|
||||
@classmethod
|
||||
def wait_until_vnf_dead(cls, vnf_id, timeout, sleep_interval):
|
||||
return cls.wait_until_vnf_status(vnf_id, 'DEAD', timeout,
|
||||
sleep_interval)
|
||||
def wait_until_vnf_dead(self, vnf_id, timeout, sleep_interval):
|
||||
self.wait_until_vnf_status(vnf_id, 'DEAD', timeout,
|
||||
sleep_interval)
|
||||
|
||||
def validate_vnf_instance(self, vnfd_instance, vnf_instance):
|
||||
self.assertIsNotNone(vnf_instance)
|
||||
@@ -115,24 +112,21 @@ class BaseTackerTest(base.BaseTestCase):
|
||||
|
||||
def verify_vnf_restart(self, vnfd_instance, vnf_instance):
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
vnf_current_status = self.wait_until_vnf_active(
|
||||
self.wait_until_vnf_active(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual('ACTIVE', vnf_current_status)
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||
|
||||
vnf_current_status = self.wait_until_vnf_dead(
|
||||
self.wait_until_vnf_dead(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_DEAD_TIMEOUT,
|
||||
constants.DEAD_SLEEP_TIME)
|
||||
self.assertEqual('DEAD', vnf_current_status)
|
||||
vnf_current_status = self.wait_until_vnf_active(
|
||||
self.wait_until_vnf_active(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual('ACTIVE', vnf_current_status)
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
|
||||
def get_vim(self, vim_list, vim_name):
|
||||
|
||||
@@ -46,11 +46,10 @@ class VnfTestEvent(base.BaseTackerTest):
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
vnf_current_status = self.wait_until_vnf_active(
|
||||
self.wait_until_vnf_active(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual('ACTIVE', vnf_current_status)
|
||||
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||
if vim_id:
|
||||
self.assertEqual(vim_id, vnf_instance['vnf']['vim_id'])
|
||||
|
||||
@@ -46,11 +46,10 @@ class VnfTestToscaCreate(base.BaseTackerTest):
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
vnf_current_status = self.wait_until_vnf_active(
|
||||
self.wait_until_vnf_active(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual('ACTIVE', vnf_current_status)
|
||||
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||
|
||||
# Delete vnf_instance with vnf_id
|
||||
@@ -86,11 +85,10 @@ class VnfTestToscaCreateFlavorCreation(base.BaseTackerTest):
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
vnf_current_status = self.wait_until_vnf_active(
|
||||
self.wait_until_vnf_active(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual('ACTIVE', vnf_current_status)
|
||||
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||
|
||||
servers = self.novaclient().servers.list()
|
||||
@@ -140,11 +138,10 @@ class VnfTestToscaCreateImageCreation(base.BaseTackerTest):
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
vnf_current_status = self.wait_until_vnf_active(
|
||||
self.wait_until_vnf_active(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual('ACTIVE', vnf_current_status)
|
||||
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||
|
||||
servers = self.novaclient().servers.list()
|
||||
|
||||
@@ -44,11 +44,10 @@ class VnfTestCreate(base.BaseTackerTest):
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
vnf_current_status = self.wait_until_vnf_active(
|
||||
self.wait_until_vnf_active(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual('ACTIVE', vnf_current_status)
|
||||
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||
if vim_id:
|
||||
self.assertEqual(vim_id, vnf_instance['vnf']['vim_id'])
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib import decorators
|
||||
|
||||
from tacker.tests import constants
|
||||
from tacker.tests.functional import base
|
||||
from tacker.tests.utils import read_file
|
||||
@@ -73,9 +70,6 @@ class VnfTestPingMonitor(base.BaseTackerTest):
|
||||
'sample-vnfd-single-vdu-monitoring-new-template.yaml',
|
||||
'ping monitor vnf new template')
|
||||
|
||||
# TODO(sridhar_ram): Temporarily disable ping monitor test using tosca
|
||||
# to avoid unwanted rechecks. Reenable after this test is fixed.
|
||||
@decorators.skip_because(bug="1617923")
|
||||
def test_create_delete_vnf_monitoring_tosca_template(self):
|
||||
self._test_vnf_with_monitoring(
|
||||
'sample-tosca-vnfd-monitor.yaml',
|
||||
|
||||
@@ -61,11 +61,10 @@ class VnfmTestParam(base.BaseTackerTest):
|
||||
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
vnf_current_status = self.wait_until_vnf_active(
|
||||
self.wait_until_vnf_active(
|
||||
vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual('ACTIVE', vnf_current_status)
|
||||
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||
vnf_instance = self.client.show_vnf(vnf_id)
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ class VNFMonitor(object):
|
||||
with self._lock:
|
||||
for hosting_vnf in self._hosting_vnfs.values():
|
||||
if hosting_vnf.get('dead', False):
|
||||
LOG.debug('monitor skips dead vnf %s', hosting_vnf)
|
||||
continue
|
||||
|
||||
self.run_monitor(hosting_vnf)
|
||||
@@ -266,7 +267,7 @@ class ActionRespawnHeat(ActionPolicy):
|
||||
@classmethod
|
||||
def execute_action(cls, plugin, vnf_dict, auth_attr):
|
||||
vnf_id = vnf_dict['id']
|
||||
LOG.error(_('vnf %s dead'), vnf_id)
|
||||
LOG.info(_('vnf %s dead and to be respawned'), vnf_id)
|
||||
if plugin._mark_vnf_dead(vnf_dict['id']):
|
||||
plugin._vnf_monitor.mark_dead(vnf_dict['id'])
|
||||
attributes = vnf_dict['attributes']
|
||||
@@ -288,6 +289,7 @@ class ActionRespawnHeat(ActionPolicy):
|
||||
"ActionRespawnHeat invoked")
|
||||
update_vnf_dict = plugin.create_vnf_sync(context,
|
||||
vnf_dict)
|
||||
LOG.info(_('respawned new vnf %s'), update_vnf_dict['id'])
|
||||
plugin.config_vnf(context, update_vnf_dict)
|
||||
plugin.add_vnf_to_monitor(update_vnf_dict, auth_attr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user