Merge lp:~wallyworld/launchpad/fix-hardcoded-test-urls into lp:launchpad/db-devel
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Robert Collins on 2010-10-19 | ||||
| Approved revision: | no longer in the source branch. | ||||
| Merged at revision: | 9921 | ||||
| Proposed branch: | lp:~wallyworld/launchpad/fix-hardcoded-test-urls | ||||
| Merge into: | lp:launchpad/db-devel | ||||
| Diff against target: |
1708 lines (+306/-191) 59 files modified
lib/canonical/config/__init__.py (+12/-2) lib/canonical/launchpad/doc/launchpadlib.txt (+13/-7) lib/canonical/launchpad/testing/browser.py (+16/-0) lib/canonical/launchpad/webapp/tests/cookie-authentication.txt (+21/-11) lib/canonical/launchpad/webapp/tests/login.txt (+9/-6) lib/canonical/launchpad/webapp/tests/no-anonymous-session-cookies.txt (+6/-4) lib/canonical/launchpad/webapp/tests/test_login.py (+6/-5) lib/canonical/testing/__init__.py (+1/-0) lib/canonical/testing/layers.py (+19/-10) lib/lp/bugs/windmill/testing.py (+5/-1) lib/lp/bugs/windmill/tests/test_bug_also_affects_new_upstream.py (+18/-12) lib/lp/bugs/windmill/tests/test_bug_commenting.py (+1/-1) lib/lp/bugs/windmill/tests/test_bug_inline_subscriber.py (+11/-9) lib/lp/bugs/windmill/tests/test_bug_me_too.py (+1/-1) lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py (+6/-5) lib/lp/bugs/windmill/tests/test_filebug_dupe_finder.py (+3/-3) lib/lp/bugs/windmill/tests/test_filebug_extra_options.py (+1/-1) lib/lp/bugs/windmill/tests/test_mark_duplicate.py (+2/-2) lib/lp/bugs/windmill/tests/test_official_bug_tags_management.py (+1/-1) lib/lp/code/model/tests/test_sourcepackagerecipe.py (+1/-1) lib/lp/code/windmill/testing.py (+5/-1) lib/lp/code/windmill/tests/test_branch_bugspeclinks.py (+1/-1) lib/lp/code/windmill/tests/test_branch_subscriptions.py (+2/-2) lib/lp/code/windmill/tests/test_branchmergeproposal_review.py (+1/-1) lib/lp/code/windmill/tests/test_productseries_setbranch.py (+1/-1) lib/lp/registry/windmill/testing.py (+5/-1) lib/lp/registry/windmill/tests/test_add_bugtracker.py (+2/-1) lib/lp/registry/windmill/tests/test_add_milestone.py (+1/-1) lib/lp/registry/windmill/tests/test_datetime_picker.py (+2/-1) lib/lp/registry/windmill/tests/test_person_picker.py (+2/-1) lib/lp/registry/windmill/tests/test_plusnew_step1.py (+2/-1) lib/lp/registry/windmill/tests/test_plusnew_step2.py (+2/-1) lib/lp/registry/windmill/tests/test_product.py (+2/-2) lib/lp/registry/windmill/tests/test_product_edit_people.py (+2/-2) lib/lp/registry/windmill/tests/test_project_licenses.py (+4/-2) lib/lp/registry/windmill/tests/test_team_index.py (+1/-1) lib/lp/registry/windmill/tests/test_timeline_graph.py (+7/-4) lib/lp/services/mailman/doc/contact-address.txt (+13/-10) lib/lp/services/mailman/doc/create-lists.txt (+3/-1) lib/lp/services/mailman/doc/deactivate-lists.txt (+3/-1) lib/lp/services/mailman/doc/decorations.txt (+3/-1) lib/lp/services/mailman/doc/modify-lists.txt (+3/-1) lib/lp/services/mailman/doc/postings.txt (+13/-17) lib/lp/services/mailman/doc/reactivate-lists.txt (+3/-1) lib/lp/services/mailman/doc/recovery.txt (+4/-2) lib/lp/services/mailman/testing/helpers.py (+2/-2) lib/lp/soyuz/windmill/testing.py (+7/-1) lib/lp/soyuz/windmill/tests/test_archive_packages.py (+2/-1) lib/lp/soyuz/windmill/tests/test_archivesubscribersindex.py (+3/-2) lib/lp/soyuz/windmill/tests/test_ppainlineedit.py (+1/-1) lib/lp/testing/__init__.py (+7/-4) lib/lp/testing/factory.py (+2/-1) lib/lp/translations/windmill/testing.py (+5/-1) lib/lp/translations/windmill/tests/disabled_test_productseries_templates.py (+2/-2) lib/lp/translations/windmill/tests/test_documentation_links.py (+4/-4) lib/lp/translations/windmill/tests/test_import_queue.py (+1/-1) lib/lp/translations/windmill/tests/test_languages.py (+1/-1) lib/lp/translations/windmill/tests/test_pofile_translate.py (+28/-28) lib/lp/translations/windmill/tests/test_serieslanguages.py (+1/-2) |
||||
| To merge this branch: | bzr merge lp:~wallyworld/launchpad/fix-hardcoded-test-urls | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Robert Collins (community) | 2010-10-18 | Approve on 2010-10-19 | |
| Ian Booth (community) | Resubmit on 2010-10-19 | ||
|
Review via email:
|
|||
Commit Message
Remove hard coded urls from various tests.
Description of the Change
This branch is part of the effort to support parallel test runs. It removes the use of hard coded urls (in particular port numbers) in doc, windmill, yui and unit tests. Currently, when running tests, the (only) test app server instance is run up on port 8085, which results in urls like "http://
Implementation
-------
The CanonicalConfig class has a new method:
def root_launchpad_
"""Return the correct root url for the given facet."""
So for a given config in use when running tests, it is possible to find out what the correct root url to use is. eg
facet='mainsite' -> http://
facet ='code' -> http://
At the moment, there's only one possible named config - 'testrunner-
@classmethod
def getAppServerCon
"""Return a config suitable for AppServer tests."""
# XXX wallyworld 2010-10-18
# use BaseLayer.
return CanonicalConfig
To make it easy for test code to simply get the correct root url instead of using a hard coded string literal, helper methods have been added to canonical/
def getAppServerCon
"""Return a config suitable for AppServer tests."""
return BaseLayer.
def getRootLaunchpa
"""Return the correct root url for the given facet."""
return getAppServerCon
So test code can do stuff like the following, which is pretty straight forward:
New:
from canonical.testing import getRootLaunchpadUrl
root_url = getRootLaunchpa
Old:
root_url = 'http://
For doc tests, it was necessary to add some extra properties to canonical/
- vhost
- rooturl
- urlpath
These enabled expected output tests to be refactored to remove the reference to the hard coded port number.
For windmill tests, the BaseWindmillLayer class has a base_url property. This property is now set during the test set up using the root url derived from the config instance. Existing windmill code was perhaps poorly written in that despite this base_url property being available, hard coded urls were still used. So there were simple replaced with references to the base_url property.
Next Steps
--------------
Once this branch lands, and once the branch lp:~lifeless/launchpad/uniqueconfig lands, then the next step is to remove the hard coded app server config name 'testrunner-
Tests
------
bin/test -vvt launchpadlib.txt
bin/test -vvt cookie-
bin/test -vvt login.txt
bin/test -vvt no-anonymous-
bin/test -vvt webapp.
bin/test -vvt shipit-login.txt
bin/test -vvt windmill
bin/test -vvt test_sourcepack
bin/test -vvt test_productser
bin/test -vvt test_yui
Lint
----
Some drive by lint fixes were done. The remaining issues were already in the code base.
bin/lint.sh
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/canonical
lib/canonical
lib/canonical
lib/canonical
lib/canonical
lib/canonical
lib/canonical
lib/canonical
lib/canonical
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
./lib/canonical
330: W602 deprecated form of raising exception
332: W602 deprecated form of raising exception
334: W602 deprecated form of raising exception
376: E202 whitespace before ')'
./lib/canonical
1: narrative uses a moin header.
./lib/canonical
22: want exceeds 78 characters.
./lib/canonical
20: want exceeds 78 characters.
./lib/canonical
24: want exceeds 78 characters.
./lib/canonical
83: 'from canonical.
79: 'canonical' imported but unused
./lib/canonical
84: redefinition of unused 'zope' from line 83
532: redefinition of unused 'pidfile' from line 96
332: E231 missing whitespace after ','
400: E202 whitespace before ')'
475: E302 expected 2 blank lines, found 1
592: E202 whitespace before ')'
608: E202 whitespace before ')'
628: E202 whitespace before ')'
742: E202 whitespace before ')'
869: E301 expected 1 blank line, found 0
878: W291 trailing whitespace
1010: E301 expected 1 blank line, found 2
1037: E202 whitespace before ')'
1047: E202 whitespace before ')'
1093: E202 whitespace before ')'
1114: E202 whitespace before ')'
1152: E301 expected 1 blank line, found 2
1249: E301 expected 1 blank line, found 0
1312: E302 expected 2 blank lines, found 3
1410: E202 whitespace before ')'
1423: E202 whitespace before ')'
1427: E301 expected 1 blank line, found 2
1511: E301 expected 1 blank line, found 0
1531: E301 expected 1 blank line, found 0
1561: E301 expected 1 blank line, found 2
1619: E301 expected 1 blank line, found 0
878: Line has trailing whitespace.
883: Line exceeds 78 characters.
./lib/lp/
12: 'config' imported but unused
./lib/lp/
21: E302 expected 2 blank lines, found 1
37: E501 line too long (81 characters)
38: E501 line too long (82 characters)
39: E501 line too long (81 characters)
58: E302 expected 2 blank lines, found 1
37: Line exceeds 78 characters.
38: Line exceeds 78 characters.
39: Line exceeds 78 characters.
./lib/lp/
20: E302 expected 2 blank lines, found 1
249: E302 expected 2 blank lines, found 1
./lib/lp/
24: E302 expected 2 blank lines, found 1
33: E301 expected 1 blank line, found 0
126: E302 expected 2 blank lines, found 1
./lib/lp/
179: E302 expected 2 blank lines, found 1
./lib/lp/
33: E302 expected 2 blank lines, found 1
122: E302 expected 2 blank lines, found 1
./lib/lp/
145: E302 expected 2 blank lines, found 1
./lib/lp/
214: E302 expected 2 blank lines, found 1
./lib/lp/
56: E302 expected 2 blank lines, found 1
./lib/lp/
9: 'time' imported but unused
./lib/lp/
81: E302 expected 2 blank lines, found 1
./lib/lp/
167: E202 whitespace before ']'
299: E301 expected 1 blank line, found 0
306: E301 expected 1 blank line, found 0
./lib/lp/
102: E302 expected 2 blank lines, found 1
./lib/lp/
132: 'anonymous_
132: 'with_anonymous
132: 'is_logged_in' imported but unused
151: 'launchpadlib_for' imported but unused
151: 'launchpadlib_
132: 'person_logged_in' imported but unused
151: 'oauth_
132: 'login_celebrity' imported but unused
132: 'with_celebrity
150: 'test_tales' imported but unused
132: 'celebrity_
132: 'run_with_login' imported but unused
132: 'with_person_
132: 'login_team' imported but unused
132: 'login_person' imported but unused
132: 'login_as' imported but unused
447: E301 expected 1 blank line, found 0
878: E301 expected 1 blank line, found 0
904: E302 expected 2 blank lines, found 1
980: E302 expected 2 blank lines, found 1
./lib/lp/
3157: redefinition of function 'makePackageDiff' from line 1847
./lib/lp/
78: E202 whitespace before ')'
494: W391 blank line at end of file
./lib/lp/
81: W391 blank line at end of file
| Ian Booth (wallyworld) wrote : | # |
On 19/10/10 08:58, Robert Collins wrote:
> Review: Approve
> A few thoughts.
>
> Those helper methods are coupled to BaseLayer; why not put them on BaseLayer? At the moment it looks a bit fragmented.
>
My thoughts were that I wanted to have "standalone" helper methods which
were independent of any implementation details. So I think you are
proposing:
from canonical.
root_url = BaseLayer.
or even
from canonical.
root_url = BaseLayer.
instead of
from canonical.testing import getRootLaunchpadUrl
root_url = getRootLaunchpa
I wanted to hide how the root url was determined and to decouple the
underlying implementation from the innovation method. So the caller has
no knowledge or code dependency on how the root url or app server config
is retrieved. Maybe it's YAGNI, but I wanted to allow the implementation
change without needing to go back and change lots of existing test code.
I could loose the getRootLaunchpa
from canonical.testing import getAppServerConfig
root_url = getAppServerCon
but I though it was such a common operation that it perhaps deserved
it's own "shortcut".
Do you agree that there's merit in my approach? Do you want me to change
it? Perhaps I should just ditch the getRootLaunchpa
Recommendations?
> Rather than hardcoding with an XXX, if you do
>
> cls.appserver_
>
> in BaseLayer.setUp, your code won't need changing at all when uniqueconfig lands.
Yes, good idea, thanks.
| Ian Booth (wallyworld) wrote : | # |
>
> Rather than hardcoding with an XXX, if you do
>
> cls.appserver_
>
> in BaseLayer.setUp, your code won't need changing at all when uniqueconfig lands.
Bollocks. The Windmill layers need work to support this since they set
their base_url at class instantiation time. I need to go and add setUp()
methods to these layers.
| Robert Collins (lifeless) wrote : | # |
On Tue, Oct 19, 2010 at 12:31 PM, Ian Booth <email address hidden> wrote:
>>
>> Rather than hardcoding with an XXX, if you do
>>
>> cls.appserver_
>>
>> in BaseLayer.setUp, your code won't need changing at all when uniqueconfig lands.
>
> Bollocks. The Windmill layers need work to support this since they set
> their base_url at class instantiation time. I need to go and add setUp()
> methods to these layers.
Heh, if its hard, don't bother in this landing, just iterate on it.
Re the helper methods.
Helper methods that hide global state terrify me.
Helper methods that are reusable are totally cool.
The ones you have actually are depending on global state; state that
has a home - BaseLayer.
You could have
appserver_
or some such. I think that avoiding deep dotted notation is a good
idea. (Law of demeter).
Certainly at least one of your functions depends totally on BaseLayer,
and I don't see it making any sense as anything other than a method.
A test I like to use is 'does this thing make sense in a different
context'? -> No, it should be a method, or at least a helper that
takes a thing matching some protocol to work with. Yes? -> totally
fine as a method.
-Rob
| Ian Booth (wallyworld) wrote : | # |
>>
>> Bollocks. The Windmill layers need work to support this since they set
>> their base_url at class instantiation time. I need to go and add setUp()
>> methods to these layers.
>
> Heh, if its hard, don't bother in this landing, just iterate on it.
>
Already done. Doing local testing now.
> Re the helper methods.
>
<snip>
I'll rework some of the implementation aspects and get back to you.
| Ian Booth (wallyworld) wrote : | # |
I cleaned up the implementation and added the appserver_root_url method to the BaseLayer. Some of the implementation did have some dumb things in there, carried over from the doc test changes. I was clearly too close to the code by that point and needed to step back a little. It looks a lot nicer now.
The layer setup initialises the appserver_
| Robert Collins (lifeless) wrote : | # |
Thank you for experimenting there, yes it does look nicer.
Might like to change
# Set the default config name.
to
# Set the default appserver config instance name.
(Because its not the 'default config name' :).

A few thoughts.
Those helper methods are coupled to BaseLayer; why not put them on BaseLayer? At the moment it looks a bit fragmented.
Rather than hardcoding with an XXX, if you do
cls. appserver_ config_ name = 'testrunner- appserver'
in BaseLayer.setUp, your code won't need changing at all when uniqueconfig lands.