Merge lp:~bjornt/launchpad/windmill-problems into lp:launchpad

Proposed by Björn Tillenius
Status: Merged
Approved by: Deryck Hodge
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~bjornt/launchpad/windmill-problems
Merge into: lp:launchpad
Diff against target: 164 lines
4 files modified
lib/canonical/launchpad/windmill/testing/constants.py (+2/-2)
lib/canonical/launchpad/windmill/testing/lpuser.py (+28/-19)
lib/canonical/testing/layers.py (+8/-0)
lib/lp/bugs/windmill/tests/test_bug_tags_entry.py (+10/-9)
To merge this branch: bzr merge lp:~bjornt/launchpad/windmill-problems
Reviewer Review Type Date Requested Status
Deryck Hodge (community) code Approve
Review via email: mp+14024@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

This branch fixes a bunch of problems with the Windmill tests. Normally
I would have done each fix in a separate branch, but it was hard to see
any progress when applying only a single fix, so I combined them into
one branch. This branch reduces the number of failures from 7-8, to 1-2.
At least one of the remaining test failure looks valid, the other one
intermittent, so I'm going to look into that in another branch.

What I've done is to:

    1) Increase the default timeout values. This should be OK, since the
       only bad effect this has is that tests take longer to fail, if
       they fail when waiting for something. It's too bad, and I'm going
       to look into why everything is taking so long.

    2) Make LaunchpadUser.ensure_login() be able to log in when the
       current page already is a +login page. There were some tests that
       failed, since the previous tests ended on a +login page. In this
       case, ensure_login() though that we were logged in, so it tried
       to press the nonexisting logout button.

    3) Disable the check for left-over threads. This check is meant to
       prevent production code from leaking threads. The only threads
       that are left here are threads that Windmill uses. Since the
       Windmill state is shared across multiple tests, we shouldn't have
       a check between the tests. The threads should be cleaned up when
       the layer is torn down, not when the test is it.

    4) Change test_bug_tags_entry.py to use constants instead of
       hard-coding the timeout values. I did this, because I needed to
       increase the timeouts due to test failures, so it made sense to
       clean it up, instead of increasing the hard-coded timeouts.

--
Björn Tillenius | https://launchpad.net/~bjornt

Revision history for this message
Deryck Hodge (deryck) wrote :

Hi, Björn.

I'll just note our IRC conversation here, that the ensure_login changes should use timeout constants and that there is an extra space after the opening paren at line 38 in the diff.

Otherwise, this looks nice. And as you know, this affects my current work, so I personally really appreciate you working on these issues! Thanks!

