telepathy-gabble: tests: don't block on Disconnect() without sending </ stream>

Will Thompson wjt at kemper.freedesktop.org
Tue Feb 12 02:24:06 PST 2013


Module: telepathy-gabble
Branch: master
Commit: 0bffd2d8302d81a804f5186f17445abae16b1d85
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=0bffd2d8302d81a804f5186f17445abae16b1d85

Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Tue Feb 12 10:21:54 2013 +0000

tests: don't block on Disconnect() without sending </stream>

These three tests were making blocking calls to Disconnect() rather than
using the disconnect_conn() helper. As a result, Gabble was waiting 5
seconds for the test server to send back </stream:stream> before timing
out. Using disconnect_conn(), which sends the stream close back
properly, shaves between 15 and 18 wasted seconds off the test suite.

---

 tests/twisted/jingle/call-muc-cancel.py   |    4 ++--
 tests/twisted/vcard/overlapping-sets.py   |    5 ++---
 tests/twisted/vcard/set-set-disconnect.py |    8 ++++----
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/tests/twisted/jingle/call-muc-cancel.py b/tests/twisted/jingle/call-muc-cancel.py
index 62fa006..36fb238 100644
--- a/tests/twisted/jingle/call-muc-cancel.py
+++ b/tests/twisted/jingle/call-muc-cancel.py
@@ -2,7 +2,7 @@
 Test closing the muc channel while a muji request is in flight
 """
 
-from gabbletest import exec_test
+from gabbletest import exec_test, disconnect_conn
 from servicetest import call_async
 
 import constants as cs
@@ -25,7 +25,7 @@ def run_cancel_test(q, bus, conn, stream):
 
     q.expect('stream-presence', to = muc + "/test")
 
-    conn.Disconnect()
+    disconnect_conn(q, conn, stream)
 
 if __name__ == '__main__':
     exec_test (run_cancel_test)
diff --git a/tests/twisted/vcard/overlapping-sets.py b/tests/twisted/vcard/overlapping-sets.py
index e9676de..a57ca9c 100644
--- a/tests/twisted/vcard/overlapping-sets.py
+++ b/tests/twisted/vcard/overlapping-sets.py
@@ -8,7 +8,7 @@ from servicetest import (EventPattern, call_async, sync_dbus, assertEquals,
         assertLength)
 from gabbletest import (
     acknowledge_iq, exec_test, expect_and_handle_get_vcard, make_result_iq,
-    sync_stream)
+    sync_stream, disconnect_conn)
 import ns
 
 def test(q, bus, conn, stream):
@@ -129,8 +129,7 @@ def test(q, bus, conn, stream):
 
     # Now Gabble gets disconnected.
     sync_stream(q, stream)
-    conn.Disconnect()
-    q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+    disconnect_conn(q, conn, stream)
 
 if __name__ == '__main__':
     exec_test(test)
diff --git a/tests/twisted/vcard/set-set-disconnect.py b/tests/twisted/vcard/set-set-disconnect.py
index b7b7315..e35ee97 100644
--- a/tests/twisted/vcard/set-set-disconnect.py
+++ b/tests/twisted/vcard/set-set-disconnect.py
@@ -4,7 +4,7 @@ Regression test for crash when disconnecting in the middle of a set.
 """
 
 from servicetest import EventPattern, call_async, sync_dbus
-from gabbletest import exec_test, acknowledge_iq, expect_and_handle_get_vcard, sync_stream
+from gabbletest import exec_test, acknowledge_iq, expect_and_handle_get_vcard, sync_stream, disconnect_conn
 import constants as cs
 
 def test(q, bus, conn, stream):
@@ -18,9 +18,9 @@ def test(q, bus, conn, stream):
         'stream-iq', iq_type='set', query_ns='vcard-temp', query_name='vCard')
     call_async(
         q, conn.Avatars, 'SetAvatar', 'LeChuck.brush', 'image/x-ghost-pirate')
-    conn.Disconnect()
-    q.expect('dbus-signal', signal='StatusChanged',
-        args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_REQUESTED]),
+
+    disconnect_conn(q, conn, stream)
+
     q.expect('dbus-error', method='SetAvatar', name=cs.NOT_AVAILABLE)
     q.expect('dbus-error', method='SetAvatar', name=cs.NOT_AVAILABLE)
     sync_dbus(bus, q, conn)



More information about the telepathy-commits mailing list