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
This commit is contained in:
parent
3d40c322b5
commit
dbbf891fd2
|
@ -1,4 +1,5 @@
|
||||||
VNF_CIRROS_CREATE_TIMEOUT = 300
|
VNF_CIRROS_CREATE_TIMEOUT = 300
|
||||||
|
VNF_CIRROS_DELETE_TIMEOUT = 300
|
||||||
VNF_CIRROS_DEAD_TIMEOUT = 250
|
VNF_CIRROS_DEAD_TIMEOUT = 250
|
||||||
ACTIVE_SLEEP_TIME = 3
|
ACTIVE_SLEEP_TIME = 3
|
||||||
DEAD_SLEEP_TIME = 1
|
DEAD_SLEEP_TIME = 1
|
||||||
|
|
|
@ -17,6 +17,7 @@ import time
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from tempest_lib.tests import base
|
from tempest_lib.tests import base
|
||||||
|
|
||||||
|
from tacker.common.exceptions import TackerException
|
||||||
from tacker.tests import constants
|
from tacker.tests import constants
|
||||||
from tacker import version
|
from tacker import version
|
||||||
|
|
||||||
|
@ -85,6 +86,20 @@ class BaseTackerTest(base.TestCase):
|
||||||
return cls.wait_until_vnf_status(vnf_id, 'ACTIVE', timeout,
|
return cls.wait_until_vnf_status(vnf_id, 'ACTIVE', timeout,
|
||||||
sleep_interval)
|
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
|
@classmethod
|
||||||
def wait_until_vnf_dead(cls, vnf_id, timeout, sleep_interval):
|
def wait_until_vnf_dead(cls, vnf_id, timeout, sleep_interval):
|
||||||
return cls.wait_until_vnf_status(vnf_id, 'DEAD', timeout,
|
return cls.wait_until_vnf_status(vnf_id, 'DEAD', timeout,
|
||||||
|
|
|
@ -57,7 +57,6 @@ class VnfTestToscaCreate(base.BaseTackerTest):
|
||||||
assert False, "vnf Delete failed"
|
assert False, "vnf Delete failed"
|
||||||
|
|
||||||
# Delete vnfd_instance
|
# Delete vnfd_instance
|
||||||
try:
|
self.addCleanup(self.client.delete_vnfd, vnfd_id)
|
||||||
self.client.delete_vnfd(vnfd_id)
|
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
|
||||||
except Exception:
|
constants.VNF_CIRROS_DELETE_TIMEOUT)
|
||||||
assert False, "vnfd Delete failed"
|
|
||||||
|
|
|
@ -76,7 +76,6 @@ class VnfTestToscaMultipleVDU(base.BaseTackerTest):
|
||||||
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
|
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
|
||||||
|
|
||||||
# Delete vnfd_instance
|
# Delete vnfd_instance
|
||||||
try:
|
self.addCleanup(self.client.delete_vnfd, vnfd_id)
|
||||||
self.client.delete_vnfd(vnfd_id)
|
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
|
||||||
except Exception:
|
constants.VNF_CIRROS_DELETE_TIMEOUT)
|
||||||
assert False, "vnfd Delete of sample-vnfd-multiple-vdus failed"
|
|
||||||
|
|
|
@ -58,10 +58,9 @@ class VnfTestCreate(base.BaseTackerTest):
|
||||||
assert False, "vnf Delete failed"
|
assert False, "vnf Delete failed"
|
||||||
|
|
||||||
# Delete vnfd_instance
|
# Delete vnfd_instance
|
||||||
try:
|
self.addCleanup(self.client.delete_vnfd, vnfd_id)
|
||||||
self.client.delete_vnfd(vnfd_id)
|
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
|
||||||
except Exception:
|
constants.VNF_CIRROS_DELETE_TIMEOUT)
|
||||||
assert False, "vnfd Delete failed"
|
|
||||||
|
|
||||||
def test_create_delete_vnf_with_default_vim(self):
|
def test_create_delete_vnf_with_default_vim(self):
|
||||||
self._test_create_delete_vnf(
|
self._test_create_delete_vnf(
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from tacker.tests import constants
|
||||||
from tacker.tests.functional import base
|
from tacker.tests.functional import base
|
||||||
from tacker.tests.utils import read_file
|
from tacker.tests.utils import read_file
|
||||||
|
|
||||||
|
@ -45,11 +46,9 @@ class VnfTestPingMonitor(base.BaseTackerTest):
|
||||||
vnf_id)
|
vnf_id)
|
||||||
|
|
||||||
# Delete vnfd_instance
|
# Delete vnfd_instance
|
||||||
try:
|
self.addCleanup(self.client.delete_vnfd, vnfd_id)
|
||||||
self.client.delete_vnfd(vnfd_id)
|
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
|
||||||
except Exception:
|
constants.VNF_CIRROS_DELETE_TIMEOUT)
|
||||||
assert False, ("Failed to delete vnfd %s after the monitor test" %
|
|
||||||
vnfd_id)
|
|
||||||
|
|
||||||
def test_create_delete_vnf_monitoring(self):
|
def test_create_delete_vnf_monitoring(self):
|
||||||
self._test_vnf_with_monitoring(
|
self._test_vnf_with_monitoring(
|
||||||
|
|
|
@ -67,7 +67,6 @@ class VnfTestMultipleVDU(base.BaseTackerTest):
|
||||||
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
|
assert False, "vnf Delete of test_vnf_with_multiple_vdus failed"
|
||||||
|
|
||||||
# Delete vnfd_instance
|
# Delete vnfd_instance
|
||||||
try:
|
self.addCleanup(self.client.delete_vnfd, vnfd_id)
|
||||||
self.client.delete_vnfd(vnfd_id)
|
self.addCleanup(self.wait_until_vnf_delete, vnf_id,
|
||||||
except Exception:
|
constants.VNF_CIRROS_DELETE_TIMEOUT)
|
||||||
assert False, "vnfd Delete of sample-vnfd-multiple-vdus failed"
|
|
||||||
|
|
|
@ -97,4 +97,7 @@ class VnfmTestParam(base.BaseTackerTest):
|
||||||
'test_vnf_with_parameters',
|
'test_vnf_with_parameters',
|
||||||
'sample_cirros_vnf_values.yaml')
|
'sample_cirros_vnf_values.yaml')
|
||||||
self._test_vnf_delete(vnf_instance)
|
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.mgmt_delete_post(context, device_dict)
|
||||||
self._delete_device_post(context, device_id, e)
|
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)
|
self.spawn_n(self._delete_device_wait, context, device_dict, vim_auth)
|
||||||
|
|
||||||
def create_vnf(self, context, vnf):
|
def create_vnf(self, context, vnf):
|
||||||
|
|
Loading…
Reference in New Issue