[PATCH] osmo-gsm-tester[master]: esme: Add cleanup function to avoid cascade failure of tests

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Aug 10 09:04:46 UTC 2017


Review at  https://gerrit.osmocom.org/3463

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(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/63/3463/1

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: newchange
Gerrit-Change-Id: Ia3a23bb8bbccfe7ac5c544521b5566164609f0a5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list