~launchpad-pqm/launchpad/devel

3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
1
= Debian Installer Custom Uploads =
2
3
Debian Installer uploads are treated as one of the Soyuz "custom"
4
types.
5
6
They come from buildd as result of the 'debian-installer' source
7
build. This binary upload usually contains:
8
9
 * The debian-installer binaries (DEB)
10
 * The debian-installer translation (TAR.GZ, custom ROSETTA_TRANSLATIONS)
11
 * The debian-installer special archive files (TAR.GZ, custom DEBIAN_INSTALLER)
12
13
We have a special processor to publish debian-installer special archive
14
file contents.
15
16
The debian-installer filename should be something like:
17
18
<BASE>_<VERSION>_<ARCH>.tar.gz
19
20
Where:
21
22
 * BASE: base name (usually 'debian-installer-images')
23
24
 * VERSION: encoded version (something like '20061102ubuntu14')
25
   * if the version string contains '.0.' we assume it is a
26
     'daily-installer', otherwise, it is a normal 'installer'
27
28
 * ARCH: targeted architecture tag ('i386', 'amd64', etc)
29
30
The contents are extracted in the archive, respecting its type
31
('installer' or 'daily-installer'), in the following path:
32
33
 * <ARCHIVE>/dists/<SUITE>/main/<TYPE>-<ARCH>/
34
35
36
Let's try one test upload and verify the results of its publication.
37
In order to keep the tests simple we will upload only the
38
debian-installer tarball, despite the fact that it's very unlikely to
39
happen in production:
40
14455.2.4 by William Grant
Drop imports from canonical.launchpad.ftests.
41
  >>> from lp.testing.gpgkeys import import_public_test_keys
3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
42
  >>> import_public_test_keys()
43
  >>> login('foo.bar@canonical.com')
44
11692.6.2 by Curtis Hovey
Use deglober to fixing simple glob imports in doctests.
45
  >>> from lp.registry.interfaces.distribution import IDistributionSet
3691.443.60 by Celso Providelo
merge from RF, bunch of conflicts fixed. storing upload_archive in the policy.
46
  >>> ubuntutest = getUtility(IDistributionSet)['ubuntutest']
47
8426.7.2 by Julian Edwards
migrate archiveuploader to the lp tree.
48
  >>> from lp.archiveuploader.nascentupload import NascentUpload
12070.1.37 by Tim Penhey
Remove mock_logger and mock_logger_quiet.
49
  >>> from lp.archiveuploader.tests import datadir, getPolicy
3804.1.24 by Celso Providelo
fix doc/distroreleasequeue* tests.
50
51
  >>> anything_policy = getPolicy(
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
52
  ...     name='anything', distro='ubuntutest', distroseries=None)
53
  >>> anything_policy.setDistroSeriesAndPocket('hoary-test')
3804.1.24 by Celso Providelo
fix doc/distroreleasequeue* tests.
54
4204.2.11 by Julian Edwards
Last few tests are fixed. This branch is Good To Go (tm).
55
Set the email address for annoucements emails:
56
4285.2.10 by Mark Shuttleworth
Merge RF
57
  >>> anything_policy.distroseries.changeslist = 'announce@example.com'
4204.2.11 by Julian Edwards
Last few tests are fixed. This branch is Good To Go (tm).
58
12070.1.37 by Tim Penhey
Remove mock_logger and mock_logger_quiet.
59
  >>> from lp.services.log.logger import DevNullLogger
11204.5.14 by William Grant
Remove conditional from NascentUpload.__init__. NU.from_changesfile_path should now be used if the ChangesFile must be created too.
60
  >>> upload = NascentUpload.from_changesfile_path(
3804.1.24 by Celso Providelo
fix doc/distroreleasequeue* tests.
61
  ...     datadir(
62
  ...       'debian-installer/debian-installer_20070214ubuntu1_i386.changes'),
12070.1.37 by Tim Penhey
Remove mock_logger and mock_logger_quiet.
63
  ...     anything_policy, DevNullLogger())
3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
64
  >>> upload.process()
