[SCM] Samba Shared Repository - branch master updated

Noel Power npower at samba.org
Tue Mar 5 13:11:01 UTC 2019


The branch, master has been updated
       via  6a7dd7ab510 tests: Reduce likelihood of auth_log test locking up during CI
      from  f0ecfd384c2 pidl/Python: initialise a datablob

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6a7dd7ab510a85d4c5f6d7e740b6bbd58b714085
Author: Aaron Haslett <aaronhaslett at catalyst.net.nz>
Date:   Thu Feb 28 16:55:31 2019 +1300

    tests: Reduce likelihood of auth_log test locking up during CI
    
    We would sometimes see the auth_log test hang during a CI run. The CI
    job would eventually fail after consuming a costly 10 hours of CI
    runtime.
    
    We believe the problem is around the test creating multiple instances of
    the Messaging() context. This is a similar race condition to what was
    seen in 19f34b2161dee26.
    
    Currently a new Messaging() context is created for every test case. By
    using classmethods instead, the Messaging context is only created once
    per python test file execution (i.e. creation of the python class,
    rather than initialization of the python object, which happens for every
    test-case).
    
    This means the test will only create one Messaging() context, which
    should avoid any race conditions.
    
    Changes:
    + removed msg_ctxs - this wasn't actually used for anything.
    + use classmethods to setup and tear-down the Messaging() context (and
    tweak lp initialization accordingly).
    + fix discardMessages() - the loop wasn't actually discarding any
    messages previously (this may also have been the cause of the test
    hanging).
    
    Signed-off-by: Aaron Haslett <aaronhaslett at catalyst.net.nz>
    Signed-off-by: Tim Beale <timbeale at catalyst.net.nz>
    Reviewed-by: Noel Power <npower at samba.org>
    
    Autobuild-User(master): Noel Power <npower at samba.org>
    Autobuild-Date(master): Tue Mar  5 13:10:43 UTC 2019 on sn-devel-144

-----------------------------------------------------------------------

Summary of changes:
 python/samba/tests/auth_log_base.py | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/tests/auth_log_base.py b/python/samba/tests/auth_log_base.py
index d6a3976f456..09a8df0a4dc 100644
--- a/python/samba/tests/auth_log_base.py
+++ b/python/samba/tests/auth_log_base.py
@@ -27,14 +27,13 @@ import time
 import json
 import os
 import re
-
-msg_ctxs = []
+from samba import param
 
 
 class AuthLogTestBase(samba.tests.TestCase):
 
-    def setUp(self):
-        super(AuthLogTestBase, self).setUp()
+    @classmethod
+    def setUpClass(self):
         # connect to the server's messaging bus (we need to explicitly load a
         # different smb.conf here, because in all other respects this test
         # wants to act as a separate remote client)
@@ -42,16 +41,14 @@ class AuthLogTestBase(samba.tests.TestCase):
         if server_conf:
             lp_ctx = LoadParm(filename_for_non_global_lp=server_conf)
         else:
-            lp_ctx = self.get_loadparm()
+            samba.tests.env_loadparm()
         self.msg_ctx = Messaging((1,), lp_ctx=lp_ctx)
-        global msg_ctxs
-        msg_ctxs.append(self.msg_ctx)
         self.msg_ctx.irpc_add_name(AUTH_EVENT_NAME)
 
         # Now switch back to using the client-side smb.conf. The tests will
         # use the first interface in the client.conf (we need to strip off
         # the subnet mask portion)
-        lp_ctx = self.get_loadparm()
+        lp_ctx = samba.tests.env_loadparm()
         client_ip_and_mask = lp_ctx.get('interfaces')[0]
         client_ip = client_ip_and_mask.split('/')[0]
 
@@ -71,18 +68,21 @@ class AuthLogTestBase(samba.tests.TestCase):
         self.msg_ctx.register(self.msg_handler_and_context,
                               msg_type=MSG_AUTH_LOG)
 
-        self.discardMessages()
-
         self.remoteAddress = None
         self.server = os.environ["SERVER"]
         self.connection = None
 
-    def tearDown(self):
+    @classmethod
+    def tearDownClass(self):
         if self.msg_handler_and_context:
             self.msg_ctx.deregister(self.msg_handler_and_context,
                                     msg_type=MSG_AUTH_LOG)
             self.msg_ctx.irpc_remove_name(AUTH_EVENT_NAME)
 
+    def setUp(self):
+        super(AuthLogTestBase, self).setUp()
+        self.discardMessages()
+
     def waitForMessages(self, isLastExpectedMessage, connection=None):
         """Wait for all the expected messages to arrive
         The connection is passed through to keep the connection alive
@@ -126,11 +126,12 @@ class AuthLogTestBase(samba.tests.TestCase):
         return list(filter(isRemote, self.context["messages"]))
 
     # Discard any previously queued messages.
+    @classmethod
     def discardMessages(self):
         self.msg_ctx.loop_once(0.001)
         while len(self.context["messages"]):
+            self.context["messages"] = []
             self.msg_ctx.loop_once(0.001)
-        self.context["messages"] = []
 
     # Remove any NETLOGON authentication messages
     # NETLOGON is only performed once per session, so to avoid ordering


-- 
Samba Shared Repository



More information about the samba-cvs mailing list