Cheers,
deryck

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/windmill/testing/constants.py'
2--- lib/canonical/launchpad/windmill/testing/constants.py 2009-06-25 05:30:52 +0000
3+++ lib/canonical/launchpad/windmill/testing/constants.py 2009-10-27 13:04:14 +0000
4@@ -8,7 +8,7 @@
5 __metaclass__ = type
6 __all__ = []
7
8-PAGE_LOAD = unicode(20000)
9-FOR_ELEMENT = unicode(10000)
10+PAGE_LOAD = unicode(40000)
11+FOR_ELEMENT = unicode(20000)
12 SLEEP = unicode(5000)
13
14
15=== modified file 'lib/canonical/launchpad/windmill/testing/lpuser.py'
16--- lib/canonical/launchpad/windmill/testing/lpuser.py 2009-10-14 17:33:28 +0000
17+++ lib/canonical/launchpad/windmill/testing/lpuser.py 2009-10-27 13:04:14 +0000
18@@ -6,6 +6,8 @@
19 __metaclass__ = type
20 __all__ = []
21
22+from canonical.launchpad.windmill.testing import constants
23+
24
25 class LaunchpadUser:
26 """Object representing well-known user on Launchpad."""
27@@ -17,27 +19,33 @@
28
29 def ensure_login(self, client):
30 """Ensure that this user is logged on the page under windmill."""
31+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
32 result = client.asserts.assertNode(
33- link=u'Log in / Register', assertion=False)
34- if not result['result']:
35- # User is probably logged in.
36- # Check under which name they are logged in.
37- result = client.commands.execJS(
38- code="""lookupNode({xpath: '//div[@id="logincontrol"]//a'}).text""")
39- if (result['result'] is not None and
40- result['result'].strip() == self.display_name):
41- # We are logged as that user.
42- return
43- client.click(name="logout")
44- client.waits.forElement(
45- link=u'Log in / Register', timeout=u'20000')
46- client.click(link=u'Log in / Register')
47- client.waits.forPageLoad(timeout=u'20000')
48- client.waits.forElement(timeout=u'8000', id=u'email')
49+ name=u'loginpage_submit_login', assertion=False)
50+ already_on_login_page = result['result']
51+ if not already_on_login_page:
52+ result = client.asserts.assertNode(
53+ link=u'Log in / Register', assertion=False)
54+ if not result['result']:
55+ # User is probably logged in.
56+ # Check under which name they are logged in.
57+ result = client.commands.execJS(
58+ code="""lookupNode({xpath: '//div[@id="logincontrol"]//a'}).text""")
59+ if (result['result'] is not None and
60+ result['result'].strip() == self.display_name):
61+ # We are logged as that user.
62+ return
63+ client.click(name="logout")
64+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
65+ client.waits.forElement(
66+ link=u'Log in / Register', timeout=constants.FOR_ELEMENT)
67+ client.click(link=u'Log in / Register')
68+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
69+ client.waits.forElement(timeout=constants.FOR_ELEMENT, id=u'email')
70 client.type(text=self.email, id=u'email')
71 client.type(text=self.password, id=u'password')
72 client.click(name=u'loginpage_submit_login')
73- client.waits.forPageLoad(timeout=u'20000')
74+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
75
76
77 class AnonymousUser:
78@@ -45,13 +53,14 @@
79
80 def ensure_login(self, client):
81 """Ensure that the user is surfing anonymously."""
82+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
83 result = client.asserts.assertNode(
84 link=u'Log in / Register', assertion=False)
85 if result['result']:
86 return
87- client.waits.forElement(name="logout", timeout=u"100000")
88+ client.waits.forElement(name="logout", timeout=constants.FOR_ELEMENT)
89 client.click(name="logout")
90- client.waits.forPageLoad(timeout=u'100000')
91+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
92
93
94 def login_person(person, password, client):
95
96=== modified file 'lib/canonical/testing/layers.py'
97--- lib/canonical/testing/layers.py 2009-09-17 17:46:09 +0000
98+++ lib/canonical/testing/layers.py 2009-10-27 13:04:14 +0000
99@@ -1736,3 +1736,11 @@
100 if cls.config_file is not None:
101 # Close the file so that it gets deleted.
102 cls.config_file.close()
103+
104+ @classmethod
105+ @profiled
106+ def testSetUp(cls):
107+ # Left-over threads should be harmless, since they should all
108+ # belong to Windmill, which will be cleaned up on layer
109+ # tear down.
110+ BaseLayer.disable_thread_check = True
111
112=== modified file 'lib/lp/bugs/windmill/tests/test_bug_tags_entry.py'
113--- lib/lp/bugs/windmill/tests/test_bug_tags_entry.py 2009-10-20 22:21:39 +0000
114+++ lib/lp/bugs/windmill/tests/test_bug_tags_entry.py 2009-10-27 13:04:14 +0000
115@@ -12,7 +12,7 @@
116 from windmill.authoring import WindmillTestClient
117
118 from canonical.launchpad.webapp import canonical_url
119-from canonical.launchpad.windmill.testing import lpuser
120+from canonical.launchpad.windmill.testing import constants, lpuser
121 from lp.bugs.windmill.testing import BugsWindmillLayer
122 from lp.testing import TestCaseWithFactory
123
124@@ -43,8 +43,8 @@
125 # Now let's tag a bug using the auto-complete widget
126
127 client.open(url=bug_url)
128- client.waits.forPageLoad(timeout=u'300000')
129- client.waits.sleep(milliseconds=u'8000')
130+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
131+ client.waits.sleep(milliseconds=constants.SLEEP)
132
133 # XXX intellectronica 2009-05-26:
134 # We (almost) consistently get an error on the following line
135@@ -52,23 +52,24 @@
136 # to the link's URL.
137
138 client.click(id=u'edit-tags-trigger')
139- client.waits.forElement(id=u'tag-input', timeout=u'8000')
140+ client.waits.forElement(
141+ id=u'tag-input', timeout=constants.FOR_ELEMENT)
142 client.type(text=u'ee', id=u'tag-input')
143- client.waits.sleep(milliseconds=u'1000')
144+ client.waits.sleep(milliseconds=constants.SLEEP)
145 client.asserts.assertNode(classname=u'yui-autocomplete-list')
146 client.click(id=u'item0')
147 client.click(id=u'edit-tags-ok')
148- client.waits.sleep(milliseconds=u'8000')
149+ client.waits.sleep(milliseconds=constants.SLEEP)
150 client.asserts.assertText(id=u'tag-list', validator=u'eenie')
151
152 # Test that anonymous users are prompted to log in.
153
154 lpuser.ANONYMOUS.ensure_login(client)
155 client.open(url=bug_url)
156- client.waits.forPageLoad(timeout=u'50000')
157- client.waits.sleep(milliseconds=u'8000')
158+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
159+ client.waits.sleep(milliseconds=constants.SLEEP)
160 client.click(id=u'edit-tags-trigger')
161- client.waits.forPageLoad(timeout=u'50000')
162+ client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
163 client.asserts.assertJS(
164 js=u'window.location.href.indexOf("+login") > 0')
165