Summary: | should run regression tests against a mock Avahi by default | ||
---|---|---|---|
Product: | Telepathy | Reporter: | Simon McVittie <smcv> |
Component: | salut | Assignee: | Jonny Lamb <jonny.lamb> |
Status: | RESOLVED FIXED | QA Contact: | Telepathy bugs list <telepathy-bugs> |
Severity: | normal | ||
Priority: | medium | CC: | tomeu |
Version: | git master | Keywords: | patch |
Hardware: | Other | ||
OS: | All | ||
URL: | http://cgit.freedesktop.org/~jonny/telepathy-salut/log?h=mock-avahi | ||
Whiteboard: | review+ | ||
i915 platform: | i915 features: |
Description
Simon McVittie
2010-12-03 02:49:22 UTC
In general this looks good. Some very brief notes for my own reference: --- a/tests/twisted/avahi/file-transfer/test-receive-file-ipv6.py +++ b/tests/twisted/avahi/file-transfer/test-receive-file-ipv6.py @@ -36,7 +36,8 @@ class TestReceiveFileIPv6(ReceiveFileTest): service = e.service service.resolve() - e = self.q.expect('service-resolved', service = service) + e = self.q.expect('service-resolved', service = service, + protocol = avahi.PROTO_INET6) Check that this works for the real network diff --git a/tests/twisted/avahi/file-transfer/test-send-file-to-unknown-contact.py b/tests/twisted/avahi/file-transfer/test-send-file-to-unknown-contact.py index cab907c..83ec8a1 100644 --- a/tests/twisted/avahi/file-transfer/test-send-file-to-unknown-contact.py +++ b/tests/twisted/avahi/file-transfer/test-send-file-to-unknown-contact.py @@ -19,7 +19,8 @@ class SendFileTransferToUnknownContactTest(SendFileTest): try: self.request_ft_channel() except dbus.DBusException, e: - assert e.get_dbus_name() == cs.NOT_AVAILABLE + if e.get_dbus_name() != cs.NOT_AVAILABLE: + raise Good independently, but call_async + expect would be even better +def get_domain(): + full_domain = socket.getfqdn() + if '.' in full_domain: + return full_domain.split('.', 1)[1] + else: + return '' Shouldn't use this, laptops' FQDNs are meaningless. All we need is Avahi's idea of the hostname (which we control anyway, so set it to mockavahi) and Avahi's advertising domain (.local). + emit_signal(service_resolver.object_path, + AVAHI_IFACE_SERVICE_RESOLVER, 'Failure', + service_resolver.client, 's', + 'fill with a proper error string') Indeed. + def _resolve_hostname(self, protocol, hostname): I'm dubious about needing this. Surely we ought to advertise everything we need on mDNS? + @dbus.service.method(dbus_interface=AVAHI_IFACE_SERVER, + in_signature='', out_signature='s') + def GetHostName(self): + return socket.gethostname() Hard-code this? + @dbus.service.method(dbus_interface=AVAHI_IFACE_SERVER, + in_signature='', out_signature='s') + def GetHostNameFqdn(self): + return socket.getfqdn() Hard-code this? + + @dbus.service.method(dbus_interface=AVAHI_IFACE_SERVER, + in_signature='', out_signature='s') + def GetDomainName(self): + return get_domain() And this? + @dbus.service.method(dbus_interface=AVAHI_IFACE_SERVER, + in_signature='', out_signature='i') + def GetState(self): + return 2 Magic number + @dbus.service.method(dbus_interface=AVAHI_IFACE_ENTRY_GROUP, + in_signature='', out_signature='') + def Commit(self): + self._set_state(1) + glib.idle_add(lambda: self._set_state(2)) Magic numbers + tests_dir = os.path.dirname(__file__) + avahimock_path = os.path.join(tests_dir, 'avahimock.py') + Popen([avahimock_path]) Isn't there a better fork/exec we could use? We could even use service activation, if we make the mock Avahi use the starter bus. diff --git a/tests/twisted/tools/org.freedesktop.Avahi.service b/tests/twisted/tools/org.freedesktop.Avahi.service new file mode 100644 index 0000000..c5c500c --- /dev/null +++ b/tests/twisted/tools/org.freedesktop.Avahi.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.Avahi +Exec=dumb Should use the fake-launch helper from MC, or not be activatable at all diff --git a/tests/twisted/tools/with-session-bus.sh b/tests/twisted/tools/with-session-bus.sh Copy to telepathy-glib I've taken this branch over. (In reply to comment #1) > - e = self.q.expect('service-resolved', service = service) > + e = self.q.expect('service-resolved', service = service, > + protocol = avahi.PROTO_INET6) > > Check that this works for the real network Done. > try: > self.request_ft_channel() > except dbus.DBusException, e: > - assert e.get_dbus_name() == cs.NOT_AVAILABLE > + if e.get_dbus_name() != cs.NOT_AVAILABLE: > + raise > > Good independently, but call_async + expect would be even better This is actually a bit of a pain because request_ft_channel does more than just call CreateChannel synchronously. I'm going to leave this for now. > +def get_domain(): > + full_domain = socket.getfqdn() > + if '.' in full_domain: > + return full_domain.split('.', 1)[1] > + else: > + return '' > > Shouldn't use this, laptops' FQDNs are meaningless. All we need is > Avahi's idea of the hostname (which we control anyway, so set it to > mockavahi) and Avahi's advertising domain (.local). Done. > + emit_signal(service_resolver.object_path, > + AVAHI_IFACE_SERVICE_RESOLVER, 'Failure', > + service_resolver.client, 's', > + 'fill with a proper error string') > > Indeed. Done. > + @dbus.service.method(dbus_interface=AVAHI_IFACE_SERVER, > + in_signature='', out_signature='s') > + def GetHostName(self): > + return socket.gethostname() > > Hard-code this? Done. > + @dbus.service.method(dbus_interface=AVAHI_IFACE_SERVER, > + in_signature='', out_signature='s') > + def GetHostNameFqdn(self): > + return socket.getfqdn() > > Hard-code this? Done. > + @dbus.service.method(dbus_interface=AVAHI_IFACE_SERVER, > + in_signature='', out_signature='s') > + def GetDomainName(self): > + return get_domain() > > And this? Done. > + @dbus.service.method(dbus_interface=AVAHI_IFACE_SERVER, > + in_signature='', out_signature='i') > + def GetState(self): > + return 2 > > Magic number Fixed. > + @dbus.service.method(dbus_interface=AVAHI_IFACE_ENTRY_GROUP, > + in_signature='', out_signature='') > + def Commit(self): > + self._set_state(1) > + glib.idle_add(lambda: self._set_state(2)) > > Magic numbers Fixed. > +[D-BUS Service] > +Name=org.freedesktop.Avahi > +Exec=dumb > > Should use the fake-launch helper from MC, or not be activatable at all Deleted service file. We're not testing service activation here. With real system avahi: 2:22.70 With mock avahi: 1:01.24 Not a bad speed increase. Okay, cool, I get consistent passing of tests now, and I added support for switching the mock avahi off at runtime. Reviewers should review from when I started working on the branch which starts at commit: "Merge remote branch 'smcv/mock-avahi'". Cooooooooooool. looks fine! awesome lol |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.