4204.2.11 by Julian Edwards
Last few tests are fixed. This branch is Good To Go (tm).
65
  >>> success = upload.do_accept()
3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
66
  >>> success
67
  True
68
69
Upload was successfully 'processed' and 'accepted'. Two email messages
70
were generated (acceptance and announcement). Inspect the queue (IDRQ)
71
information we find out that it contains one custom upload.
72
73
  >>> upload.queue_root.status.name
74
  'ACCEPTED'
4204.2.11 by Julian Edwards
Last few tests are fixed. This branch is Good To Go (tm).
75
76
Make librarian files available for publication:
77
78
  >>> import transaction
79
  >>> transaction.commit()
80
8377.6.17 by Tim Penhey
Move the doctest and fix stub imports.
81
  >>> from lp.services.mail import stub
4204.2.11 by Julian Edwards
Last few tests are fixed. This branch is Good To Go (tm).
82
  >>> len(stub.test_emails)
3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
83
  2
84
  >>> upload.queue_root.customfiles.count()
85
  1
86
3838.1.13 by Celso Providelo
improving custom upload processor tests.
87
Let's force an error simulating a conflict in archive:
3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
88
89
  >>> import os
90
  >>> archive_path = "/var/tmp/archive/"
91
  >>> installer_path = os.path.join(
92
  ...     archive_path, "ubuntutest/dists/hoary-test/main/installer-i386")
93
3838.1.13 by Celso Providelo
improving custom upload processor tests.
94
  >>> os.makedirs(os.path.join(installer_path, '20070214ubuntu1'))
95
96
Try to publish the custom upload, but it will be skipped due the disk
97
conflict and the queue item will remain in ACCEPTED
98
12070.1.37 by Tim Penhey
Remove mock_logger and mock_logger_quiet.
99
  >>> from lp.services.log.logger import FakeLogger
12070.1.39 by Tim Penhey
Updating tests for unified log output.
100
  >>> pub_records = upload.queue_root.realiseUpload(FakeLogger())
12070.1.41 by Tim Penhey
Changed my mind about the colon. Removed it.
101
  DEBUG Publishing custom debian-installer-images_20070214ubuntu1_i386.tar.gz to ubuntutest/hoary-test
102
  ERROR Queue item ignored: installer build i386 for architecture 20070214ubuntu1 already exists
3838.1.13 by Celso Providelo
improving custom upload processor tests.
103
  >>> upload.queue_root.status.name
104
  'ACCEPTED'
105
106
Let's remove the conflicted directory from disk and expect it to work
107
next time:
108
109
  >>> os.rmdir(os.path.join(installer_path, '20070214ubuntu1'))
110
4092.2.18 by Barry Warsaw
Respond to spiv's review:
111
The upload task requires that the umask be 022, otherwise things will end up
112
with the wrong permission.
113
114
  >>> old_mask = os.umask(002)
12070.1.40 by Tim Penhey
More updates.
115
  >>> pub_records = upload.queue_root.realiseUpload(FakeLogger())
12070.1.41 by Tim Penhey
Changed my mind about the colon. Removed it.
116
  DEBUG ...
117
  ERROR Queue item ignored: Bad umask; expected 022, got 002
4092.2.18 by Barry Warsaw
Respond to spiv's review:
118
119
Reset the umask, remove any residual directories, and try again.
120
4092.2.19 by Barry Warsaw
Because these tests also do custom uploads, they need to ensure the umask is
121
  >>> os.rmdir(os.path.join(installer_path, '20070214ubuntu1'))
4092.2.18 by Barry Warsaw
Respond to spiv's review:
122
  >>> print '%03o' % os.umask(old_mask)
123
  002
124
3838.1.13 by Celso Providelo
improving custom upload processor tests.
125
Process (publish) the custom upload:
126
12070.1.37 by Tim Penhey
Remove mock_logger and mock_logger_quiet.
127
  >>> pub_records = upload.queue_root.realiseUpload(DevNullLogger())
3838.1.13 by Celso Providelo
improving custom upload processor tests.
128
  >>> upload.queue_root.status.name
