From da8a43e59d2fe0f3be33e97678fc92c650f8360d Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Tue, 26 Oct 2021 17:35:11 -0700 Subject: [PATCH] [pytest]: Check if appl DB exists before deleting (#1983) *Add a new helper method for deleting appl DBs, and use it anytime appl DB needs to be deleted Signed-off-by: Lawrence Lee --- tests/conftest.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index d0ad19743c44..b4633c1aa8f0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -410,10 +410,15 @@ def reset_dbs(self): self.flex_db = None self.state_db = None - def destroy(self) -> None: + def del_appl_db(self): + # APPL DB may not always exist, so use this helper method to check before deleting if getattr(self, 'appldb', False): del self.appldb + + def destroy(self) -> None: + self.del_appl_db() + # In case persistent dvs was used removed all the extra server link # that were created if self.persistent: @@ -583,8 +588,7 @@ def ctn_restart(self) -> None: self.ctn.restart() def restart(self) -> None: - if self.appldb: - del self.appldb + self.del_appl_db() self.ctn_restart() self.check_ready_status_and_init_db()