[telepathy-mission-control/master] Add a regression test for clients vanishing

Simon McVittie simon.mcvittie at collabora.co.uk
Tue May 12 11:05:54 PDT 2009


---
 test/twisted/Makefile.am                    |    1 +
 test/twisted/constants.py                   |    2 +
 test/twisted/dispatcher/vanishing-client.py |   92 +++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 test/twisted/dispatcher/vanishing-client.py

diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index 3e983a6..7f74d21 100644
--- a/test/twisted/Makefile.am
+++ b/test/twisted/Makefile.am
@@ -19,6 +19,7 @@ TWISTED_BASIC_TESTS = \
 	dispatcher/exploding-bundles.py \
 	dispatcher/fdo-21034.py \
 	dispatcher/lose-text.py \
+	dispatcher/vanishing-client.py \
 	do-nothing.py \
 	test-account.py \
 	test-connect.py
diff --git a/test/twisted/constants.py b/test/twisted/constants.py
index 5794f0a..d379a25 100644
--- a/test/twisted/constants.py
+++ b/test/twisted/constants.py
@@ -5,6 +5,8 @@ Some handy constants for other tests to share and enjoy.
 from dbus import PROPERTIES_IFACE, INTROSPECTABLE_IFACE
 from servicetest import tp_name_prefix, tp_path_prefix
 
+DBUS_ERROR_NO_REPLY = 'org.freedesktop.DBus.Error.NoReply'
+
 HT_CONTACT = 1
 HT_ROOM = 2
 
diff --git a/test/twisted/dispatcher/vanishing-client.py b/test/twisted/dispatcher/vanishing-client.py
new file mode 100644
index 0000000..e261759
--- /dev/null
+++ b/test/twisted/dispatcher/vanishing-client.py
@@ -0,0 +1,92 @@
+"""Regression test for a client crashing when Get is called.
+"""
+
+import dbus
+import dbus.service
+
+from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
+        call_async, sync_dbus
+from mctest import exec_test, SimulatedConnection, SimulatedClient, \
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
+import constants as cs
+
+def test(q, bus, mc):
+    params = dbus.Dictionary({"account": "someguy at example.com",
+        "password": "secrecy"}, signature='sv')
+    cm_name_ref, account = create_fakecm_account(q, bus, mc, params)
+    conn = enable_fakecm_account(q, bus, mc, account, params)
+
+    bus_name = '.'.join([tp_name_prefix, 'Client.CrashMe'])
+    bus_name_ref = dbus.service.BusName(bus_name, bus)
+    object_path = '/' + bus_name.replace('.', '/')
+
+    # MC inspects it
+    e = q.expect('dbus-method-call',
+            interface=cs.PROPERTIES_IFACE, method='Get',
+            path=object_path,
+            args=[cs.CLIENT, 'Interfaces'],
+            handled=False)
+    # Simulate a crash
+    del bus_name_ref
+    sync_dbus(bus, q, account)
+    # This might crash MC in sympathy
+    q.dbus_raise(e.message, cs.DBUS_ERROR_NO_REPLY, 'I crashed')
+
+    sync_dbus(bus, q, account)
+
+    # Try again
+    bus_name = '.'.join([tp_name_prefix, 'Client.CrashMeAgain'])
+    bus_name_ref = dbus.service.BusName(bus_name, bus)
+    object_path = '/' + bus_name.replace('.', '/')
+
+    # MC inspects it
+    e = q.expect('dbus-method-call',
+            interface=cs.PROPERTIES_IFACE, method='Get',
+            path=object_path,
+            args=[cs.CLIENT, 'Interfaces'],
+            handled=False)
+    # Don't crash just yet
+    q.dbus_return(e.message, dbus.Array([cs.OBSERVER], signature='s'),
+            signature='v')
+    # MC investigates further
+    e = q.expect('dbus-method-call',
+            interface=cs.PROPERTIES_IFACE, method='Get',
+            path=object_path,
+            args=[cs.OBSERVER, 'ObserverChannelFilter'],
+            handled=False)
+    # Simulate another crash
+    del bus_name_ref
+    sync_dbus(bus, q, account)
+    q.dbus_raise(e.message, cs.DBUS_ERROR_NO_REPLY, 'I crashed')
+
+    # Try again
+    bus_name = '.'.join([tp_name_prefix, 'Client.CrashMeHarder'])
+    bus_name_ref = dbus.service.BusName(bus_name, bus)
+    object_path = '/' + bus_name.replace('.', '/')
+
+    # MC inspects it
+    e = q.expect('dbus-method-call',
+            interface=cs.PROPERTIES_IFACE, method='Get',
+            path=object_path,
+            args=[cs.CLIENT, 'Interfaces'],
+            handled=False)
+    # Don't crash just yet
+    q.dbus_return(e.message, dbus.Array([cs.OBSERVER], signature='s'),
+            signature='v')
+    # MC investigates further
+    e = q.expect('dbus-method-call',
+            interface=cs.PROPERTIES_IFACE, method='Get',
+            path=object_path,
+            args=[cs.OBSERVER, 'ObserverChannelFilter'],
+            handled=False)
+    # Simulate a crash with highly unfortunate timing
+    del bus_name_ref
+    sync_dbus(bus, q, account)
+    q.dbus_return(e.message, dbus.Array([dbus.Dictionary({
+        'x': 'y',
+        }, signature='sv')], signature='a{sv}'), signature='v')
+    sync_dbus(bus, q, account)
+
+if __name__ == '__main__':
+    exec_test(test, {})
-- 
1.5.6.5




More information about the telepathy-commits mailing list