aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/instantiate/vnf_ala_carte.py
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2021-03-19 15:01:26 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2021-03-19 15:46:43 +0000
commit11eaf0bf2df74664ab9812d817e1d34e89112c0b (patch)
treea8b7854c5332ec4fe1e65cd469881feba814919f /src/onaptests/steps/instantiate/vnf_ala_carte.py
parentfb89da9e663ae759fc245b9273e55d06bc57f6a8 (diff)
Timeout on orchestration requests
Use wait_for_finish method to raise an exception if orchestration requests took more than 10 minutes Issue-ID: TEST-316 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: I0d82d91b0f7104caf32e5905d5950047d7551a7b
Diffstat (limited to 'src/onaptests/steps/instantiate/vnf_ala_carte.py')
-rw-r--r--src/onaptests/steps/instantiate/vnf_ala_carte.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/onaptests/steps/instantiate/vnf_ala_carte.py b/src/onaptests/steps/instantiate/vnf_ala_carte.py
index 64ea090..9dc062a 100644
--- a/src/onaptests/steps/instantiate/vnf_ala_carte.py
+++ b/src/onaptests/steps/instantiate/vnf_ala_carte.py
@@ -1,4 +1,3 @@
-import time
from uuid import uuid4
from yaml import load
@@ -118,9 +117,13 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep):
cloud_region,
tenant,
f"{self.service_instance_name}_vnf_{idx}")
- while not vnf_instantiation.finished:
- time.sleep(10)
- if vnf_instantiation.failed:
+ try:
+ vnf_instantiation.wait_for_finish(settings.ORCHESTRATION_REQUEST_TIMEOUT)
+ if vnf_instantiation.failed:
+ self._logger.error("VNF instantiation %s failed", vnf.name)
+ raise onap_test_exceptions.VnfInstantiateException
+ except TimeoutError:
+ self._logger.error("VNF instantiation %s timed out", vnf.name)
raise onap_test_exceptions.VnfInstantiateException
@YamlTemplateBaseStep.store_state(cleanup=True)
@@ -133,16 +136,13 @@ class YamlTemplateVnfAlaCarteInstantiateStep(YamlTemplateBaseStep):
"""
for vnf_instance in self._service_instance.vnf_instances:
vnf_deletion = vnf_instance.delete()
- nb_try = 0
- nb_try_max = 30
-
- while not vnf_deletion.finished and nb_try < nb_try_max:
- self._logger.info("Wait for vnf deletion")
- nb_try += 1
- time.sleep(15)
- if vnf_deletion.finished:
- self._logger.info("VNF %s deleted", vnf_instance.name)
- else:
- self._logger.error("VNF deletion %s failed", vnf_instance.name)
+
+ try:
+ vnf_deletion.wait_for_finish(settings.ORCHESTRATION_REQUEST_TIMEOUT)
+ if vnf_deletion.failed:
+ self._logger.error("VNF deletion %s failed", vnf_instance.name)
+ raise onap_test_exceptions.VnfCleanupException
+ except TimeoutError:
+ self._logger.error("VNF deletion %s timed out", vnf_instance.name)
raise onap_test_exceptions.VnfCleanupException
super().cleanup()