Cleanup bgpvpn envtries at the end of test
At the moment bgpvpns are removed when all tests finished in class
resource_cleanup. The patch adds addCleanup() at the places
where bgpvpn entries are created to let them cleanned after single
test finished.
Also add cleanup for some API tests that were completely missing.
Related-Prod: PRODX-12050
Change-Id: I94229f2d6cc3331a61a57e5d03231fa8640857b6
(cherry picked from commit de5a63800ff3486be77f4399660d13668c0efccc)
(cherry picked from commit 63807a43771fe3a8f19089037a663ce6f852c43b)
diff --git a/neutron_tempest_plugin/bgpvpn/base.py b/neutron_tempest_plugin/bgpvpn/base.py
index b436a5d..46c2c78 100644
--- a/neutron_tempest_plugin/bgpvpn/base.py
+++ b/neutron_tempest_plugin/bgpvpn/base.py
@@ -17,6 +17,7 @@
from tempest.common import utils
from tempest import config
from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
from neutron_tempest_plugin.bgpvpn.services import bgpvpn_client
@@ -34,12 +35,6 @@
bgpvpn_alt_client = None
@classmethod
- def resource_cleanup(cls):
- for bgpvpn in cls.bgpvpns:
- cls.bgpvpn_admin_client.delete_bgpvpn(bgpvpn['id'])
- super(BaseBgpvpnTest, cls).resource_cleanup()
-
- @classmethod
def resource_setup(cls):
cls.route_distinguishers = []
cls.bgpvpns = []
@@ -87,9 +82,9 @@
body = client.create_bgpvpn(**kwargs)
bgpvpn = body['bgpvpn']
- self.bgpvpns.append(bgpvpn)
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.bgpvpn_admin_client.delete_bgpvpn, bgpvpn['id'])
return bgpvpn
def delete_bgpvpn(self, client, bgpvpn):
client.delete_bgpvpn(bgpvpn['id'])
- self.bgpvpns.remove(bgpvpn)