Merge lp:~vila/bzr/781140-ftp-test-coverage into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5960
Proposed branch: lp:~vila/bzr/781140-ftp-test-coverage
Merge into: lp:bzr
Diff against target: 126 lines (+57/-12)
3 files modified
bzrlib/tests/ftp_server/__init__.py (+19/-2)
bzrlib/tests/ftp_server/pyftpdlib_based.py (+33/-10)
doc/en/release-notes/bzr-2.4.txt (+5/-0)
To merge this branch: bzr merge lp:~vila/bzr/781140-ftp-test-coverage
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+63652@code.launchpad.net

Commit message

Support pyftplib-0.6.0 as an ftp test server

Description of the change

We supported two ftp test servers in the past: medusa and pyftpdlib.

Medusa stopped working with python-2.6 due to some
incompatibilities with unicode.

pyftpdlib is not packaged and as such poorly deployed in our ecosystem.

This patch does two things:

- upgrade our test framework to support pyftpdlib 0.6.0,

- disable medusa while keeping the plumbing in place in case the
  unicode issues are addressed in the future. python-3 may help.

Note that the medusa plumbing was removed when we made python-2.6
a requirement. I had to dig a bit to find it back and I like to
keep it disabled (instead of removed) to make it easier to use it
again. An alternative would be fully purge the test framework
from all medusa references but that's more work for little
benefits. Roughly, we try to import and disable support, less
trouble than digging the history.

This patch needs to land before we can deploy pyftpdlib again, be
it on babune or pqm or both.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6/7/2011 9:18 AM, Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging lp:~vila/bzr/781140-ftp-test-coverage into lp:bzr.

...

> Note that the medusa plumbing was removed when we made python-2.6
> a requirement. I had to dig a bit to find it back and I like to
> keep it disabled (instead of removed) to make it easier to use it
> again. An alternative would be fully purge the test framework
> from all medusa references but that's more work for little
> benefits. Roughly, we try to import and disable support, less
> trouble than digging the history.
>
> This patch needs to land before we can deploy pyftpdlib again, be
> it on babune or pqm or both.

+if pyftplib_version < (0, 6,0):

Spacing is wrong on this one.

Otherwise:
 merge: approve

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3t3MQACgkQJdeBCYSNAAP4vACcDqu5EqBCzq0ZnJki9+zh1dFf
Kp0AoJuuQXKx3Ez4Ni2KlAJ7TvPlYb+c
=Ig3r
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

> +if pyftplib_version < (0, 6,0):
>
> Spacing is wrong on this one.

Yup, was already fixed, review-by-mail-gotcha:-/

>
> Otherwise:
> merge: approve

