[asterisk-commits] mmichelson: testsuite/asterisk/trunk r4672 - in /asterisk/trunk: lib/python/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 4 17:23:45 CST 2014


Author: mmichelson
Date: Tue Feb  4 17:23:40 2014
New Revision: 4672

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4672
Log:
Fix failing PJSUA plugin tests.

There was ambiguity because the pjsua test module had an identical name as the
pjsua module provided by PJPROJECT. I renamed our module to pjsua_mod.py to
resolve this.

When re-testing the modules that use this, I noticed that sometimes AMI actions
that I sent from PJSUA's thread did not reach Asterisk, thus causing tests to
fail. I have changed the tests to send the AMI actions from the reactor
thread. After this change, I have not experienced a test failure.


Added:
    asterisk/trunk/lib/python/asterisk/pjsua_mod.py
      - copied, changed from r4667, asterisk/trunk/lib/python/asterisk/pjsua.py
Removed:
    asterisk/trunk/lib/python/asterisk/pjsua.py
Modified:
    asterisk/trunk/tests/channels/pjsip/mwi/mwi_check.py
    asterisk/trunk/tests/channels/pjsip/mwi/test-config.yaml
    asterisk/trunk/tests/channels/pjsip/presence_pidf/state_check.py
    asterisk/trunk/tests/channels/pjsip/presence_pidf/test-config.yaml
    asterisk/trunk/tests/channels/pjsip/presence_xpidf/state_check.py
    asterisk/trunk/tests/channels/pjsip/presence_xpidf/test-config.yaml

Copied: asterisk/trunk/lib/python/asterisk/pjsua_mod.py (from r4667, asterisk/trunk/lib/python/asterisk/pjsua.py)
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/pjsua_mod.py?view=diff&rev=4672&p1=asterisk/trunk/lib/python/asterisk/pjsua.py&r1=4667&p2=asterisk/trunk/lib/python/asterisk/pjsua_mod.py&r2=4672
==============================================================================
--- asterisk/trunk/lib/python/asterisk/pjsua.py (original)
+++ asterisk/trunk/lib/python/asterisk/pjsua_mod.py Tue Feb  4 17:23:40 2014
@@ -111,9 +111,6 @@
     def __init__(self, instance_config, test_object):
         """Constructor for pluggable modules."""
         super(PJsua, self).__init__()
-
-        if not PJSUA_AVAILABLE:
-            raise ImportError
 
         self.test_object = test_object
         self.test_object.register_ami_observer(self.__ami_connect)

Modified: asterisk/trunk/tests/channels/pjsip/mwi/mwi_check.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/mwi/mwi_check.py?view=diff&rev=4672&r1=4671&r2=4672
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/mwi/mwi_check.py (original)
+++ asterisk/trunk/tests/channels/pjsip/mwi/mwi_check.py Tue Feb  4 17:23:40 2014
@@ -1,5 +1,12 @@
+#!/usr/bin/env python
+
+import sys
 import logging
 import pjsua as pj
+
+sys.path.append("lib/python")
+
+from twisted.internet import reactor
 
 LOGGER = logging.getLogger(__name__)
 
@@ -69,7 +76,7 @@
             'NewMessages': self.mwis[self.pos]['new'],
             'OldMessages': self.mwis[self.pos]['old']
         }
-        self.ami.sendMessage(message)
+        reactor.callFromThread(self.ami.sendMessage, message)
 
     def delete_mwi(self):
         LOGGER.info("Deleting Mailbox")
@@ -77,7 +84,7 @@
             'Action': 'MWIDelete',
             'Mailbox': 'alice',
         }
-        self.ami.sendMessage(message)
+        reactor.callFromThread(self.ami.sendMessage, message)
 
 
 def mwi_callback(test_object, accounts):

Modified: asterisk/trunk/tests/channels/pjsip/mwi/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/mwi/test-config.yaml?view=diff&rev=4672&r1=4671&r2=4672
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/mwi/test-config.yaml (original)
+++ asterisk/trunk/tests/channels/pjsip/mwi/test-config.yaml Tue Feb  4 17:23:40 2014
@@ -28,7 +28,7 @@
     modules:
         -
             config-section: 'pjsua-config'
-            typename: 'pjsua.PJsua'
+            typename: 'pjsua_mod.PJsua'
 
 test-case-config:
     connect-ami: 'True'

