~free.ekanayaka/landscape-client/lucid-1.4.4-0ubuntu0.10.04

« back to all changes in this revision

Viewing changes to landscape/package/tests/helpers.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2009-12-16 10:50:05 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20091216105005-svplwdorkgz6vja7
Tags: 1.4.0-0ubuntu0.10.04.0
* New upstream release with several bug fixes:
  - Fix landscape daemons fail to start when too many groups are
    available (LP: #456124)
  - Fix landscape programs wake up far too much. (LP: #340843)
  - Fix Package manager fails with 'no such table: task' (LP #465846)
  - Fix test suite leaving temporary files around (LP #476418)
  - Fix the 1hr long wait for user data to be uploaded following a
    resynchronisation (LP #369000)

* Add support for Ubuntu release upgrades:
  - Add helper function to fetch many files at once (LP: #450629)
  - Handle release-upgrade messages in the packagemanager
    plugin (LP: #455217)
  - Add a release-upgrader task handler (LP: #462543)
  - Support upgrade-tool environment variables (LP: #463321)

* Add initial support for Smart package locking:
  - Detect and report changes about Smart package locks (#488108)

* Packaging fixes:
  - Turn unnecessary Pre-Depends on python-gobject into a regular Depends
  - If it's empty, remove /etc/landscape upon purge

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
class SmartHelper(object):
8
8
 
9
9
    def set_up(self, test_case):
10
 
        test_case.smart_dir = test_case.make_dir()
11
 
        test_case.repository_dir = test_case.make_dir()
12
 
        create_repository(test_case.repository_dir)
 
10
        test_case.smart_dir = test_case.makeDir()
 
11
        test_case.repository_dir = test_case.makeDir()
 
12
        create_simple_repository(test_case.repository_dir)
13
13
 
14
14
    def tear_down(self, test_case):
15
15
        if smart.iface.object:
21
21
    def set_up(self, test_case):
22
22
        super(SmartFacadeHelper, self).set_up(test_case)
23
23
 
24
 
        from landscape.package.facade import SmartFacade, make_deb_dir_channel
 
24
        from landscape.package.facade import SmartFacade
25
25
 
26
26
        class Facade(SmartFacade):
27
27
            repository_dir = test_case.repository_dir
28
28
 
29
29
            def smart_initialized(self):
30
30
                self.reset_channels()
31
 
                self.add_channel("alias",
32
 
                                 make_deb_dir_channel(test_case.repository_dir))
 
31
                self.add_channel_deb_dir(test_case.repository_dir)
33
32
 
34
33
        test_case.Facade = Facade
35
34
        test_case.facade = Facade({"datadir": test_case.smart_dir})
42
41
HASH1 = base64.decodestring("/ezv4AefpJJ8DuYFSq4RiEHJYP4=")
43
42
HASH2 = base64.decodestring("glP4DwWOfMULm0AkRXYsH/exehc=")
44
43
HASH3 = base64.decodestring("NJM05mj86veaSInYxxqL1wahods=")
45
 
 
46
 
 
47
 
def create_repository(target_dir):
 
44
HASH4 = 'c\xc1\xe6\xe1U\xde\xb6:\x03\xcb\xb9\xdc\xee\x91\xb7"\xc9\xb1\xe4\x8f'
 
45
HASH5 = '|\x93K\xe0gx\xba\xe4\x85\x84\xd9\xf4%\x8bB\xbdR\x97\xdb\xfc'
 
46
HASH6 = '\xedt!=,\\\rk\xa7\xe3$\xfb\x06\x9c\x88\x92)\xc2\xfb\xd6'
 
47
HASH7 = 'D\xb1\xb6\xf5\xaa\xa8i\x84\x07#x\x97\x01\xf7`.\x9b\xde\xfb '
 
48
 
 
49
RELEASES = {"hardy": """Origin: Ubuntu
 
50
Label: Ubuntu
 
51
Codename: hardy
 
52
Version: 8.04
 
53
Date: Tue, 31 Mar 2009 13:30:02 +0000
 
54
Architectures: amd64 i386
 
55
Components: main restricted
 
56
MD5Sum:
 
57
 356312bc1c0ab2b8dbe5c67f09879497 827 main/binary-i386/Packages
 
58
 ad2d9b94381264ce25cda7cfa1b2da03 555 main/binary-i386/Packages.gz
 
59
 2f6ee66ed2d2b4115fabc8eed428e42e 78 main/binary-i386/Release
 
60
 f0fd5c1bb18584cf07f9bf4a9f2e6d92 605 main/binary-amd64/Packages
 
61
 98860034ca03a73a9face10af8238a81 407 main/binary-amd64/Packages.gz
 
62
 7e40db962fe49b6db232bf559cf6f79d 79 main/binary-amd64/Release
 
63
 99e2e7213a7fdd8dd6860623bbf700e6 538 restricted/binary-i386/Packages
 
64
 7771307958f2800bafb5cd96292308bd 384 restricted/binary-i386/Packages.gz
 
65
 8686ad9c5d83484dc66a1eca2bd8030f 84 restricted/binary-i386/Release
 
66
 99e2e7213a7fdd8dd6860623bbf700e6 538 restricted/binary-amd64/Packages
 
67
 7771307958f2800bafb5cd96292308bd 384 restricted/binary-amd64/Packages.gz
 
68
 6e24798a6089cd3a21226182784995e9 85 restricted/binary-amd64/Release
 
69
SHA1:
 
70
 1f39494284f8da4a1cdd788a3d91a048c5edf7f5 827 main/binary-i386/Packages
 
71
 e79a66d7543f24f77a9ffe1409431ae717781375 555 main/binary-i386/Packages.gz
 
72
 5fe86036c60d6210b662df3acc238e2936f03581 78 main/binary-i386/Release
 
73
 37ba69be70f4a79506038c0124293187bc879014 605 main/binary-amd64/Packages
 
74
 65dca66c72b18d59cdcf671775104e86cbe2123a 407 main/binary-amd64/Packages.gz
 
75
 c9810732c61aa7de2887b5194c6a09d0b6118664 79 main/binary-amd64/Release
 
76
 4cdb64c700f798f719f5c81ae42e44582be094c5 538 restricted/binary-i386/Packages
 
77
 190f980fd80d58284129ee050f9eb70b9590fedb 384 restricted/binary-i386/Packages.gz
 
78
 b1d1a4d57f5c8d70184c9661a087b8a92406c76d 84 restricted/binary-i386/Release
 
79
 4cdb64c700f798f719f5c81ae42e44582be094c5 538 restricted/binary-amd64/Packages
 
80
 190f980fd80d58284129ee050f9eb70b9590fedb 384 restricted/binary-amd64/Packages.gz
 
81
 4bd64fb2ef44037254729ab514d3403a65db7123 85 restricted/binary-amd64/Release
 
82
""",
 
83
            "hardy-updates": """Origin: Ubuntu
 
84
Label: Ubuntu
 
85
Codename: hardy-updates
 
86
Version: 8.04
 
87
Date: Tue, 31 Mar 2009 13:32:17 +0000
 
88
Architectures: i386 amd64
 
89
Components: main restricted
 
90
MD5Sum:
 
91
 a23ba734dc4fe7c1ec8dc960cc670b8e 1227 main/binary-i386/Packages
 
92
 2d6d271964be8000808abfa2b0e999b7 713 main/binary-i386/Packages.gz
 
93
 2f6ee66ed2d2b4115fabc8eed428e42e 78 main/binary-i386/Release
 
94
 a23ba734dc4fe7c1ec8dc960cc670b8e 1227 main/binary-amd64/Packages
 
95
 2d6d271964be8000808abfa2b0e999b7 713 main/binary-amd64/Packages.gz
 
96
 7e40db962fe49b6db232bf559cf6f79d 79 main/binary-amd64/Release
 
97
 d41d8cd98f00b204e9800998ecf8427e 0 restricted/binary-i386/Packages
 
98
 7029066c27ac6f5ef18d660d5741979a 20 restricted/binary-i386/Packages.gz
 
99
 8686ad9c5d83484dc66a1eca2bd8030f 84 restricted/binary-i386/Release
 
100
 d41d8cd98f00b204e9800998ecf8427e 0 restricted/binary-amd64/Packages
 
101
 7029066c27ac6f5ef18d660d5741979a 20 restricted/binary-amd64/Packages.gz
 
102
 6e24798a6089cd3a21226182784995e9 85 restricted/binary-amd64/Release
 
103
SHA1:
 
104
 9867c9f7ebbb5741fc589d0d4395ea8f74f3b5e4 1227 main/binary-i386/Packages
 
105
 2a7061fa162a607a63453c0360678052a38f0259 713 main/binary-i386/Packages.gz
 
106
 5fe86036c60d6210b662df3acc238e2936f03581 78 main/binary-i386/Release
 
107
 9867c9f7ebbb5741fc589d0d4395ea8f74f3b5e4 1227 main/binary-amd64/Packages
 
108
 2a7061fa162a607a63453c0360678052a38f0259 713 main/binary-amd64/Packages.gz
 
109
 c9810732c61aa7de2887b5194c6a09d0b6118664 79 main/binary-amd64/Release
 
110
 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 restricted/binary-i386/Packages
 
111
 46c6643f07aa7f6bfe7118de926b86defc5087c4 20 restricted/binary-i386/Packages.gz
 
112
 b1d1a4d57f5c8d70184c9661a087b8a92406c76d 84 restricted/binary-i386/Release
 
113
 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 restricted/binary-amd64/Packages
 
114
 46c6643f07aa7f6bfe7118de926b86defc5087c4 20 restricted/binary-amd64/Packages.gz
 
115
 4bd64fb2ef44037254729ab514d3403a65db7123 85 restricted/binary-amd64/Release
 
116
"""}
 
117
 
 
118
PACKAGES = {"hardy":
 
119
            {"restricted":
 
120
             {"amd64": """Package: kairos
 
121
Version: 0.0.8
 
122
Architecture: all
 
123
Maintainer: Free Ekanayaka <freee@debian.org>
 
124
Installed-Size: 192
 
125
Pre-Depends: libaugeas0, python-augeas, augeas-tools, jackd, rotter, monit, darkice, soma, python-remix, nfs-kernel-server, icecast2
 
126
Priority: extra
 
127
Section: admin
 
128
Filename: pool/restricted/k/kairos/kairos_0.0.8_all.deb
 
129
Size: 60768
 
130
SHA1: 1e5cc71cbd33d2b26a8feb19a48e815f271cd335
 
131
MD5sum: 5fd717ed3d15db25ffaa9d05fec62e42
 
132
Description: kairos customisation package
 
133
 This package configures and customises an kairos
 
134
 machine.
 
135
 
 
136
""",
 
137
              "i386": """Package: kairos
 
138
Version: 0.0.8
 
139
Architecture: all
 
140
Maintainer: Free Ekanayaka <freee@debian.org>
 
141
Installed-Size: 192
 
142
Pre-Depends: libaugeas0, python-augeas, augeas-tools, jackd, rotter, monit, darkice, soma, python-remix, nfs-kernel-server, icecast2
 
143
Priority: extra
 
144
Section: admin
 
145
Filename: pool/restricted/k/kairos/kairos_0.0.8_all.deb
 
146
Size: 60768
 
147
SHA1: 1e5cc71cbd33d2b26a8feb19a48e815f271cd335
 
148
MD5sum: 5fd717ed3d15db25ffaa9d05fec62e42
 
149
Description: kairos customisation package
 
150
 This package configures and customises an kairos
 
151
 machine.
 
152
 
 
153
"""},
 
154
             "main":
 
155
             {"amd64": """Package: libclthreads2
 
156
Source: clthreads
 
157
Version: 2.4.0-1
 
158
Architecture: amd64
 
159
Maintainer: Debian Multimedia Maintainers <pkg-multimedia-maintainers@lists.alioth.debian.org>
 
160
Installed-Size: 80
 
161
Depends: libc6 (>= 2.3.2), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.1.1)
 
162
Priority: extra
 
163
Section: libs
 
164
Filename: pool/main/c/clthreads/libclthreads2_2.4.0-1_amd64.deb
 
165
Size: 12938
 
166
SHA1: dc6cb78896642dd436851888b8bd4454ab8f421b
 
167
MD5sum: 19960adb88e178fb7eb4997b47eee05b
 
168
Description: POSIX threads C++ access library
 
169
 C++ wrapper library around the POSIX threads API. This package includes
 
170
 the shared library object.
 
171
 
 
172
""",
 
173
              "i386": """Package: syslinux
 
174
Version: 2:3.73+dfsg-2
 
175
Architecture: i386
 
176
Maintainer: Daniel Baumann <daniel@debian.org>
 
177
Installed-Size: 140
 
178
Depends: libc6 (>= 2.7-1), syslinux-common (= 2:3.73+dfsg-2), dosfstools, mtools
 
179
Homepage: http://syslinux.zytor.com/
 
180
Priority: optional
 
181
Section: utils
 
182
Filename: pool/main/s/syslinux/syslinux_3.73+dfsg-2_i386.deb
 
183
Size: 70384
 
184
SHA1: 6edf6a7e81a5e9759270872e45c782394dfa85e5
 
185
MD5sum: ae8baa9f6c6a172a3b127af1e6675046
 
186
Description: utilities for the syslinux bootloaders
 
187
 SYSLINUX is a suite of lightweight bootloaders, currently supporting DOS FAT
 
188
 filesystems (SYSLINUX), Linux ext2/ext3 filesystems (EXTLINUX), PXE network
 
189
 booting (PXELINUX), or bootable "El Torito" ISO 9660 CD-ROMs (ISOLINUX). It
 
190
 also includes a tool, MEMDISK, which loads legacy operating systems (such as
 
191
 DOS) from these media.
 
192
 
 
193
"""}},
 
194
            "hardy-updates":
 
195
            {"restricted":
 
196
             {"amd64": """""",
 
197
              "i386": """"""},
 
198
             "main":
 
199
             {"amd64": """Package: rebuildd
 
200
Version: 0.3.5
 
201
Architecture: all
 
202
Maintainer: Julien Danjou <acid@debian.org>
 
203
Installed-Size: 312
 
204
Depends: python (>= 2.5), python-support (>= 0.7.1), lsb-base, python-sqlobject, python-apt
 
205
Recommends: pbuilder, python-gdchart2, python-webpy
 
206
Suggests: cowdancer
 
207
Priority: extra
 
208
Section: devel
 
209
Filename: pool/main/r/rebuildd/rebuildd_0.3.5_all.deb
 
210
Size: 24652
 
211
SHA1: 5446cd5c8a29212b403214884cae96f14824a573
 
212
MD5sum: 92e81240c2caf286ad103e44dcdc44e1
 
213
Description: build daemon aiming at rebuilding Debian packages
 
214
 This software allows you to manage a set of jobs. Each job is a package
 
215
 rebuilding task. Rebuilding is done by pbuilder (or cowbuilder if you want),
 
216
 or anything else, since everything is customizable via configuration file.
 
217
 It can also send build logs by email, event each log can be sent to a different
 
218
 email address.
 
219
 .
 
220
 rebuildd is multi-threaded, so you can run multiple build jobs in parallel.
 
221
 It is also administrable via a telnet interface. A Web interface is also
 
222
 embedded so you can see your jobs queue and watch log file in real-time in your
 
223
 browser.
 
224
 .
 
225
 rebuildd is designed to be run on multiple hosts even with different
 
226
 architecture set, and to parallelize the rebuild tasks.
 
227
 
 
228
""",
 
229
              "i386": """Package: rebuildd
 
230
Version: 0.3.5
 
231
Architecture: all
 
232
Maintainer: Julien Danjou <acid@debian.org>
 
233
Installed-Size: 312
 
234
Depends: python (>= 2.5), python-support (>= 0.7.1), lsb-base, python-sqlobject, python-apt
 
235
Recommends: pbuilder, python-gdchart2, python-webpy
 
236
Suggests: cowdancer
 
237
Priority: extra
 
238
Section: devel
 
239
Filename: pool/main/r/rebuildd/rebuildd_0.3.5_all.deb
 
240
Size: 24652
 
241
SHA1: 5446cd5c8a29212b403214884cae96f14824a573
 
242
MD5sum: 92e81240c2caf286ad103e44dcdc44e1
 
243
Description: build daemon aiming at rebuilding Debian packages
 
244
 This software allows you to manage a set of jobs. Each job is a package
 
245
 rebuilding task. Rebuilding is done by pbuilder (or cowbuilder if you want),
 
246
 or anything else, since everything is customizable via configuration file.
 
247
 It can also send build logs by email, event each log can be sent to a different
 
248
 email address.
 
249
 .
 
250
 rebuildd is multi-threaded, so you can run multiple build jobs in parallel.
 
251
 It is also administrable via a telnet interface. A Web interface is also
 
252
 embedded so you can see your jobs queue and watch log file in real-time in your
 
253
 browser.
 
254
 .
 
255
 rebuildd is designed to be run on multiple hosts even with different
 
256
 architecture set, and to parallelize the rebuild tasks.
 
257
 
 
258
"""}}}
 
259
 
 
260
 
 
261
def create_simple_repository(target_dir):
 
262
    """
 
263
    Create a simple APT repository with a single Packages.gz in C{target_dir}.
 
264
    """
48
265
    filename = os.path.join(target_dir, "Packages.gz")
49
266
    file = open(filename, "w")
50
267
    file.write(base64.decodestring("""
137
354
WjYBSMglEwCkbBKBgFo2AUjIJRMApGwSgYBaNgFIyCUTAKSAIAY/FOKAAoAAAK
138
355
    """))
139
356
    file.close()
 
357
 
 
358
 
 
359
def create_full_repository(target_dir):
 
360
    """
 
361
    Create a full APT repository with a dists/ tree rooted at C{target_dir}.
 
362
    """
 
363
 
 
364
    class Repository(object):
 
365
 
 
366
        codename = "hardy"
 
367
        variant = "hardy-updates"
 
368
        components = "main restricted"
 
369
        archs = ["amd64", "i386"]
 
370
        hashes = [HASH4, HASH5, HASH6, HASH7]
 
371
 
 
372
        def __init__(self, root):
 
373
            self.root = root
 
374
            self.url = "file://%s" % self.root
 
375
 
 
376
    repository = Repository(target_dir)
 
377
    dists_directory = os.path.join(repository.root, "dists")
 
378
    os.mkdir(dists_directory)
 
379
    for dist in [repository.codename, repository.variant]:
 
380
        dist_directory = os.path.join(dists_directory, dist)
 
381
        os.mkdir(dist_directory)
 
382
        fd = open(os.path.join(dist_directory, "Release"), "w")
 
383
        fd.write(RELEASES[dist])
 
384
        fd.close()
 
385
        for component in repository.components.split():
 
386
            component_directory = os.path.join(dist_directory, component)
 
387
            os.mkdir(component_directory)
 
388
            for arch in repository.archs:
 
389
                arch_directory = os.path.join(component_directory,
 
390
                                              "binary-%s" % arch)
 
391
                os.mkdir(arch_directory)
 
392
                fd = open(os.path.join(arch_directory, "Packages"), "w")
 
393
                fd.write(PACKAGES[dist][component][arch])
 
394
                fd.close()
 
395
                fd = open(os.path.join(arch_directory, "Release"), "w")
 
396
                fd.write("""Version: 8.04
 
397
Component: %s
 
398
Origin: Ubuntu
 
399
Label: Ubuntu
 
400
Architecture: %s
 
401
""" % (component, arch))
 
402
                fd.close()
 
403
    return repository