Pau Espin Pedrol has submitted this change and it was merged.

Change subject: esme: Add cleanup function to avoid cascade failure of tests
......................................................................


esme: Add cleanup function to avoid cascade failure of tests

In commit 6100b629e55ed4aa319f46ad797741131b9da8e7 I assumed esme
already had a cleanup function, which doesn't seem to be the case. This
means if a test calls esme.connect() and fails afterwards without
calling esme.disconnect(), the connection will be kept but as the test
will finish and the NITB is closed, then the connection will be kept
forever in an erroneous state. With the cleanup function we ensure we
will close the connection after the test.

Change-Id: Ia3a23bb8bbccfe7ac5c544521b5566164609f0a5
---
M src/osmo_gsm_tester/esme.py
M src/osmo_gsm_tester/suite.py
2 files changed, 4 insertions(+), 0 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo_gsm_tester/esme.py b/src/osmo_gsm_tester/esme.py
index 7063c33..376152a 100644
--- a/src/osmo_gsm_tester/esme.py
+++ b/src/osmo_gsm_tester/esme.py
@@ -52,6 +52,9 @@
         self.next_user_message_reference = 1
 
     def __del__(self):
+        self.cleanup()
+
+    def cleanup(self):
         try:
             self.disconnect()
         except smpplib.exceptions.ConnectionError:
diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py
index d510b93..2ac2062 100644
--- a/src/osmo_gsm_tester/suite.py
+++ b/src/osmo_gsm_tester/suite.py
@@ -368,6 +368,7 @@
 
     def esme(self):
         esme_obj = esme.Esme(self.msisdn())
+        self.register_for_cleanup(esme_obj)
         return esme_obj
 
     def msisdn(self):

-- 
To view, visit https://gerrit.osmocom.org/3463
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia3a23bb8bbccfe7ac5c544521b5566164609f0a5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to