Modified: asterisk/trunk/tests/channels/pjsip/presence_pidf/state_check.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/presence_pidf/state_check.py?view=diff&rev=4672&r1=4671&r2=4672
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/presence_pidf/state_check.py (original)
+++ asterisk/trunk/tests/channels/pjsip/presence_pidf/state_check.py Tue Feb  4 17:23:40 2014
@@ -1,7 +1,12 @@
 #!/usr/bin/env python
 
+import sys
 import logging
 import pjsua as pj
+
+sys.path.append("lib/python")
+
+from twisted.internet import reactor
 
 LOGGER = logging.getLogger(__name__)
 
@@ -42,12 +47,12 @@
                 LOGGER.error("Unexpected state %d. Expected %d" %
                              (info.online_status,  states[self.pos][1]))
                 self.test_object.set_passed(False)
-                self.test_object.stop_reactor(False)
+                self.test_object.stop_reactor()
             if info.online_text != states[self.pos][2]:
                 LOGGER.error("Unexpected text %s. Expected %s" %
                              (info.online_text, states[self.pos][2]))
                 self.test_object.set_passed(False)
-                self.test_object.stop_reactor(False)
+                self.test_object.stop_reactor()
             self.pos += 1
             if (self.pos >= len(states)):
                 self.test_object.set_passed(True)
@@ -56,8 +61,9 @@
         if self.pos < len(states) and states[self.pos][0]:
             LOGGER.info("Setting device state to %s" % states[self.pos][0])
             self.check_status = True
-            self.ami.setVar(channel="", variable="DEVICE_STATE(Custom:bob)",
-                            value=states[self.pos][0])
+            reactor.callFromThread(self.ami.setVar, channel="",
+                                   variable="DEVICE_STATE(Custom:bob)",
+                                   value=states[self.pos][0])
         else:
             self.buddy.unsubscribe()
 

Modified: asterisk/trunk/tests/channels/pjsip/presence_pidf/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/presence_pidf/test-config.yaml?view=diff&rev=4672&r1=4671&r2=4672
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/presence_pidf/test-config.yaml (original)
+++ asterisk/trunk/tests/channels/pjsip/presence_pidf/test-config.yaml Tue Feb  4 17:23:40 2014
@@ -25,7 +25,7 @@
     modules:
         -
             config-section: 'pjsua-config'
-            typename: 'pjsua.PJsua'
+            typename: 'pjsua_mod.PJsua'
 
 test-case-config:
     connect-ami: 'True'

Modified: asterisk/trunk/tests/channels/pjsip/presence_xpidf/state_check.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/presence_xpidf/state_check.py?view=diff&rev=4672&r1=4671&r2=4672
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/presence_xpidf/state_check.py (original)
+++ asterisk/trunk/tests/channels/pjsip/presence_xpidf/state_check.py Tue Feb  4 17:23:40 2014
@@ -1,7 +1,12 @@
 #!/usr/bin/env python
 
+import sys
 import logging
 import pjsua as pj
+
+sys.path.append("lib/python")
+
+from twisted.internet import reactor
 
 LOGGER = logging.getLogger(__name__)
 
@@ -56,8 +61,9 @@
         if self.pos < len(states) and states[self.pos][0]:
             LOGGER.info("Setting device state to %s" % states[self.pos][0])
             self.check_status = True
-            self.ami.setVar(channel="", variable="DEVICE_STATE(Custom:bob)",
-                            value=states[self.pos][0])
+            reactor.callFromThread(self.ami.setVar, channel="",
+                                   variable="DEVICE_STATE(Custom:bob)",
+                                   value=states[self.pos][0])
         else:
             self.buddy.unsubscribe()
 

Modified: asterisk/trunk/tests/channels/pjsip/presence_xpidf/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/presence_xpidf/test-config.yaml?view=diff&rev=4672&r1=4671&r2=4672
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/presence_xpidf/test-config.yaml (original)
+++ asterisk/trunk/tests/channels/pjsip/presence_xpidf/test-config.yaml Tue Feb  4 17:23:40 2014
@@ -24,7 +24,7 @@
     modules:
         -
             config-section: 'pjsua-config'
-            typename: 'pjsua.PJsua'
+            typename: 'pjsua_mod.PJsua'
 
 test-case-config:
     connect-ami: 'True'




More information about the asterisk-commits mailing list