13233.1.1
by Jeroen Vermeulen
Lint. |
1 |
DDTP-TARBALL upload |
2 |
------------------- |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
3 |
|
3686.1.14
by Celso Providelo
review comments |
4 |
This test will describe how launchpad treats an upload of DDTP |
5 |
tarball. |
|
6 |
||
7 |
DDTP (Debian Description Translation Project) tarball upload is |
|
8 |
consisted of a tarball (specified in the changesfile as a |
|
9 |
DDTP-TARBALL) containing all the supported index files for the DDTP |
|
10 |
contents driven by component. |
|
11 |
||
12 |
The index-files needs to be published in the ubuntu archive, according |
|
13 |
its target suite and component, under the 'i18n' (see |
|
14 |
http://en.wikipedia.org/wiki/Internationalization_and_localization) |
|
15 |
directory. |
|
16 |
||
17 |
Soonish APT will be able to download and follow the indexes files, |
|
18 |
then present the appropriated translated package description the users |
|
19 |
in ubuntu. |
|
20 |
||
21 |
For further info about DDTP see: |
|
22 |
https://wiki.ubuntu.com/TranslatedPackageDescriptionsSpec |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
23 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
24 |
>>> from lp.registry.interfaces.distribution import IDistributionSet |
25 |
||
26 |
>>> ubuntutest = getUtility(IDistributionSet)['ubuntutest'] |
|
27 |
>>> breezy_autotest = ubuntutest['breezy-autotest'] |
|
28 |
||
29 |
>>> from lp.archiveuploader.nascentupload import NascentUpload |
|
30 |
>>> from lp.archiveuploader.tests import datadir, getPolicy |
|
31 |
||
32 |
>>> from canonical.launchpad.ftests import import_public_test_keys |
|
33 |
>>> import_public_test_keys() |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
34 |
|
3686.1.14
by Celso Providelo
review comments |
35 |
Login as an admin (or ubuntutest.archive_admin if we have one), since |
3691.441.24
by Malcolm Cleaton
More renaming |
36 |
we need to access and modify PackageUpload records and other tables. |
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
37 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
38 |
>>> login('foo.bar@canonical.com') |
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
39 |
|
4204.2.11
by Julian Edwards
Last few tests are fixed. This branch is Good To Go (tm). |
40 |
Set the email address for announcements: |
41 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
42 |
>>> breezy_autotest.changeslist = 'test@example.com' |
4204.2.11
by Julian Edwards
Last few tests are fixed. This branch is Good To Go (tm). |
43 |
|
3686.1.14
by Celso Providelo
review comments |
44 |
First, test the rejection of a missapplied changesfile name, which |
45 |
doesn't follow the accepted format, "<pkg>_<version>_<arch>.changes" |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
46 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
47 |
>>> sync_policy = getPolicy( |
48 |
... name='sync', distro='ubuntutest', distroseries=None) |
|
3804.1.24
by Celso Providelo
fix doc/distroreleasequeue* tests. |
49 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
50 |
>>> from lp.services.log.logger import DevNullLogger |
51 |
>>> upload = NascentUpload.from_changesfile_path( |
|
52 |
... datadir('ddtp-tarball/translations-main_20060728.changes'), |
|
53 |
... sync_policy, DevNullLogger()) |
|
54 |
>>> upload.process() |
|
55 |
Traceback (most recent call last): |
|
56 |
... |
|
57 |
EarlyReturnUploadError: An error occurred that prevented further |
|
58 |
processing. |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
59 |
|
60 |
Now do a proper upload into the system. |
|
61 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
62 |
>>> insecure_policy = getPolicy( |
63 |
... name='insecure', distro='ubuntutest', distroseries=None) |
|
64 |
||
65 |
>>> from lp.services.log.logger import FakeLogger |
|
66 |
>>> upload = NascentUpload.from_changesfile_path( |
|
67 |
... datadir('ddtp-tarball/translations-main_20060728_all.changes'), |
|
68 |
... insecure_policy, FakeLogger()) |
|
69 |
DEBUG Verifying signature on translations-main_20060728_all.changes |
|
70 |
||
71 |
>>> upload.process() |
|
72 |
DEBUG Beginning processing. |
|
73 |
DEBUG Verifying the changes file. |
|
74 |
DEBUG Verifying files in upload. |
|
75 |
DEBUG Single Custom Upload detected. |
|
76 |
DEBUG Finished checking upload. |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
77 |
|
78 |
It was not rejected. |
|
79 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
80 |
>>> upload.is_rejected |
81 |
False |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
82 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
83 |
>>> success = upload.do_accept() |
84 |
DEBUG Creating queue entry |
|
85 |
... |
|
86 |
DEBUG Sent a mail: |
|
87 |
DEBUG Subject: [ubuntutest/breezy-autotest] |
|
88 |
translations_main_20060728.tar.gz - (Accepted) |
|
89 |
DEBUG Sender: Root <root@localhost> |
|
90 |
DEBUG Recipients: Foo Bar <foo.bar@canonical.com> |
|
91 |
DEBUG Bcc: Root <root@localhost> |
|
92 |
DEBUG Body: |
|
93 |
DEBUG . |
|
94 |
DEBUG * Duhh |
|
95 |
DEBUG |
|
96 |
DEBUG |
|
97 |
DEBUG Date: Thu, 01 Aug 2006 14:20:25 +0300 |
|
98 |
DEBUG Changed-By: Foo Bar <foo.bar@canonical.com> |
|
99 |
DEBUG Origin: Ubuntu/warty |
|
100 |
DEBUG |
|
101 |
DEBUG |
|
102 |
DEBUG == |
|
103 |
DEBUG |
|
104 |
DEBUG Announcing to test@example.com |
|
105 |
DEBUG |
|
106 |
DEBUG Thank you for your contribution to Ubuntu Test. |
|
107 |
DEBUG |
|
108 |
DEBUG -- |
|
109 |
DEBUG You are receiving this email because you are the uploader, |
|
110 |
maintainer or |
|
111 |
DEBUG signer of the above package. |
|
112 |
DEBUG Sent a mail: |
|
113 |
DEBUG Subject: [ubuntutest/breezy-autotest] |
|
114 |
translations_main_20060728.tar.gz - (Accepted) |
|
115 |
DEBUG Sender: Foo Bar <foo.bar@canonical.com> |
|
116 |
DEBUG Recipients: test@example.com |
|
117 |
DEBUG Bcc: Root <root@localhost> |
|
118 |
DEBUG Body: |
|
119 |
DEBUG . |
|
120 |
DEBUG * Duhh |
|
121 |
DEBUG |
|
122 |
DEBUG |
|
123 |
DEBUG Date: Thu, 01 Aug 2006 14:20:25 +0300 |
|
124 |
DEBUG Changed-By: Foo Bar <foo.bar@canonical.com> |
|
125 |
DEBUG Origin: Ubuntu/warty |
|
126 |
DEBUG |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
127 |
|
128 |
And all things worked. |
|
129 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
130 |
>>> success |
131 |
True |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
132 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
133 |
>>> not upload.rejection_message |
134 |
True |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
135 |
|
136 |
We need to commit the transaction to be able to use the librarian files. |
|
137 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
138 |
>>> flush_database_updates() |
139 |
>>> transaction.commit() |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
140 |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
141 |
Let's use the script to fetch the ddtp-tarball upload: |
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
142 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
143 |
>>> import subprocess |
144 |
>>> import os |
|
145 |
>>> import sys |
|
146 |
>>> from canonical.config import config |
|
147 |
||
148 |
>>> script = os.path.join( |
|
149 |
... config.root, "scripts", "ftpmaster-tools", "queue") |
|
150 |
||
151 |
>>> process = subprocess.Popen([sys.executable, script, "-Q", "accepted", |
|
152 |
... "-s", "breezy-autotest", "fetch", "trans", |
|
153 |
... "-d", "ubuntutest"], |
|
154 |
... stdout=subprocess.PIPE) |
|
155 |
>>> stdout, stderr = process.communicate() |
|
156 |
>>> process.returncode |
|
157 |
0 |
|
158 |
>>> print stdout |
|
159 |
Initializing connection to queue accepted |
|
160 |
Running: "fetch trans" |
|
161 |
Fetching ubuntutest/breezy-autotest (ACCEPTED) 1/1 |
|
162 |
--------------------------------------------------------------------------- |
|
163 |
Constructing translations-main_20060728_all.changes |
|
164 |
Constructing translations_main_20060728.tar.gz |
|
165 |
--------------------------------------------------------------------------- |
|
166 |
1/1 total |
|
167 |
<BLANKLINE> |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
168 |
|
169 |
Check if the files were written: |
|
170 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
171 |
>>> os.path.exists('translations-main_20060728_all.changes') |
172 |
True |
|
173 |
>>> os.path.exists('translations_main_20060728.tar.gz') |
|
174 |
True |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
175 |
|
176 |
Cleanup the mess: |
|
177 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
178 |
>>> os.remove('translations-main_20060728_all.changes') |
179 |
>>> os.remove('translations_main_20060728.tar.gz') |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
180 |
|
181 |
||
182 |
Inspect the QUEUE looking for an ACCEPTED entry corresponding to the |
|
183 |
previous upload: |
|
184 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
185 |
>>> from lp.soyuz.enums import PackageUploadStatus |
186 |
>>> queue_item = breezy_autotest.getQueueItems( |
|
187 |
... status=PackageUploadStatus.ACCEPTED)[0] |
|
188 |
>>> queue_item.customfiles[0].libraryfilealias.filename |
|
189 |
u'translations_main_20060728.tar.gz' |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
190 |
|
191 |
Do the publish, i.e process the CustomUpload decompressing and writing |
|
3686.1.20
by Celso Providelo
improving DDTP custom format processor and tests, checking the size of result files in archive |
192 |
the tarball contents in the archive, collect and check debug message: |
193 |
||
4092.2.19
by Barry Warsaw
Because these tests also do custom uploads, they need to ensure the umask is |
194 |
The umask must be 022 in order to perform the upload. |
195 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
196 |
>>> old_mask = os.umask(022) |
197 |
>>> pub_records = queue_item.realiseUpload(FakeLogger()) |
|
198 |
DEBUG Publishing custom translations_main_20060728.tar.gz to |
|
199 |
ubuntutest/breezy-autotest |
|
200 |
>>> print '%03o' % os.umask(old_mask) |
|
201 |
022 |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
202 |
|
203 |
Check what was published in the target directory: |
|
204 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
205 |
>>> import os |
206 |
>>> archive_dir = '/var/tmp/archive/' |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
207 |
|
3686.1.22
by Celso Providelo
applying review comments |
208 |
DDTP indexes are published in the "i18n" directory inside archive dists: |
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
209 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
210 |
>>> upgrade_dir = 'ubuntutest/dists/breezy-autotest/main/i18n' |
211 |
>>> target_dir = os.path.join(archive_dir, upgrade_dir) |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
212 |
|
213 |
We simply decompress the contents of the tarball, the files follow |
|
214 |
the format: |
|
215 |
||
3686.1.14
by Celso Providelo
review comments |
216 |
Translation-<lang-code>{'', '.gz', '.bz2'} |
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
217 |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
218 |
We have only used uncompressed files for tests: |
219 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
220 |
>>> dir_list = os.listdir(target_dir) |
221 |
>>> for filename in sorted(dir_list): |
|
222 |
... content = open(os.path.join(target_dir, filename), 'rb').read() |
|
223 |
... print filename, len(content) |
|
224 |
Translation-bn 0 |
|
225 |
Translation-ca 0 |
|
226 |
Translation-en 16 |
|
227 |
Translation-pt_BR 15 |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
228 |
|
3686.1.22
by Celso Providelo
applying review comments |
229 |
** Note that a incomming directory inside the tarball "i18n" directory |
230 |
was skipped by the DDTP processor |
|
231 |
||
232 |
Upload a new DDTP tarball which is supposed to only add a new language |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
233 |
index , the "bn" one, and left the rest untouched, this feature is |
234 |
know as "partial update" and will save some storage when fixing specific |
|
235 |
language indexes or adding new ones: |
|
236 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
237 |
>>> insecure_policy = getPolicy( |
238 |
... name='insecure', distro='ubuntutest', distroseries=None) |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
239 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
240 |
>>> upload = NascentUpload.from_changesfile_path( |
241 |
... datadir('ddtp-tarball/translations-main_20060817_all.changes'), |
|
242 |
... insecure_policy, DevNullLogger()) |
|
243 |
>>> upload.process() |
|
244 |
>>> upload.is_rejected |
|
245 |
False |
|
246 |
>>> success = upload.do_accept() |
|
247 |
>>> success |
|
248 |
True |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
249 |
|
250 |
||
251 |
We need to commit the transaction to be able to use the librarian files. |
|
252 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
253 |
>>> flush_database_updates() |
254 |
>>> transaction.commit() |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
255 |
|
256 |
||
257 |
Our archive uses `dsync` to replace identical files by hard link in |
|
258 |
order to save some space. This feature breaks the tarfile.extract method, |
|
259 |
because it doesn't remove pre-existing files, it simply overwrite them. |
|
260 |
||
3686.1.22
by Celso Providelo
applying review comments |
261 |
Create a hard link to "bn" package file. |
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
262 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
263 |
>>> src = os.path.join(target_dir, 'Translation-ca') |
264 |
>>> dest = os.path.join(target_dir, 'Translation-bn') |
|
265 |
>>> os.remove(dest) |
|
266 |
>>> os.link(src, dest) |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
267 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
268 |
>>> os.path.exists(dest) |
269 |
True |
|
270 |
>>> os.stat(dest).st_nlink |
|
271 |
2 |
|
272 |
>>> os.stat(src).st_nlink |
|
273 |
2 |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
274 |
|
275 |
||
276 |
Retrieve and publish new custom upload: |
|
277 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
278 |
>>> queue_item = breezy_autotest.getQueueItems( |
279 |
... status=PackageUploadStatus.ACCEPTED)[0] |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
280 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
281 |
>>> pub_records = queue_item.realiseUpload() |
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
282 |
|
283 |
||
284 |
Check if there is new content for "bn" index: |
|
285 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
286 |
>>> dir_list = os.listdir(target_dir) |
287 |
>>> for filename in sorted(dir_list): |
|
288 |
... content = open(os.path.join(target_dir, filename), 'rb').read() |
|
289 |
... print filename, len(content) |
|
290 |
Translation-bn 22 |
|
291 |
Translation-ca 0 |
|
292 |
Translation-en 16 |
|
293 |
Translation-pt_BR 15 |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
294 |
|
295 |
||
296 |
Check if the contents of "ca" were not affected by the "bn" contents |
|
3686.1.22
by Celso Providelo
applying review comments |
297 |
(this would happen if "bn" was not removed, left as hard link): |
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
298 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
299 |
>>> open(os.path.join(target_dir, 'Translation-bn')).read() |
300 |
'hardlinks are bad !!!\n' |
|
3686.1.21
by Celso Providelo
Fix problem with python tarfile module and hard links when publishing ddtp-tarball. |
301 |
|
13233.1.1
by Jeroen Vermeulen
Lint. |
302 |
>>> open(os.path.join(target_dir, 'Translation-ca')).read() |
303 |
'' |
|
3686.1.13
by Celso Providelo
Implementing DDTP (Debian Description Translation Project) custom format support in soyuz, as suggested in bug #54795 |
304 |
|
305 |
Remove the directory to keep the test working. |
|
306 |
||
13233.1.1
by Jeroen Vermeulen
Lint. |
307 |
>>> import shutil |
308 |
>>> shutil.rmtree(target_dir) |