Remove premature vnf delete from db

Hold the vnf in "PENDING_DELETE" state until underlying heat-stack
deletion is complete.
Closes-bug: #1554663

Change-Id: I5c52a9fc55950355f9122cc907f41cb8b9217a5c
changes/32/291032/7
dharmendra 7 years ago
parent 3d40c322b5
commit dbbf891fd2

@ -1,4 +1,5 @@
VNF_CIRROS_CREATE_TIMEOUT = 300
VNF_CIRROS_DELETE_TIMEOUT = 300
VNF_CIRROS_DEAD_TIMEOUT = 250
ACTIVE_SLEEP_TIME = 3
DEAD_SLEEP_TIME = 1

@ -17,6 +17,7 @@ import time
from oslo_config import cfg
from tempest_lib.tests import base
from tacker.common.exceptions import TackerException
from tacker.tests import constants
from tacker import version
@ -85,6 +86,20 @@ class BaseTackerTest(base.TestCase):
return cls.wait_until_vnf_status(vnf_id, 'ACTIVE', timeout,
sleep_interval)
@classmethod
def wait_until_vnf_delete(cls, vnf_id, timeout):
start_time = int(time.time())
while True:
try:
vnf_result = cls.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 TackerException(_("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,

@ -57,7 +57,6 @@ class VnfTestToscaCreate(base.BaseTackerTest):
assert False, "vnf Delete failed"
# Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed"
self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)

@ -76,7 +76,6 @@ class VnfTestToscaMultipleVDU(base.BaseTackerTest):
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
# Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete of sample-vnfd-multiple-vdus failed"
self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)

@ -58,10 +58,9 @@ class VnfTestCreate(base.BaseTackerTest):
assert False, "vnf Delete failed"
# Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed"
self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
def test_create_delete_vnf_with_default_vim(self):
self._test_create_delete_vnf(

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from tacker.tests import constants
from tacker.tests.functional import base
from tacker.tests.utils import read_file
@ -45,11 +46,9 @@ class VnfTestPingMonitor(base.BaseTackerTest):
vnf_id)
# Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, ("Failed to delete vnfd %s after the monitor test" %
vnfd_id)
self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)
def test_create_delete_vnf_monitoring(self):
self._test_vnf_with_monitoring(

@ -67,7 +67,6 @@ class VnfTestMultipleVDU(base.BaseTackerTest):
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
# Delete vnfd_instance
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete of sample-vnfd-multiple-vdus failed"
self.addCleanup(self.client.delete_vnfd, vnfd_id)
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)

@ -97,4 +97,7 @@ class VnfmTestParam(base.BaseTackerTest):
'test_vnf_with_parameters',
'sample_cirros_vnf_values.yaml')
self._test_vnf_delete(vnf_instance)
self._test_vnfd_delete(vnfd_instance)
vnf_id = vnf_instance['vnf']['id']
self.addCleanup(self.client.delete_vnfd, vnfd_instance['vnfd']['id'])
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
constants.VNF_CIRROS_DELETE_TIMEOUT)

@ -380,7 +380,6 @@ class VNFMPlugin(vm_db.VNFMPluginDb, VNFMMgmtMixin):
self.mgmt_delete_post(context, device_dict)
self._delete_device_post(context, device_id, e)
self._delete_device_post(context, device_id, None)
self.spawn_n(self._delete_device_wait, context, device_dict, vim_auth)
def create_vnf(self, context, vnf):

Loading…
Cancel
Save