Thanks.

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/ftp_server/__init__.py'
2--- bzrlib/tests/ftp_server/__init__.py 2011-05-11 11:35:28 +0000
3+++ bzrlib/tests/ftp_server/__init__.py 2011-06-07 08:21:37 +0000
4@@ -17,10 +17,25 @@
5 Facilities to use ftp test servers.
6 """
7
8+import sys
9+
10 from bzrlib import tests
11
12
13 try:
14+ from bzrlib.tests.ftp_server import medusa_based
15+ # medusa is bogus starting with python2.6, since we don't support earlier
16+ # pythons anymore, it's currently useless. There is hope though that the
17+ # unicode bugs get fixed in the future so we leave it disabled until
18+ # then. Keeping the framework in place means that only the following line
19+ # will need to be changed. The last tests were conducted with medusa-2.0
20+ # -- vila 20110607
21+ medusa_available = False
22+except ImportError:
23+ medusa_available = False
24+
25+
26+try:
27 from bzrlib.tests.ftp_server import pyftpdlib_based
28 pyftpdlib_available = True
29 except ImportError:
30@@ -38,7 +53,7 @@
31 """
32
33 def _probe(self):
34- return pyftpdlib_available
35+ return medusa_available or pyftpdlib_available
36
37 def feature_name(self):
38 return 'FTPServer'
39@@ -69,7 +84,9 @@
40 raise tests.UnavailableFeature(FTPServerFeature)
41
42
43-if pyftpdlib_available:
44+if medusa_available:
45+ FTPTestServer = medusa_based.FTPTestServer
46+elif pyftpdlib_available:
47 FTPTestServer = pyftpdlib_based.FTPTestServer
48 else:
49 FTPTestServer = UnavailableFTPTestServer
50
51=== modified file 'bzrlib/tests/ftp_server/pyftpdlib_based.py'
52--- bzrlib/tests/ftp_server/pyftpdlib_based.py 2010-06-30 15:19:36 +0000
53+++ bzrlib/tests/ftp_server/pyftpdlib_based.py 2011-06-07 08:21:37 +0000
54@@ -34,6 +34,11 @@
55 from bzrlib.tests import test_server
56
57
58+# Convert the pyftplib string version into a tuple to avoid traps in string
59+# comparison.
60+pyftplib_version = tuple(map(int, ftpserver.__ver__.split('.')))
61+
62+
63 class AnonymousWithWriteAccessAuthorizer(ftpserver.DummyAuthorizer):
64
65 def _check_permissions(self, username, perm):
66@@ -113,16 +118,34 @@
67 self.log('OK SITE CHMOD 0%03o "%s".' % (mode, ftp_path))
68 self.respond('200 SITE CHMOD succesful.')
69
70-
71-# pyftpdlib says to define SITE commands by declaring ftp_SITE_<CMD> methods,
72-# but fails to recognize them.
73-ftpserver.proto_cmds['SITE CHMOD'] = ftpserver._CommandProperty(
74- perm='w', # Best fit choice even if not exactly right (can be d, f or m too)
75- auth_needed=True, arg_needed=True, check_path=False,
76- help='Syntax: SITE CHMOD <SP> octal_mode_bits file-name (chmod file)',
77- )
78-# An empty password is valid, hence the arg is neither mandatory not forbidden
79-ftpserver.proto_cmds['PASS'].arg_needed = None
80+ if pyftplib_version >= (0, 6, 0):
81+ def log_cmd(self, cmd, arg, respcode, respstr):
82+ # base class version choke on unicode, the alternative is to just
83+ # provide an empty implementation and relies on the client to do
84+ # the logging for debugging purposes. Not worth the trouble so far
85+ # -- vila 20110607
86+ if cmd in ("DELE", "RMD", "RNFR", "RNTO", "MKD"):
87+ line = '"%s" %s' % (' '.join([cmd, unicode(arg)]).strip(),
88+ respcode)
89+ self.log(line)
90+
91+
92+if pyftplib_version < (0, 6,0):
93+ # pyftpdlib says to define SITE commands by declaring ftp_SITE_<CMD>
94+ # methods, but fails to recognize them.
95+ ftpserver.proto_cmds['SITE CHMOD'] = ftpserver._CommandProperty(
96+ # Best fit choice even if not exactly right (can be d, f or m too)
97+ perm='w',
98+ auth_needed=True, arg_needed=True, check_path=False,
99+ help='Syntax: SITE CHMOD <SP> octal_mode_bits file-name (chmod file)',
100+ )
101+ # An empty password is valid, hence the arg is neither mandatory not
102+ # forbidden
103+ ftpserver.proto_cmds['PASS'].arg_needed = None
104+else:
105+ # Same rationale as above (the password should be optional), but the hole
106+ # in pyftplib-0.6.0 is narrower
107+ ftpserver.proto_cmds['PASS']['arg'] = None
108
109
110 class ftp_server(ftpserver.FTPServer):
111
112=== modified file 'doc/en/release-notes/bzr-2.4.txt'
113--- doc/en/release-notes/bzr-2.4.txt 2011-06-06 11:13:41 +0000
114+++ doc/en/release-notes/bzr-2.4.txt 2011-06-07 08:21:37 +0000
115@@ -117,6 +117,11 @@
116 * Multiple ``selftest --exclude`` options are now combined instead of
117 overriding each other. (Vincent Ladeuil, #746991)
118
119+* Restore some ``FTPTransport`` test coverage by allowing ``pyftpdlib
120+ 0.6.0`` to be used. Also restore ``medusa`` support while leaving it
121+ disabled to make it easier to use if/when we can in the future.
122+ (Vincent Ladeuil, #781140)
123+
124 * `TestImportTariffs` no longer uses the real ``$HOME``. This prevents it
125 from polluting ``$HOME/.bzr.log`` or being accidentally influenced by
126 user configuration such as aliases. It still runs with all the user's