This is an automated email from the ASF dual-hosted git repository.
gmurthy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/main by this push:
new 90f177f DISPATCH-1930: Make sure log file is created before searching
the log file. This closes #1212
90f177f is described below
commit 90f177f43d99c30d1af4b3165262a105157a9a5f
Author: Ganesh Murthy <[email protected]>
AuthorDate: Tue May 11 16:20:26 2021 -0400
DISPATCH-1930: Make sure log file is created before searching the log file.
This closes #1212
---
tests/system_tests_bad_configuration.py | 31 ++++++++++++++++++++-----------
tests/system_tests_policy.py | 7 +++++--
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/tests/system_tests_bad_configuration.py
b/tests/system_tests_bad_configuration.py
index ba06922..c407210 100644
--- a/tests/system_tests_bad_configuration.py
+++ b/tests/system_tests_bad_configuration.py
@@ -70,8 +70,8 @@ class RouterTestBadConfiguration(TestCase):
def __init__(self, test_method):
TestCase.__init__(self, test_method)
self.error_caught = False
- self.timer_delay = 1
- self.max_attempts = 20
+ self.timer_delay = 0.2
+ self.max_attempts = 100
self.attempts_made = 0
self.schedule_timer()
@@ -109,15 +109,24 @@ class RouterTestBadConfiguration(TestCase):
then it stops scheduling new attempts.
:return:
"""
- with open(self.router.logfile_path, 'r') as router_log:
- log_lines = router_log.read().split("\n")
- expected_log_snip = "Connection to %s" %
self.unresolvable_host_name
- errors_caught = [line for line in log_lines if expected_log_snip
in line and "failed" in line]
-
- self.error_caught = any(errors_caught)
-
- # If condition not yet satisfied and not exhausted max attempts,
- # re-schedule the verification.
+ try:
+ # mode 'r' and 't' are defaults
+ with open(self.router.logfile_path) as router_log:
+ log_lines = router_log.read().split("\n")
+ expected_log_snip = "Connection to %s" %
self.unresolvable_host_name
+ errors_caught = [line for line in log_lines if
expected_log_snip in line and "failed" in line]
+
+ self.error_caught = any(errors_caught)
+
+ # If condition not yet satisfied and not exhausted max
attempts,
+ # re-schedule the verification.
+ if self.waiting_for_error():
+ self.attempts_made += 1
+ self.schedule_timer()
+ except IOError:
+ # DISPATCH-1930: The log file might not have been created yet.
+ # When we try to open a non-existent log file, we run into an
exception.
+ # We will keep trying until the log file is in place.
if self.waiting_for_error():
self.attempts_made += 1
self.schedule_timer()
diff --git a/tests/system_tests_policy.py b/tests/system_tests_policy.py
index 0db1ba5..27a4105 100644
--- a/tests/system_tests_policy.py
+++ b/tests/system_tests_policy.py
@@ -340,7 +340,9 @@ class SenderReceiverLimits(TestCase):
# In some emulated environments the router log file writes may lag
test execution.
# To accomodate the file lag this test may retry reading the log file.
verified = False
- for tries in range(5):
+
+ # We will wait a total of 5 seconds for the log files to appear.
+ for tries in range(25):
with open(self.router.logfile_path, 'r') as router_log:
log_lines = router_log.read().split("\n")
close_lines = [s for s in log_lines if "senders_denied=1,
receivers_denied=1" in s]
@@ -349,7 +351,8 @@ class SenderReceiverLimits(TestCase):
break
print("system_tests_policy, SenderReceiverLimits,
test_verify_z_connection_stats: delay to wait for log to be written")
sys.stdout.flush()
- time.sleep(1)
+ # Sleep for 0.2 seconds before trying again.
+ time.sleep(0.2)
if not verified:
deny_lines = [s for s in log_lines if "DENY" in s]
resources_lines = [s for s in log_lines if "closed with resources"
in s]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]