Merge lp://qastaging/~verterok/ubuntuone-client/no-more-timeouts-please into lp://qastaging/ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: dobey
Approved revision: 8
Merged at revision: not available
Proposed branch: lp://qastaging/~verterok/ubuntuone-client/no-more-timeouts-please
Merge into: lp://qastaging/ubuntuone-client
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~verterok/ubuntuone-client/no-more-timeouts-please
Reviewer Review Type Date Requested Status
dobey (community) Approve
Rick McBride (community) Approve
Tim Cole (community) Approve
Review via email: mp+6493@code.qastaging.launchpad.net

Commit message

[r=tcole, r=rmcbride, r=dobey] Make the tests that require glib2reactor work again

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

This branch fix the dbus config for the tests and setup.py in order to run the tests under the glib reactor.

Revision history for this message
dobey (dobey) wrote :

101 + success = 0
102 + try:
103 + result = runner.run(self.__collect_tests())
104 + success = result.wasSuccessful()
105 + finally:
106 + self.stopDBus()
107 + if success:
108 + sys.exit(success)

we should do something more like the following here:

if not success:
    sys.exit(1)

Always doing sys.exit() here is bad, and will break chained commands to setup.py. But we do want to exit for failure.

review: Needs Fixing
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

fixed and pushed

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Tim Cole (tcole) :
review: Approve
Revision history for this message
Rick McBride (rmcbride) wrote :

tests pass, changes look good. Something in setup.py may not be right. I'll leave that to dobey.

review: Approve
Revision history for this message
dobey (dobey) wrote :

I approved too soon. This needs fixing. You start the glibreactor, but never exit the reactor's loop on success. We need a reactor.stop() somewhere in here I think. :)

review: Needs Fixing
Revision history for this message
Rick McBride (rmcbride) wrote :

Need to get that reactor exiting so that ./setup.py check finishes

review: Needs Fixing
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

On Wed, May 13, 2009 at 10:45 AM, Rodney Dawes
<email address hidden> wrote:
> Review: Needs Fixing
> I approved too soon. This needs fixing. You start the glibreactor, but never exit the reactor's loop on success. We need a reactor.stop() somewhere in here I think. :)
I don't start a glib reactor :)
the issue is stopDbus is broked.
I'll try to fix it, but looks like the subprocess is messed up
> --
> https://code.edge.launchpad.net/~verterok/ubuntuone-client/no-more-timeouts-please/+merge/6493
> You are the owner of lp:~verterok/ubuntuone-client/no-more-timeouts-please.
>

8. By Guillermo Gonzalez

 move out the unittest bits out of setup.py to contrib/test
 run the tests as a subprocess

Revision history for this message
Rick McBride (rmcbride) wrote :

Looks good! check finishes normally now

review: Approve
Revision history for this message
dobey (dobey) wrote :

I still don't like this, but whatever. I am tired of discussing it. :(

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'contrib/testing/dbus-session.conf'
2--- contrib/testing/dbus-session.conf 2009-05-12 17:34:36 +0000
3+++ contrib/testing/dbus-session.conf 2009-05-12 21:45:38 +0000
4@@ -8,11 +8,11 @@
5
6 <listen>unix:tmpdir=/tmp</listen>
7
8- <!-- Load the standard session services -->
9- <standard_session_servicedirs />
10 <!-- Load our own services.
11 To make other dbus service in this session bus, just add another servicedir entry. -->
12- <servicedir>./dbus-session</servicedir>
13+ <servicedir>contrib/testing/dbus-session</servicedir>
14+ <!-- Load the standard session services -->
15+ <!--standard_session_servicedirs /-->
16
17 <policy context="default">
18 <!-- Allow everything to be sent -->
19
20=== modified file 'contrib/testing/testcase.py'
21--- contrib/testing/testcase.py 2009-05-12 17:34:36 +0000
22+++ contrib/testing/testcase.py 2009-05-12 21:45:38 +0000
23@@ -19,13 +19,10 @@
24 import dbus.service
25 import dbus.mainloop.glib
26 import logging
27-import os, signal
28+import os
29 import shutil
30-import subprocess
31 from warnings import warn
32
33-# We use this to find dbus-daemon
34-from distutils.spawn import find_executable
35
36 from canonical.ubuntuone.storage.syncdaemon import (
37 action_queue,
38@@ -147,9 +144,9 @@
39 base = os.path.join(self.__class__.__module__[:MAX_FILENAME],
40 self.__class__.__name__[:MAX_FILENAME],
41 self._testMethodName[:MAX_FILENAME])
42- # use $ROOTDIR/_trial_temp dir
43+ # use _trial_temp dir, it should be os.gwtcwd()
44 # define the root temp dir of the testcase, pylint: disable-msg=W0201
45- self.__root = os.path.join(os.getcwd(), '_trial_temp', base)
46+ self.__root = os.path.join(os.getcwd(), base)
47 return os.path.join(self.__root, 'tmpdir')
48
49 def rmtree(self, path):
50@@ -195,7 +192,7 @@
51 self.event_q = self.main.event_q
52 self.action_q = self.main.action_q
53 self.loop = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
54- self.bus = dbus.SessionBus(self.loop)
55+ self.bus = dbus.bus.BusConnection(mainloop=self.loop)
56 self.nm = FakeNetworkManager(self.bus)
57 # monkeypatch busName.__del__ to avoid errors on gc
58 # we take care of releasing the name in shutdown
59
60=== modified file 'setup.py'
61--- setup.py 2009-05-12 17:34:36 +0000
62+++ setup.py 2009-05-12 21:45:38 +0000
63@@ -3,8 +3,6 @@
64
65 import os, signal, sys, string, unittest
66
67-sys.path.insert(0, os.path.abspath("."))
68-
69 from distutils.core import setup
70 from distutils.spawn import find_executable
71 # pylint: disable-msg=F0401
72@@ -178,18 +176,32 @@
73 check.check.run(self)
74
75 print "\nrunning tests"
76+ # install the glib2reactor before any import of the reactor to avoid
77+ # using the default SelectReactor and be able to run the dbus tests
78+ from twisted.internet import glib2reactor
79+ glib2reactor.install()
80 from twisted.trial.reporter import TreeReporter
81 from twisted.trial.runner import TrialRunner
82
83 self.startDBus()
84
85- runner = TrialRunner(reporterFactory=TreeReporter, realTimeErrors=True)
86-
87- result = runner.run(self.__collect_tests())
88- self.stopDBus()
89-
90- if not result.wasSuccessful():
91- sys.exit(1)
92+ workingDirectory = os.path.join(os.getcwd(), "_trial_temp", "tmp")
93+ runner = TrialRunner(reporterFactory=TreeReporter, realTimeErrors=True,
94+ workingDirectory=workingDirectory)
95+
96+ # setup a custom XDG_CACHE_HOME and create the logs directory
97+ xdg_cache = os.path.join(os.getcwd(), "_trial_temp", "xdg_cache")
98+ os.environ["XDG_CACHE_HOME"] = xdg_cache
99+ if not os.path.exists(xdg_cache):
100+ os.makedirs(xdg_cache)
101+ success = 0
102+ try:
103+ result = runner.run(self.__collect_tests())
104+ success = result.wasSuccessful()
105+ finally:
106+ self.stopDBus()
107+ if success:
108+ sys.exit(success)
109
110
111 setup(name='ubuntuone-client',
112@@ -231,3 +243,4 @@
113 'check' : UbuntuOneCheck,
114 }
115 )
116+

Subscribers

People subscribed via source and target branches