8687.15.17
by Karl Fogel
Add the copyright header block to the rest of the files under lib/lp/. |
1 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
3 |
|
4 |
"""Functional tests for publish-distro.py script."""
|
|
5 |
||
6 |
__metaclass__ = type |
|
7 |
||
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
8 |
from optparse import OptionParser |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
9 |
import os |
4781.3.1
by Julian Edwards
Amend cron.daily to properly publish the commercial archive. Also fix |
10 |
import shutil |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
11 |
import subprocess |
12 |
import sys |
|
13 |
import unittest |
|
14 |
||
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
15 |
from zope.component import getUtility |
4781.3.1
by Julian Edwards
Amend cron.daily to properly publish the commercial archive. Also fix |
16 |
from zope.security.proxy import removeSecurityProxy |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
17 |
|
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
18 |
from canonical.config import config |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
19 |
from lp.archivepublisher.config import getPubConfig |
7675.1069.8
by Julian Edwards
fix some unit tests |
20 |
from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet |
7675.110.3
by Curtis Hovey
Ran the migration script to move registry code to lp.registry. |
21 |
from lp.registry.interfaces.distribution import IDistributionSet |
22 |
from lp.registry.interfaces.person import IPersonSet |
|
12070.1.4
by Tim Penhey
Move FakeLogger and BufferLogger to lp.services.log.logging and delete the QuietFakeLogger. |
23 |
from lp.services.log.logger import BufferLogger |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
24 |
from lp.services.scripts.base import LaunchpadScriptFailure |
11411.6.6
by Julian Edwards
move BinaryPackageFormat and BinaryPackageFileType |
25 |
from lp.soyuz.enums import ( |
26 |
ArchivePurpose, |
|
27 |
BinaryPackageFormat, |
|
11411.6.12
by Julian Edwards
Move PackagePublishingStatus/Priority |
28 |
PackagePublishingStatus, |
11411.6.6
by Julian Edwards
move BinaryPackageFormat and BinaryPackageFileType |
29 |
)
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
30 |
from lp.soyuz.interfaces.archive import ( |
31 |
IArchiveSet, |
|
32 |
)
|
|
8294.6.1
by Julian Edwards
First stab at code-reorg. Still got a discrepancy on stuff I assigned to registry but not migrated yet. |
33 |
from lp.soyuz.scripts import publishdistro |
34 |
from lp.soyuz.tests.test_publishing import TestNativePublishingBase |
|
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
35 |
|
7968.3.1
by Celso Providelo
Fixing bug #238851 (reenabling NMAF for Partner archives). |
36 |
|
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
37 |
class TestPublishDistro(TestNativePublishingBase): |
38 |
"""Test the publish-distro.py script works properly."""
|
|
39 |
||
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
40 |
def runPublishDistro(self, extra_args=None, distribution="ubuntutest"): |
41 |
"""Run publish-distro without invoking the script.
|
|
42 |
||
43 |
This method hooks into the publishdistro module to run the
|
|
44 |
publish-distro script without the overhead of using Popen.
|
|
45 |
"""
|
|
46 |
args = ["-d", distribution] |
|
47 |
if extra_args is not None: |
|
48 |
args.extend(extra_args) |
|
49 |
parser = OptionParser() |
|
50 |
publishdistro.add_options(parser) |
|
51 |
options, args = parser.parse_args(args=args) |
|
5596.2.2
by Julian Edwards
Add polish and some tests. |
52 |
self.layer.switchDbUser(config.archivepublisher.dbuser) |
12070.1.4
by Tim Penhey
Move FakeLogger and BufferLogger to lp.services.log.logging and delete the QuietFakeLogger. |
53 |
publishdistro.run_publisher( |
54 |
options, self.layer.txn, log=BufferLogger()) |
|
5596.2.2
by Julian Edwards
Add polish and some tests. |
55 |
self.layer.switchDbUser('launchpad') |
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
56 |
|
57 |
def runPublishDistroScript(self): |
|
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
58 |
"""Run publish-distro.py, returning the result and output."""
|
59 |
script = os.path.join(config.root, "scripts", "publish-distro.py") |
|
60 |
args = [sys.executable, script, "-v", "-d", "ubuntutest"] |
|
61 |
process = subprocess.Popen( |
|
62 |
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
63 |
stdout, stderr = process.communicate() |
|
64 |
return (process.returncode, stdout, stderr) |
|
65 |
||
5188.3.3
by Julian Edwards
Add a bunch more tests. Revert requestDeletion change in previous branch |
66 |
def testPublishDistroRun(self): |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
67 |
"""Try a simple publish-distro run.
|
68 |
||
69 |
Expect database publishing record to be updated to PUBLISHED and
|
|
70 |
the file to be written in disk.
|
|
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
71 |
|
72 |
This method also ensures the publish-distro.py script is runnable.
|
|
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
73 |
"""
|
3686.1.69
by Celso Providelo
reorganize tests for publishing system, make them share the TestNativePublishingBase. |
74 |
pub_source = self.getPubSource(filecontent='foo') |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
75 |
self.layer.txn.commit() |
76 |
||
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
77 |
rc, out, err = self.runPublishDistroScript() |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
78 |
|
5094.2.5
by Francis J. Lacoste
Sync objects to see modified values after transaction commit. |
79 |
pub_source.sync() |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
80 |
self.assertEqual(0, rc, "Publisher failed with:\n%s\n%s" % (out, err)) |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
81 |
self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
82 |
||
7077.1.6
by Celso Providelo
fixing test failures. |
83 |
foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
84 |
self.assertEqual(open(foo_path).read().strip(), 'foo') |
85 |
||
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
86 |
def testDirtyPocketProcessing(self): |
87 |
"""Test dirty pocket processing.
|
|
88 |
||
89 |
Make a DELETED source to see if the dirty pocket processing
|
|
90 |
works for deletions.
|
|
91 |
"""
|
|
92 |
pub_source = self.getPubSource(filecontent='foo') |
|
93 |
self.layer.txn.commit() |
|
94 |
self.runPublishDistro() |
|
95 |
pub_source.sync() |
|
96 |
||
5188.3.3
by Julian Edwards
Add a bunch more tests. Revert requestDeletion change in previous branch |
97 |
random_person = getUtility(IPersonSet).getByName('name16') |
98 |
pub_source.requestDeletion(random_person) |
|
99 |
self.layer.txn.commit() |
|
100 |
self.assertTrue(pub_source.scheduleddeletiondate is None, |
|
101 |
"pub_source.scheduleddeletiondate should not be set, and it is.") |
|
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
102 |
self.runPublishDistro() |
5188.3.3
by Julian Edwards
Add a bunch more tests. Revert requestDeletion change in previous branch |
103 |
pub_source.sync() |
104 |
self.assertTrue(pub_source.scheduleddeletiondate is not None, |
|
105 |
"pub_source.scheduleddeletiondate should be set, and it's not.") |
|
106 |
||
3691.433.2
by Celso Providelo
applying review comments [r=spiv] |
107 |
def assertExists(self, path): |
108 |
"""Assert if the given path exists."""
|
|
109 |
self.assertTrue(os.path.exists(path), "Not Found: '%s'" % path) |
|
110 |
||
111 |
def assertNotExists(self, path): |
|
112 |
"""Assert if the given path does not exist."""
|
|
113 |
self.assertFalse(os.path.exists(path), "Found: '%s'" % path) |
|
114 |
||
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
115 |
def testRunWithSuite(self): |
116 |
"""Try to run publish-distro with restricted suite option.
|
|
117 |
||
118 |
Expect only update and disk writing only in the publishing record
|
|
119 |
targeted to the specified suite, other records should be untouched
|
|
120 |
and not present in disk.
|
|
121 |
"""
|
|
3686.1.69
by Celso Providelo
reorganize tests for publishing system, make them share the TestNativePublishingBase. |
122 |
pub_source = self.getPubSource(filecontent='foo') |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
123 |
pub_source2 = self.getPubSource( |
3686.1.69
by Celso Providelo
reorganize tests for publishing system, make them share the TestNativePublishingBase. |
124 |
sourcename='baz', filecontent='baz', |
4285.2.1
by Mark Shuttleworth
Massive renaming of distrorelease to distroseries |
125 |
distroseries=self.ubuntutest['hoary-test']) |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
126 |
self.layer.txn.commit() |
127 |
||
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
128 |
self.runPublishDistro(['-s', 'hoary-test']) |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
129 |
|
5094.2.5
by Francis J. Lacoste
Sync objects to see modified values after transaction commit. |
130 |
pub_source.sync() |
131 |
pub_source2.sync() |
|
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
132 |
self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING) |
5217.6.12
by Celso Providelo
fixing lint problems. |
133 |
self.assertEqual( |
134 |
pub_source2.status, PackagePublishingStatus.PUBLISHED) |
|
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
135 |
|
7077.1.6
by Celso Providelo
fixing test failures. |
136 |
foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir |
3691.433.2
by Celso Providelo
applying review comments [r=spiv] |
137 |
self.assertNotExists(foo_path) |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
138 |
|
7077.1.6
by Celso Providelo
fixing test failures. |
139 |
baz_path = "%s/main/b/baz/baz_666.dsc" % self.pool_dir |
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
140 |
self.assertEqual('baz', open(baz_path).read().strip()) |
141 |
||
4781.3.3
by Julian Edwards
Apply kiko review comments. |
142 |
def publishToArchiveWithOverriddenDistsroot(self, archive): |
143 |
"""Publish a test package to the specified archive.
|
|
144 |
||
145 |
Publishes a test package but overrides the distsroot.
|
|
146 |
:return: A tuple of the path to the overridden distsroot and the
|
|
147 |
configured distsroot, in that order.
|
|
148 |
"""
|
|
149 |
self.getPubSource(filecontent="flangetrousers", archive=archive) |
|
150 |
self.layer.txn.commit() |
|
8255.13.1
by Julian Edwards
Move IArchive.getPubConfig() to archivepublisher. |
151 |
pubconf = getPubConfig(archive) |
10459.3.1
by Steve Kowalik
Change testReplaceUpdatedHtpasswd, testDistsrootOverridePartnerArchive to use the same base device to avoid failures when /tmp and /var are on seperate devices. |
152 |
tmp_path = os.path.join(pubconf.archiveroot, "tmpdistroot") |
4781.3.3
by Julian Edwards
Apply kiko review comments. |
153 |
if os.path.exists(tmp_path): |
154 |
shutil.rmtree(tmp_path) |
|
10459.3.1
by Steve Kowalik
Change testReplaceUpdatedHtpasswd, testDistsrootOverridePartnerArchive to use the same base device to avoid failures when /tmp and /var are on seperate devices. |
155 |
os.makedirs(tmp_path) |
5283.2.1
by Julian Edwards
Make publishing of the partner archive as atomic as possible rather than |
156 |
myargs = ['-R', tmp_path] |
157 |
if archive.purpose == ArchivePurpose.PARTNER: |
|
158 |
myargs.append('--partner') |
|
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
159 |
self.runPublishDistro(myargs) |
4781.3.3
by Julian Edwards
Apply kiko review comments. |
160 |
return tmp_path, pubconf.distsroot |
161 |
||
4781.3.1
by Julian Edwards
Amend cron.daily to properly publish the commercial archive. Also fix |
162 |
def testDistsrootOverridePrimaryArchive(self): |
163 |
"""Test the -R option to publish-distro.
|
|
164 |
||
165 |
Make sure that -R works with the primary archive.
|
|
166 |
"""
|
|
167 |
main_archive = getUtility(IDistributionSet)['ubuntutest'].main_archive |
|
4781.3.3
by Julian Edwards
Apply kiko review comments. |
168 |
tmp_path, distsroot = self.publishToArchiveWithOverriddenDistsroot( |
169 |
main_archive) |
|
4781.3.1
by Julian Edwards
Amend cron.daily to properly publish the commercial archive. Also fix |
170 |
distroseries = 'breezy-autotest' |
171 |
self.assertExists(os.path.join(tmp_path, distroseries, 'Release')) |
|
172 |
self.assertNotExists( |
|
4781.3.3
by Julian Edwards
Apply kiko review comments. |
173 |
os.path.join("%s" % distsroot, distroseries, 'Release')) |
4781.3.1
by Julian Edwards
Amend cron.daily to properly publish the commercial archive. Also fix |
174 |
shutil.rmtree(tmp_path) |
175 |
||
5283.2.1
by Julian Edwards
Make publishing of the partner archive as atomic as possible rather than |
176 |
def testDistsrootOverridePartnerArchive(self): |
4781.3.1
by Julian Edwards
Amend cron.daily to properly publish the commercial archive. Also fix |
177 |
"""Test the -R option to publish-distro.
|
178 |
||
5283.2.1
by Julian Edwards
Make publishing of the partner archive as atomic as possible rather than |
179 |
Make sure the -R option affects the partner archive.
|
4781.3.1
by Julian Edwards
Amend cron.daily to properly publish the commercial archive. Also fix |
180 |
"""
|
181 |
ubuntu = getUtility(IDistributionSet)['ubuntutest'] |
|
4810.9.8
by Julian Edwards
Merge the commercial-release-pocket-upload branch and rename some more |
182 |
partner_archive = ubuntu.getArchiveByComponent('partner') |
4781.3.3
by Julian Edwards
Apply kiko review comments. |
183 |
tmp_path, distsroot = self.publishToArchiveWithOverriddenDistsroot( |
4810.9.8
by Julian Edwards
Merge the commercial-release-pocket-upload branch and rename some more |
184 |
partner_archive) |
4781.3.1
by Julian Edwards
Amend cron.daily to properly publish the commercial archive. Also fix |
185 |
distroseries = 'breezy-autotest' |
5283.2.1
by Julian Edwards
Make publishing of the partner archive as atomic as possible rather than |
186 |
self.assertExists(os.path.join(tmp_path, distroseries, 'Release')) |
187 |
self.assertNotExists( |
|
4781.3.3
by Julian Edwards
Apply kiko review comments. |
188 |
os.path.join("%s" % distsroot, distroseries, 'Release')) |
4781.3.1
by Julian Edwards
Amend cron.daily to properly publish the commercial archive. Also fix |
189 |
shutil.rmtree(tmp_path) |
190 |
||
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
191 |
def testForPPA(self): |
192 |
"""Try to run publish-distro in PPA mode.
|
|
193 |
||
194 |
It should deal only with PPA publications.
|
|
195 |
"""
|
|
196 |
pub_source = self.getPubSource(filecontent='foo') |
|
197 |
||
3691.443.50
by Celso Providelo
Fix #88611 (only one PPA per user) and simpler upload/publish paths for PPA. |
198 |
cprov = getUtility(IPersonSet).getByName('cprov') |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
199 |
pub_source2 = self.getPubSource( |
3691.443.50
by Celso Providelo
Fix #88611 (only one PPA per user) and simpler upload/publish paths for PPA. |
200 |
sourcename='baz', filecontent='baz', archive=cprov.archive) |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
201 |
|
4376.2.30
by Julian Edwards
Tweak publishing and add support for building of commercial packages. |
202 |
ubuntutest = getUtility(IDistributionSet)['ubuntutest'] |
3691.443.50
by Celso Providelo
Fix #88611 (only one PPA per user) and simpler upload/publish paths for PPA. |
203 |
name16 = getUtility(IPersonSet).getByName('name16') |
11382.6.14
by Gavin Panella
It is no longer necessary to remove security proxies everywhere now that adaption to IPropertyCache will remove security proxies. |
204 |
getUtility(IArchiveSet).new(purpose=ArchivePurpose.PPA, owner=name16, |
4376.2.30
by Julian Edwards
Tweak publishing and add support for building of commercial packages. |
205 |
distribution=ubuntutest) |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
206 |
pub_source3 = self.getPubSource( |
3691.443.50
by Celso Providelo
Fix #88611 (only one PPA per user) and simpler upload/publish paths for PPA. |
207 |
sourcename='bar', filecontent='bar', archive=name16.archive) |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
208 |
|
4285.3.42
by Celso Providelo
moving PPA handlers to IDistribution, improving IArchive tests, using IArchive.distribution in Publisher System, verifying Archive.distribution in upload time. *some* tests missing (tm). |
209 |
# Override PPAs distributions
|
210 |
naked_archive = removeSecurityProxy(cprov.archive) |
|
211 |
naked_archive.distribution = self.ubuntutest |
|
212 |
naked_archive = removeSecurityProxy(name16.archive) |
|
213 |
naked_archive.distribution = self.ubuntutest |
|
214 |
||
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
215 |
self.layer.txn.commit() |
216 |
||
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
217 |
self.runPublishDistro(['--ppa']) |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
218 |
|
5094.2.5
by Francis J. Lacoste
Sync objects to see modified values after transaction commit. |
219 |
pub_source.sync() |
220 |
pub_source2.sync() |
|
221 |
pub_source3.sync() |
|
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
222 |
self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING) |
5217.6.12
by Celso Providelo
fixing lint problems. |
223 |
self.assertEqual( |
224 |
pub_source2.status, PackagePublishingStatus.PUBLISHED) |
|
225 |
self.assertEqual( |
|
226 |
pub_source3.status, PackagePublishingStatus.PUBLISHED) |
|
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
227 |
|
7077.1.6
by Celso Providelo
fixing test failures. |
228 |
foo_path = "%s/main/f/foo/foo_666.dsc" % self.pool_dir |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
229 |
self.assertEqual(False, os.path.exists(foo_path)) |
230 |
||
231 |
baz_path = os.path.join( |
|
3691.443.50
by Celso Providelo
Fix #88611 (only one PPA per user) and simpler upload/publish paths for PPA. |
232 |
config.personalpackagearchive.root, cprov.name, |
7592.1.1
by Celso Providelo
fixing test failures caused by archive-lookup-fixing vs multi-ppa branches. |
233 |
'ppa/ubuntutest/pool/main/b/baz/baz_666.dsc') |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
234 |
self.assertEqual('baz', open(baz_path).read().strip()) |
235 |
||
236 |
bar_path = os.path.join( |
|
3691.443.50
by Celso Providelo
Fix #88611 (only one PPA per user) and simpler upload/publish paths for PPA. |
237 |
config.personalpackagearchive.root, name16.name, |
7592.1.1
by Celso Providelo
fixing test failures caused by archive-lookup-fixing vs multi-ppa branches. |
238 |
'ppa/ubuntutest/pool/main/b/bar/bar_666.dsc') |
3691.443.43
by Celso Providelo
extend p-d script with PPA-mode and remove bogus publish-ppa. |
239 |
self.assertEqual('bar', open(bar_path).read().strip()) |
240 |
||
5596.2.2
by Julian Edwards
Add polish and some tests. |
241 |
def testForPrivatePPA(self): |
242 |
"""Run publish-distro in private PPA mode.
|
|
243 |
||
244 |
It should only publish private PPAs.
|
|
245 |
"""
|
|
10316.1.16
by Michael Nelson
Fixed test for private PPA. |
246 |
# First, we'll make a private PPA and populate it with a
|
247 |
# publishing record.
|
|
5596.2.2
by Julian Edwards
Add polish and some tests. |
248 |
ubuntutest = getUtility(IDistributionSet)['ubuntutest'] |
10316.1.16
by Michael Nelson
Fixed test for private PPA. |
249 |
private_ppa = self.factory.makeArchive( |
250 |
private=True, distribution=ubuntutest) |
|
5596.2.2
by Julian Edwards
Add polish and some tests. |
251 |
|
10316.1.16
by Michael Nelson
Fixed test for private PPA. |
252 |
# Publish something to the private PPA:
|
5596.2.2
by Julian Edwards
Add polish and some tests. |
253 |
pub_source = self.getPubSource( |
10316.1.16
by Michael Nelson
Fixed test for private PPA. |
254 |
sourcename='baz', filecontent='baz', archive=private_ppa) |
5596.2.2
by Julian Edwards
Add polish and some tests. |
255 |
self.layer.txn.commit() |
256 |
||
5596.2.3
by Julian Edwards
Some extra polishing. Catch NotFoundError and turn it into a |
257 |
# Try a plain PPA run, to ensure the private one is NOT published.
|
5596.2.2
by Julian Edwards
Add polish and some tests. |
258 |
self.runPublishDistro(['--ppa']) |
259 |
||
260 |
pub_source.sync() |
|
261 |
self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING) |
|
262 |
||
263 |
# Now publish the private PPAs and make sure they are really
|
|
264 |
# published.
|
|
265 |
self.runPublishDistro(['--private-ppa']) |
|
266 |
||
267 |
pub_source.sync() |
|
268 |
self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
|
269 |
||
8383.2.2
by Celso Providelo
Publishing DEBUG archive and its DDEBS. |
270 |
def testPublishPrimaryDebug(self): |
271 |
# 'ubuntutest' (default testing distribution) has no DEBUG
|
|
272 |
# archive, Thus an error is raised.
|
|
273 |
self.assertRaises( |
|
274 |
LaunchpadScriptFailure, |
|
275 |
self.runPublishDistro, ['--primary-debug']) |
|
276 |
||
277 |
# The DEBUG repository path was not created.
|
|
7675.1069.8
by Julian Edwards
fix some unit tests |
278 |
ubuntutest = getUtility(IDistributionSet)['ubuntutest'] |
279 |
root_dir = getUtility( |
|
280 |
IPublisherConfigSet).getByDistribution(ubuntutest).root_dir |
|
8383.2.2
by Celso Providelo
Publishing DEBUG archive and its DDEBS. |
281 |
repo_path = os.path.join( |
7675.1069.8
by Julian Edwards
fix some unit tests |
282 |
root_dir, 'ubuntutest-debug') |
8383.2.2
by Celso Providelo
Publishing DEBUG archive and its DDEBS. |
283 |
self.assertNotExists(repo_path) |
284 |
||
285 |
# We will create the DEBUG archive for ubuntutest, so it can
|
|
286 |
# be published.
|
|
287 |
debug_archive = getUtility(IArchiveSet).new( |
|
288 |
purpose=ArchivePurpose.DEBUG, owner=ubuntutest.owner, |
|
289 |
distribution=ubuntutest) |
|
290 |
||
291 |
# We will also create a source & binary pair of pending
|
|
292 |
# publications. Only the DDEB (binary) will be moved to
|
|
293 |
# the DEBUG archive, exactly as it would happen in normal
|
|
294 |
# operation, see nascentupload-ddebs.txt.
|
|
295 |
self.prepareBreezyAutotest() |
|
296 |
pub_binaries = self.getPubBinaries(format=BinaryPackageFormat.DDEB) |
|
297 |
for binary in pub_binaries: |
|
7659.7.5
by Julian Edwards
Fix lots of broken stuff |
298 |
binary.archive = debug_archive |
8383.2.2
by Celso Providelo
Publishing DEBUG archive and its DDEBS. |
299 |
|
300 |
# Commit setup changes, so the script can operate on them.
|
|
301 |
self.layer.txn.commit() |
|
302 |
||
303 |
# After publication, the DDEB is published and indexed.
|
|
304 |
self.runPublishDistro(['--primary-debug']) |
|
305 |
||
306 |
debug_pool_path = os.path.join(repo_path, 'pool/main/f/foo') |
|
307 |
self.assertEqual( |
|
308 |
os.listdir(debug_pool_path), ['foo-bin_666_all.ddeb']) |
|
309 |
||
310 |
debug_index_path = os.path.join( |
|
311 |
repo_path, 'dists/breezy-autotest/main/binary-i386/Packages') |
|
312 |
self.assertEqual( |
|
313 |
open(debug_index_path).readlines()[0], 'Package: foo-bin\n') |
|
314 |
||
10373.1.2
by Julian Edwards
change the script so that --copy-archive doesn't need a named archive, we will just publish any that are marked with publish=True |
315 |
def testPublishCopyArchive(self): |
316 |
"""Run publish-distro in copy archive mode.
|
|
317 |
||
318 |
It should only publish copy archives.
|
|
319 |
"""
|
|
320 |
ubuntutest = getUtility(IDistributionSet)['ubuntutest'] |
|
321 |
cprov = getUtility(IPersonSet).getByName('cprov') |
|
322 |
copy_archive_name = 'test-copy-publish' |
|
10373.1.4
by Julian Edwards
Fix tests |
323 |
|
324 |
# The COPY repository path is not created yet.
|
|
7675.1069.8
by Julian Edwards
fix some unit tests |
325 |
root_dir = getUtility( |
326 |
IPublisherConfigSet).getByDistribution(ubuntutest).root_dir |
|
10373.1.4
by Julian Edwards
Fix tests |
327 |
repo_path = os.path.join( |
7675.1069.8
by Julian Edwards
fix some unit tests |
328 |
root_dir, |
10391.1.2
by Julian Edwards
fix the testPublishCopyArchive test |
329 |
ubuntutest.name + '-' + copy_archive_name, |
330 |
ubuntutest.name) |
|
10373.1.4
by Julian Edwards
Fix tests |
331 |
self.assertNotExists(repo_path) |
332 |
||
10373.1.2
by Julian Edwards
change the script so that --copy-archive doesn't need a named archive, we will just publish any that are marked with publish=True |
333 |
copy_archive = getUtility(IArchiveSet).new( |
334 |
distribution=ubuntutest, owner=cprov, name=copy_archive_name, |
|
335 |
purpose=ArchivePurpose.COPY, enabled=True) |
|
10373.1.4
by Julian Edwards
Fix tests |
336 |
# Save some test CPU cycles by avoiding logging in as the user
|
337 |
# necessary to alter the publish flag.
|
|
338 |
removeSecurityProxy(copy_archive).publish = True |
|
10373.1.2
by Julian Edwards
change the script so that --copy-archive doesn't need a named archive, we will just publish any that are marked with publish=True |
339 |
|
340 |
# Publish something.
|
|
341 |
pub_source = self.getPubSource( |
|
342 |
sourcename='baz', filecontent='baz', archive=copy_archive) |
|
343 |
||
344 |
# Try a plain PPA run, to ensure the copy archive is not published.
|
|
345 |
self.runPublishDistro(['--ppa']) |
|
346 |
||
347 |
self.assertEqual(pub_source.status, PackagePublishingStatus.PENDING) |
|
348 |
||
10373.1.4
by Julian Edwards
Fix tests |
349 |
# Now publish the copy archives and make sure they are really
|
10373.1.2
by Julian Edwards
change the script so that --copy-archive doesn't need a named archive, we will just publish any that are marked with publish=True |
350 |
# published.
|
10373.1.4
by Julian Edwards
Fix tests |
351 |
self.runPublishDistro(['--copy-archive']) |
10373.1.2
by Julian Edwards
change the script so that --copy-archive doesn't need a named archive, we will just publish any that are marked with publish=True |
352 |
|
353 |
self.assertEqual(pub_source.status, PackagePublishingStatus.PUBLISHED) |
|
354 |
||
10373.1.4
by Julian Edwards
Fix tests |
355 |
# Make sure that the files were published in the right place.
|
356 |
pool_path = os.path.join(repo_path, 'pool/main/b/baz/baz_666.dsc') |
|
357 |
self.assertExists(pool_path) |
|
358 |
||
3691.433.1
by Celso Providelo
Fix #83548 (extend 'careful_apt' option associated with 'allowed_suite' to enable publish-distro to write/update index and release files for empty suites). |
359 |
def testRunWithEmptySuites(self): |
360 |
"""Try a publish-distro run on empty suites in careful_apt mode
|
|
361 |
||
362 |
Expect it to create all indexes, including current 'Release' file
|
|
363 |
for the empty suites specified.
|
|
364 |
"""
|
|
5596.2.1
by Julian Edwards
Make test_publishdistro quicker. Also add --private-ppa option to publish-distro.py |
365 |
self.runPublishDistro( |
3691.433.1
by Celso Providelo
Fix #83548 (extend 'careful_apt' option associated with 'allowed_suite' to enable publish-distro to write/update index and release files for empty suites). |
366 |
['-A', '-s', 'hoary-test-updates', '-s', 'hoary-test-backports']) |
367 |
||
368 |
# Check "Release" files
|
|
369 |
release_path = "%s/hoary-test-updates/Release" % self.config.distsroot |
|
3691.433.2
by Celso Providelo
applying review comments [r=spiv] |
370 |
self.assertExists(release_path) |
3691.433.1
by Celso Providelo
Fix #83548 (extend 'careful_apt' option associated with 'allowed_suite' to enable publish-distro to write/update index and release files for empty suites). |
371 |
|
5217.6.12
by Celso Providelo
fixing lint problems. |
372 |
release_path = ( |
373 |
"%s/hoary-test-backports/Release" % self.config.distsroot) |
|
3691.433.2
by Celso Providelo
applying review comments [r=spiv] |
374 |
self.assertExists(release_path) |
3691.433.1
by Celso Providelo
Fix #83548 (extend 'careful_apt' option associated with 'allowed_suite' to enable publish-distro to write/update index and release files for empty suites). |
375 |
|
376 |
release_path = "%s/hoary-test/Release" % self.config.distsroot |
|
3691.433.2
by Celso Providelo
applying review comments [r=spiv] |
377 |
self.assertNotExists(release_path) |
3691.433.1
by Celso Providelo
Fix #83548 (extend 'careful_apt' option associated with 'allowed_suite' to enable publish-distro to write/update index and release files for empty suites). |
378 |
|
379 |
# Check some index files
|
|
380 |
index_path = ( |
|
381 |
"%s/hoary-test-updates/main/binary-i386/Packages" |
|
382 |
% self.config.distsroot) |
|
3691.433.2
by Celso Providelo
applying review comments [r=spiv] |
383 |
self.assertExists(index_path) |
3691.433.1
by Celso Providelo
Fix #83548 (extend 'careful_apt' option associated with 'allowed_suite' to enable publish-distro to write/update index and release files for empty suites). |
384 |
|
385 |
index_path = ( |
|
386 |
"%s/hoary-test-backports/main/binary-i386/Packages" |
|
387 |
% self.config.distsroot) |
|
3691.433.2
by Celso Providelo
applying review comments [r=spiv] |
388 |
self.assertExists(index_path) |
3691.433.1
by Celso Providelo
Fix #83548 (extend 'careful_apt' option associated with 'allowed_suite' to enable publish-distro to write/update index and release files for empty suites). |
389 |
|
390 |
index_path = ( |
|
391 |
"%s/hoary-test/main/binary-i386/Packages" % self.config.distsroot) |
|
3691.433.2
by Celso Providelo
applying review comments [r=spiv] |
392 |
self.assertNotExists(index_path) |
3691.433.1
by Celso Providelo
Fix #83548 (extend 'careful_apt' option associated with 'allowed_suite' to enable publish-distro to write/update index and release files for empty suites). |
393 |
|
5596.2.2
by Julian Edwards
Add polish and some tests. |
394 |
def testExclusiveOptions(self): |
395 |
"""Test that some command line options are mutually exclusive."""
|
|
396 |
self.assertRaises( |
|
397 |
LaunchpadScriptFailure, |
|
10373.1.1
by Julian Edwards
basic first changes, and option exclusivity test |
398 |
self.runPublishDistro, |
10373.1.3
by Julian Edwards
fix exclusive options tests |
399 |
['--ppa', '--partner', '--primary-debug', '--copy-archive']) |
8383.2.2
by Celso Providelo
Publishing DEBUG archive and its DDEBS. |
400 |
self.assertRaises( |
401 |
LaunchpadScriptFailure, |
|
5596.2.2
by Julian Edwards
Add polish and some tests. |
402 |
self.runPublishDistro, ['--ppa', '--partner']) |
403 |
self.assertRaises( |
|
404 |
LaunchpadScriptFailure, |
|
405 |
self.runPublishDistro, ['--ppa', '--private-ppa']) |
|
406 |
self.assertRaises( |
|
407 |
LaunchpadScriptFailure, |
|
8383.2.2
by Celso Providelo
Publishing DEBUG archive and its DDEBS. |
408 |
self.runPublishDistro, ['--ppa', '--primary-debug']) |
409 |
self.assertRaises( |
|
410 |
LaunchpadScriptFailure, |
|
10373.1.3
by Julian Edwards
fix exclusive options tests |
411 |
self.runPublishDistro, ['--ppa', '--copy-archive']) |
10373.1.1
by Julian Edwards
basic first changes, and option exclusivity test |
412 |
self.assertRaises( |
413 |
LaunchpadScriptFailure, |
|
5596.2.2
by Julian Edwards
Add polish and some tests. |
414 |
self.runPublishDistro, ['--partner', '--private-ppa']) |
8383.2.2
by Celso Providelo
Publishing DEBUG archive and its DDEBS. |
415 |
self.assertRaises( |
416 |
LaunchpadScriptFailure, |
|
417 |
self.runPublishDistro, ['--partner', '--primary-debug']) |
|
10373.1.1
by Julian Edwards
basic first changes, and option exclusivity test |
418 |
self.assertRaises( |
419 |
LaunchpadScriptFailure, |
|
10373.1.3
by Julian Edwards
fix exclusive options tests |
420 |
self.runPublishDistro, ['--partner', '--copy-archive']) |
10373.1.1
by Julian Edwards
basic first changes, and option exclusivity test |
421 |
self.assertRaises( |
422 |
LaunchpadScriptFailure, |
|
10373.1.3
by Julian Edwards
fix exclusive options tests |
423 |
self.runPublishDistro, ['--primary-debug', '--copy-archive']) |
5596.2.2
by Julian Edwards
Add polish and some tests. |
424 |
|
3496.1.113
by Celso Providelo
Add the ability to specify a single target suite in publish-distro script. |
425 |
|
426 |
def test_suite(): |
|
427 |
return unittest.TestLoader().loadTestsFromName(__name__) |