129
  'DONE'
3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
130
131
The current debian-installer directory (20070214ubuntu1) and a link to
132
the last version (we only have the one we uploaded) should be
133
presented:
134
4195.1.4 by Brad Crittenden
Corrected test to sort results of os.listdir as ordering is indeterminate
135
  >>> sorted(os.listdir(installer_path))
3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
136
  ['20070214ubuntu1', 'current']
137
138
As a consistency check, let's verify one of the files inside the
139
tarball:
140
141
  >>> the_file = ("current/images/netboot/ubuntu-installer/i386/"
3838.1.13 by Celso Providelo
improving custom upload processor tests.
142
  ...             "pxelinux.cfg.serial-9600/default")
3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
143
  >>> the_file_path = os.path.join(installer_path, the_file)
144
  >>> print open(the_file_path).read()
145
  hey
146
3838.1.13 by Celso Providelo
improving custom upload processor tests.
147
Also check if the symbolic link included in the installer tarball
148
looks sane:
149
150
  >>> the_link = "current/images/netboot/foo"
151
  >>> the_link_path = os.path.join(installer_path, the_link)
152
  >>> os.readlink(the_link_path)
153
  'ubuntu-installer/i386/pxelinux.cfg.serial-9600/default'
154
3691.274.29 by Celso Providelo
Re-fixing #78672 (entries in custom upload tarballs with long names don't get extracted) reproduced the problem in out test suite, symbolic links to directories do not get installed because of an unusual combination of os.walk() with implict makedirs() when installing files. We are doing better now.
155
  >>> the_dir_link = "current/images/netboot/link_to_dir"
156
  >>> the_dir_link_path = os.path.join(installer_path, the_dir_link)
157
  >>> os.readlink(the_dir_link_path)
158
  'ubuntu-installer/i386/pxelinux.cfg.serial-9600/'
159
4115.1.1 by Celso Providelo
Fix #107068 (os.makedirs is creating world-writable directories in archive). Now we simply force '0755' despite of the local environment umask.
160
Check permissions on the created directories to satisfy the
161
publication path. They are created with os.makedirs() and forced to
162
set permission '0755' instead of the default '0777' (see further
163
details in bug #107068):
164
165
  >>> oct(os.stat(installer_path).st_mode & 0777)
166
  '0755'
167
168
  >>> the_path = os.path.join(installer_path, os.pardir)
169
  >>> oct(os.stat(the_path).st_mode & 0777)
170
  '0755'
171
3691.274.29 by Celso Providelo
Re-fixing #78672 (entries in custom upload tarballs with long names don't get extracted) reproduced the problem in out test suite, symbolic links to directories do not get installed because of an unusual combination of os.walk() with implict makedirs() when installing files. We are doing better now.
172
Check permissions of created files and directories:
173
174
  >>> the_file = ("current/images/netboot/ubuntu-installer/i386/"
175
  ...             "pxelinux.cfg.serial-9600/default")
176
  >>> the_file_path = os.path.join(installer_path, the_file)
177
  >>> oct(os.stat(the_file_path).st_mode & 0777)
178
  '0644'
179
180
  >>> the_dir = ("current/images/netboot/ubuntu-installer/i386/"
181
  ...            "pxelinux.cfg.serial-9600/")
182
  >>> the_dir_path = os.path.join(installer_path, the_dir)
183
  >>> oct(os.stat(the_dir_path).st_mode & 0777)
184
  '0755'
185
3838.1.13 by Celso Providelo
improving custom upload processor tests.
186
187
Remove local archive contents:
188
3811.4.1 by Celso Providelo
Fixing #78672 (entries in custom upload tarballs with long names don't get extracted). It basically applied the suggested patch and added a specific doctest to certify debian-installer is still working as expected. I couldn't reproduce the 'long path name' problem with small tests tarballs, but it does exist in huge/real tarballs used in production. The bug might also be related with the size of the files, not only 'pathname > 100 chars'. Anyway, the suggested workaround DTRT.
189
  >>> import shutil
190
  >>> shutil.rmtree(archive_path)