Merge lp:~jibel/ubuntu-cdimage/support_for_multilayer into lp:ubuntu-cdimage
- support_for_multilayer
- Merge into mainline
Status: | Merged |
---|---|
Merged at revision: | 1792 |
Proposed branch: | lp:~jibel/ubuntu-cdimage/support_for_multilayer |
Merge into: | lp:ubuntu-cdimage |
Prerequisite: | lp:~vorlon/ubuntu-cdimage/prune-obsolete-code |
Diff against target: |
358 lines (+130/-81) (has conflicts) 5 files modified
etc/crontab (+1/-1) etc/livefs-launchpad (+1/-0) etc/qa-products (+1/-0) lib/cdimage/livefs.py (+43/-46) lib/cdimage/tests/test_livefs.py (+84/-34) Text conflict in etc/purge-days |
To merge this branch: | bzr merge lp:~jibel/ubuntu-cdimage/support_for_multilayer |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Steve Langasek | Approve | ||
Review via email: mp+364105@code.launchpad.net |
This proposal supersedes a proposal from 2018-11-26.
Commit message
Adds support for multilayer images
* Made artefacts download generic: Don't hardcode artefact names and ensure they can be matched via regexp, on launchpad or local directory build.
* Fixed test suite
* Removed obsolete edubuntu server-squashfs test (LP: #1154601)
* Ensure we are still compatible with tests using a local server and with a local build.
* Add new ubuntu:canary subproject in automated builds
Extract from the discussion with cjwatson about these changes:
"""""
didrocks hey cjwatson! jibel and I have a question on ubuntu-cdimage: as with the new layered images we are building, we might not know in advance the squashfs, size, manifest files. We want to avoid to hardcode more filenames that already exists. In livefs.py, there are basically 2 code paths to download assets. One is using LP API (and so, can list all artefacts attached to a specific build) and the other
didrocks one is just for filesystem + http:// download. We thought to match against regexp, which works in the LP case and for filesystem (via os.listdir()). However, tests are failing as they are using http mock server. I wonder if in production, only the LP path is took. If so, can we just detect "http" for tests and either create a manifest that we download or rely on hardcoded filenames?
cjwatson As far as I know it's only ever the LP path in production, indeed
didrocks so, do you think special casing tests, like not using the regexp for them, is fine?
cjwatson Yeah, I think so
didrocks perfect! Thanks a lot cjwatson :)
cjwatson The http:// case may even be legacy - not sure
didrocks yeah, sounds like it, but we preferred asking you directly :)
cjwatson Obviously for good software engineering reasons keeping special cases for tests to a minimum is a good idea, but creating a sort of meta-manifest doesn't seem unreasonable, maybe with a fallback if it doesn't exist
didrocks yeah, the best would be ofc to rewrite the tests to mock LP
didrocks but I think that's out of our current scope :)
"""""
Description of the change
This is the support for multi layer images based on dead code removal branch from from Steve.
Jean-Baptiste Lallement (jibel) wrote : Posted in a previous version of this proposal | # |
Steve Langasek (vorlon) : Posted in a previous version of this proposal | # |
Didier Roche-Tolomelli (didrocks) wrote : Posted in a previous version of this proposal | # |
Thanks for the review!
We just rebased on your cleanup branch to avoid adapating tests and code that are going to be removed soon. All your comments should hopefully now be addressed :)
Didier Roche-Tolomelli (didrocks) wrote : | # |
FYI, some answers to your comments were in https:/
Steve Langasek (vorlon) wrote : | # |
Thanks, getting close now, mostly I just want you to delete some more code ;)
Also since you have (IMHO reasonably) based this on my other branch which has not yet landed, landing this will now necessarily block on review of that other branch, which I've asked sil2100 to look at.
Steve Langasek (vorlon) : | # |
- 1804. By Jean-Baptiste Lallement
-
* Removed dead code
* Fixed PEP8 warning
* Updated tests to match the code removal and use the LP code path
* Added negative test to download from remote URL
Didier Roche-Tolomelli (didrocks) : | # |
Jean-Baptiste Lallement (jibel) wrote : | # |
Thanks for the review.
We tried to explain our choices to show that some decisions were not arbitrary. No issue on pending on the other MP, as stated before, there was no point anyway to modify tests and code that are going to be removed.
So, we mixed a little bit of dead code removal as you requested on this MP, and adapted the tests as the API isn’t called in the way the tests were calling them.
Steve Langasek (vorlon) wrote : | # |
I still get the following linting failures from ./run-tests on cosmic, do you also see this?
./lib/cdimage/
./lib/cdimage/
./lib/cdimage/
./lib/cdimage/
Jean-Baptiste Lallement (jibel) wrote : | # |
I didn't notice these linter errors on cosmic because pep8 and pyflakes were not installed in the build env.
test_pep8_clean and test_pyflakes_clean should probably fail (or as least explicitly skip) when the linter is not installed instead of returning.
- 1805. By Jean-Baptiste Lallement
-
Fixed linter errors
- 1806. By Jean-Baptiste Lallement
-
Factorized download_
live_items_ * tests and removed duplicated tests
Added test for filtering several artefacts by suffix
Added test for downloading several artefacts
Jean-Baptiste Lallement (jibel) wrote : | # |
We removed duplicated test and added one to cover filtering of artefacts and another to ensure that several artefacts are downloaded.
The remaining point is the question about server-squashfs (cf inline comment)
Steve Langasek (vorlon) wrote : | # |
I covered the point in my prior review that there are no actual consumers of the "server-squashfs" support apart from the tests; so both the tests and the implementation should be culled.
- 1807. By Jean-Baptiste Lallement
-
Removed all the references to server-squashfs
Jean-Baptiste Lallement (jibel) wrote : | # |
All the references to server-squashfs have been removed from livefs.py and the related tests.
Steve Langasek (vorlon) : | # |
Preview Diff
1 | === modified file 'etc/crontab' | |||
2 | --- etc/crontab 2018-10-30 13:23:58 +0000 | |||
3 | +++ etc/crontab 2019-03-12 08:44:31 +0000 | |||
4 | @@ -21,7 +21,7 @@ | |||
5 | 21 | 20 15 * * * DIST=bionic for-project ubuntu-budgie cron.daily-live --live | 21 | 20 15 * * * DIST=bionic for-project ubuntu-budgie cron.daily-live --live |
6 | 22 | 26 2 * * * DIST=bionic for-project ubuntu-mate cron.daily-live --live | 22 | 26 2 * * * DIST=bionic for-project ubuntu-mate cron.daily-live --live |
7 | 23 | # regular disco daily builds | 23 | # regular disco daily builds |
9 | 24 | 31 7 * * * for-project ubuntu cron.daily-live --live | 24 | 31 7 * * * for-project ubuntu cron.daily-live --live; SUBPROJECT=canary for-project ubuntu cron.daily-live --live |
10 | 25 | 14 5 * * * for-project kubuntu cron.daily-live --live | 25 | 14 5 * * * for-project kubuntu cron.daily-live --live |
11 | 26 | 50 1 * * * for-project xubuntu cron.daily-live --live | 26 | 50 1 * * * for-project xubuntu cron.daily-live --live |
12 | 27 | 29 6 * * * for-project ubuntu-server cron.daily --live; for-project ubuntu-server cron.daily-preinstalled --live; SUBPROJECT=live for-project ubuntu-server cron.daily-live --live | 27 | 29 6 * * * for-project ubuntu-server cron.daily --live; for-project ubuntu-server cron.daily-preinstalled --live; SUBPROJECT=live for-project ubuntu-server cron.daily-live --live |
13 | 28 | 28 | ||
14 | === modified file 'etc/livefs-launchpad' | |||
15 | --- etc/livefs-launchpad 2019-03-12 08:44:31 +0000 | |||
16 | +++ etc/livefs-launchpad 2019-03-12 08:44:31 +0000 | |||
17 | @@ -3,6 +3,7 @@ | |||
18 | 3 | # Like etc/default-arches, "PROJECT" is in fact PROJECT[-SUBPROJECT][-LOCALE]. | 3 | # Like etc/default-arches, "PROJECT" is in fact PROJECT[-SUBPROJECT][-LOCALE]. |
19 | 4 | 4 | ||
20 | 5 | ubuntu daily-live * * ubuntu-cdimage/ubuntu | 5 | ubuntu daily-live * * ubuntu-cdimage/ubuntu |
21 | 6 | ubuntu-canary daily-live * * ubuntu-cdimage/ubuntu-canary | ||
22 | 6 | kubuntu daily-live * * ubuntu-cdimage/kubuntu | 7 | kubuntu daily-live * * ubuntu-cdimage/kubuntu |
23 | 7 | edubuntu dvd * * ubuntu-cdimage/edubuntu | 8 | edubuntu dvd * * ubuntu-cdimage/edubuntu |
24 | 8 | xubuntu daily-live * * ubuntu-cdimage/xubuntu | 9 | xubuntu daily-live * * ubuntu-cdimage/xubuntu |
25 | 9 | 10 | ||
26 | === modified file 'etc/qa-products' | |||
27 | --- etc/qa-products 2019-03-12 08:44:31 +0000 | |||
28 | +++ etc/qa-products 2019-03-12 08:44:31 +0000 | |||
29 | @@ -45,6 +45,7 @@ | |||
30 | 45 | 45 | ||
31 | 46 | # Ubuntu Desktop | 46 | # Ubuntu Desktop |
32 | 47 | Ubuntu Desktop amd64 ubuntu daily-live desktop amd64 iso | 47 | Ubuntu Desktop amd64 ubuntu daily-live desktop amd64 iso |
33 | 48 | Ubuntu Desktop (Canary) amd64 ubuntu daily-live/canary desktop amd64 iso | ||
34 | 48 | Ubuntu Desktop amd64+mac ubuntu daily-live desktop amd64+mac iso | 49 | Ubuntu Desktop amd64+mac ubuntu daily-live desktop amd64+mac iso |
35 | 49 | Ubuntu Desktop armhf+omap4 ubuntu daily-live desktop armhf+omap4 iso | 50 | Ubuntu Desktop armhf+omap4 ubuntu daily-live desktop armhf+omap4 iso |
36 | 50 | Ubuntu Desktop i386 ubuntu daily-live desktop i386 iso | 51 | Ubuntu Desktop i386 ubuntu daily-live desktop i386 iso |
37 | 51 | 52 | ||
38 | === modified file 'lib/cdimage/livefs.py' | |||
39 | --- lib/cdimage/livefs.py 2019-03-12 08:44:31 +0000 | |||
40 | +++ lib/cdimage/livefs.py 2019-03-12 08:44:31 +0000 | |||
41 | @@ -538,22 +538,32 @@ | |||
42 | 538 | liveproject_subarch = liveproject | 538 | liveproject_subarch = liveproject |
43 | 539 | 539 | ||
44 | 540 | lp, lp_livefs = get_lp_livefs(config, arch) | 540 | lp, lp_livefs = get_lp_livefs(config, arch) |
45 | 541 | uris = [] | ||
46 | 542 | root = "" | ||
47 | 541 | if lp_livefs is not None: | 543 | if lp_livefs is not None: |
48 | 542 | lp_kwargs = live_build_lp_kwargs(config, lp, lp_livefs, arch) | 544 | lp_kwargs = live_build_lp_kwargs(config, lp, lp_livefs, arch) |
49 | 543 | lp_build = lp_livefs.getLatestBuild( | 545 | lp_build = lp_livefs.getLatestBuild( |
50 | 544 | lp_kwargs["distro_arch_series"], | 546 | lp_kwargs["distro_arch_series"], |
51 | 545 | unique_key=lp_kwargs.get("unique_key")) | 547 | unique_key=lp_kwargs.get("unique_key")) |
58 | 546 | lp_urls = list(lp_build.getFileUrls()) | 548 | uris = list(lp_build.getFileUrls()) |
53 | 547 | |||
54 | 548 | def urls_for(base): | ||
55 | 549 | for url in lp_urls: | ||
56 | 550 | if unquote(os.path.basename(url)) == base: | ||
57 | 551 | yield url | ||
59 | 552 | else: | 549 | else: |
60 | 553 | root = livecd_base(config, arch) | 550 | root = livecd_base(config, arch) |
61 | 551 | try: | ||
62 | 552 | uris = [os.path.join(root, u) for u in os.listdir(root)] | ||
63 | 553 | except OSError: | ||
64 | 554 | # fallback to exact given uri (for http://) in url_for as we can't | ||
65 | 555 | # list content. | ||
66 | 556 | pass | ||
67 | 554 | 557 | ||
70 | 555 | def urls_for(base): | 558 | def urls_for(base, item): |
71 | 556 | yield "%s/%s" % (root, base) | 559 | if uris: |
72 | 560 | for uri in uris: | ||
73 | 561 | filename = unquote(os.path.basename(uri)) | ||
74 | 562 | if (filename.startswith(base + '.') and | ||
75 | 563 | filename.endswith('.' + item)): | ||
76 | 564 | yield uri | ||
77 | 565 | else: | ||
78 | 566 | yield os.path.join(root, base + '.' + item) | ||
79 | 557 | 567 | ||
80 | 558 | if item in ( | 568 | if item in ( |
81 | 559 | "cloop", "squashfs", "manifest", "manifest-desktop", "manifest-remove", | 569 | "cloop", "squashfs", "manifest", "manifest-desktop", "manifest-remove", |
82 | @@ -561,20 +571,22 @@ | |||
83 | 561 | "rootfs.tar.gz", "custom.tar.gz", "device.tar.gz", | 571 | "rootfs.tar.gz", "custom.tar.gz", "device.tar.gz", |
84 | 562 | "azure.device.tar.gz", "raspi2.device.tar.gz", "plano.device.tar.gz", | 572 | "azure.device.tar.gz", "raspi2.device.tar.gz", "plano.device.tar.gz", |
85 | 563 | "tar.xz", "iso", "os.snap", "kernel.snap", "disk1.img.xz", | 573 | "tar.xz", "iso", "os.snap", "kernel.snap", "disk1.img.xz", |
88 | 564 | "dragonboard.kernel.snap", "raspi2.kernel.snap", "installer.squashfs", | 574 | "dragonboard.kernel.snap", "raspi2.kernel.snap", |
87 | 565 | "maas-rack.squashfs", "maas-region.squashfs", | ||
89 | 566 | "img.xz", "model-assertion" | 575 | "img.xz", "model-assertion" |
90 | 567 | ): | 576 | ): |
91 | 568 | if item == "ext4" and arch == "armhf+nexus7": | 577 | if item == "ext4" and arch == "armhf+nexus7": |
92 | 569 | for url in urls_for( | 578 | for url in urls_for( |
94 | 570 | "livecd.%s.%s-nexus7" % (liveproject_subarch, item)): | 579 | "livecd." + liveproject_subarch, item + "-nexus7"): |
95 | 571 | yield url | 580 | yield url |
96 | 572 | elif item == "disk1.img.xz": | 581 | elif item == "disk1.img.xz": |
97 | 573 | for url in urls_for( | 582 | for url in urls_for( |
99 | 574 | "livecd.%s.%s" % (liveproject, item)): | 583 | "livecd." + liveproject, item): |
100 | 575 | yield url | 584 | yield url |
101 | 576 | else: | 585 | else: |
103 | 577 | for url in urls_for("livecd.%s.%s" % (liveproject_subarch, item)): | 586 | for url in urls_for("livecd." + liveproject_subarch, item): |
104 | 587 | # filter out redundant artefacts | ||
105 | 588 | if url.endswith("modules.squashfs"): | ||
106 | 589 | continue | ||
107 | 578 | yield url | 590 | yield url |
108 | 579 | elif item in ( | 591 | elif item in ( |
109 | 580 | "kernel", "initrd", "bootimg", "modules.squashfs" | 592 | "kernel", "initrd", "bootimg", "modules.squashfs" |
110 | @@ -582,8 +594,8 @@ | |||
111 | 582 | our_flavours = flavours(config, arch) | 594 | our_flavours = flavours(config, arch) |
112 | 583 | our_flavours.extend(["%s-hwe" % (f,) for f in our_flavours]) | 595 | our_flavours.extend(["%s-hwe" % (f,) for f in our_flavours]) |
113 | 584 | for flavour in our_flavours: | 596 | for flavour in our_flavours: |
116 | 585 | base = "livecd.%s.%s-%s" % (liveproject_subarch, item, flavour) | 597 | for url in urls_for("livecd." + liveproject_subarch, |
117 | 586 | for url in urls_for(base): | 598 | item + "-" + flavour): |
118 | 587 | yield url | 599 | yield url |
119 | 588 | elif item in ( | 600 | elif item in ( |
120 | 589 | "boot-%s+%s.img" % (target.ubuntu_arch, target.subarch) | 601 | "boot-%s+%s.img" % (target.ubuntu_arch, target.subarch) |
121 | @@ -596,15 +608,13 @@ | |||
122 | 596 | for target in Touch.list_targets_by_ubuntu_arch(arch) | 608 | for target in Touch.list_targets_by_ubuntu_arch(arch) |
123 | 597 | ): | 609 | ): |
124 | 598 | for flavour in flavours(config, arch): | 610 | for flavour in flavours(config, arch): |
127 | 599 | base = "livecd.%s.%s" % (liveproject_subarch, item) | 611 | for url in urls_for("livecd." + liveproject_subarch, item): |
126 | 600 | for url in urls_for(base): | ||
128 | 601 | yield url | 612 | yield url |
129 | 602 | elif item == "kernel-efi-signed": | 613 | elif item == "kernel-efi-signed": |
130 | 603 | if series >= "precise" and arch == "amd64": | 614 | if series >= "precise" and arch == "amd64": |
131 | 604 | for flavour in flavours(config, arch): | 615 | for flavour in flavours(config, arch): |
135 | 605 | base = "livecd.%s.kernel-%s.efi.signed" % ( | 616 | for url in urls_for("livecd." + liveproject_subarch, |
136 | 606 | liveproject_subarch, flavour) | 617 | "kernel-" + flavour + ".efi.signed"): |
134 | 607 | for url in urls_for(base): | ||
137 | 608 | yield url | 618 | yield url |
138 | 609 | elif item == "wubi": | 619 | elif item == "wubi": |
139 | 610 | if (project != "xubuntu" and arch in ("amd64", "i386")): | 620 | if (project != "xubuntu" and arch in ("amd64", "i386")): |
140 | @@ -616,7 +626,7 @@ | |||
141 | 616 | "stable" % series) | 626 | "stable" % series) |
142 | 617 | elif item == "ltsp-squashfs": | 627 | elif item == "ltsp-squashfs": |
143 | 618 | if arch in ("amd64", "i386"): | 628 | if arch in ("amd64", "i386"): |
145 | 619 | for url in urls_for("livecd.%s-ltsp.squashfs" % liveproject): | 629 | for url in urls_for("livecd." + liveproject + "-ltsp", "squashfs"): |
146 | 620 | yield url | 630 | yield url |
147 | 621 | else: | 631 | else: |
148 | 622 | raise UnknownLiveItem("Unknown live filesystem item '%s'" % item) | 632 | raise UnknownLiveItem("Unknown live filesystem item '%s'" % item) |
149 | @@ -635,15 +645,7 @@ | |||
150 | 635 | output_dir = live_output_directory(config) | 645 | output_dir = live_output_directory(config) |
151 | 636 | found = False | 646 | found = False |
152 | 637 | 647 | ||
162 | 638 | if item == "server-squashfs": | 648 | urls = list(live_item_paths(config, arch, item)) |
154 | 639 | original_project = config.project | ||
155 | 640 | try: | ||
156 | 641 | config["PROJECT"] = "ubuntu-server" | ||
157 | 642 | urls = list(live_item_paths(config, arch, "squashfs")) | ||
158 | 643 | finally: | ||
159 | 644 | config["PROJECT"] = original_project | ||
160 | 645 | else: | ||
161 | 646 | urls = list(live_item_paths(config, arch, item)) | ||
163 | 647 | if not urls: | 649 | if not urls: |
164 | 648 | return False | 650 | return False |
165 | 649 | 651 | ||
166 | @@ -726,14 +728,17 @@ | |||
167 | 726 | except osextras.FetchError: | 728 | except osextras.FetchError: |
168 | 727 | pass | 729 | pass |
169 | 728 | else: | 730 | else: |
178 | 729 | target = os.path.join(output_dir, "%s.%s" % (arch, item)) | 731 | for url in urls: |
179 | 730 | try: | 732 | # strip livecd.<PROJECT> and replace by arch |
180 | 731 | osextras.fetch(config, urls[0], target) | 733 | filename = unquote(os.path.basename(url)).split('.', 2)[-1] |
181 | 732 | if item in ["squashfs", "server-squashfs"]: | 734 | target = os.path.join(output_dir, "%s.%s" % (arch, filename)) |
182 | 733 | sign.sign_cdimage(config, target) | 735 | try: |
183 | 734 | found = True | 736 | osextras.fetch(config, url, target) |
184 | 735 | except osextras.FetchError: | 737 | if target.endswith("squashfs"): |
185 | 736 | pass | 738 | sign.sign_cdimage(config, target) |
186 | 739 | found = True | ||
187 | 740 | except osextras.FetchError: | ||
188 | 741 | pass | ||
189 | 737 | return found | 742 | return found |
190 | 738 | 743 | ||
191 | 739 | 744 | ||
192 | @@ -796,9 +801,6 @@ | |||
193 | 796 | elif download_live_items(config, arch, "cloop"): | 801 | elif download_live_items(config, arch, "cloop"): |
194 | 797 | got_image = True | 802 | got_image = True |
195 | 798 | elif download_live_items(config, arch, "squashfs"): | 803 | elif download_live_items(config, arch, "squashfs"): |
196 | 799 | download_live_items(config, arch, "installer.squashfs") | ||
197 | 800 | download_live_items(config, arch, "maas-rack.squashfs") | ||
198 | 801 | download_live_items(config, arch, "maas-region.squashfs") | ||
199 | 802 | download_live_items(config, arch, "modules.squashfs") | 804 | download_live_items(config, arch, "modules.squashfs") |
200 | 803 | got_image = True | 805 | got_image = True |
201 | 804 | elif download_live_items(config, arch, "rootfs.tar.gz"): | 806 | elif download_live_items(config, arch, "rootfs.tar.gz"): |
202 | @@ -904,10 +906,5 @@ | |||
203 | 904 | if project == "edubuntu" and config["CDIMAGE_DVD"]: | 906 | if project == "edubuntu" and config["CDIMAGE_DVD"]: |
204 | 905 | for arch in config.arches: | 907 | for arch in config.arches: |
205 | 906 | if arch in ("amd64", "i386"): | 908 | if arch in ("amd64", "i386"): |
206 | 907 | # TODO: Disabled for raring (LP: #1154601) | ||
207 | 908 | # if series >= "raring": | ||
208 | 909 | # # Fetch the Ubuntu Server squashfs for Edubuntu Server. | ||
209 | 910 | # download_live_items(config, arch, "server-squashfs") | ||
210 | 911 | |||
211 | 912 | # Fetch the i386 LTSP chroot for Edubuntu Terminal Server. | 909 | # Fetch the i386 LTSP chroot for Edubuntu Terminal Server. |
212 | 913 | download_live_items(config, arch, "ltsp-squashfs") | 910 | download_live_items(config, arch, "ltsp-squashfs") |
213 | 914 | 911 | ||
214 | === modified file 'lib/cdimage/tests/test_livefs.py' | |||
215 | --- lib/cdimage/tests/test_livefs.py 2019-03-12 08:44:31 +0000 | |||
216 | +++ lib/cdimage/tests/test_livefs.py 2019-03-12 08:44:31 +0000 | |||
217 | @@ -1201,50 +1201,56 @@ | |||
218 | 1201 | mock_fetch.assert_called_once_with( | 1201 | mock_fetch.assert_called_once_with( |
219 | 1202 | self.config, url, os.path.join(target_dir, "i386.squashfs")) | 1202 | self.config, url, os.path.join(target_dir, "i386.squashfs")) |
220 | 1203 | 1203 | ||
240 | 1204 | @mock.patch("cdimage.osextras.fetch") | 1204 | def assert_desktop_live_download_items(self, series, item, filenames): |
241 | 1205 | def test_download_live_items_server_squashfs(self, mock_fetch): | 1205 | self.assert_live_download_items("ubuntu", "", series, item, |
242 | 1206 | self.config["PROJECT"] = "edubuntu" | 1206 | filenames, filenames) |
243 | 1207 | self.config["DIST"] = "trusty" | 1207 | |
244 | 1208 | self.config["IMAGE_TYPE"] = "dvd" | 1208 | def assert_desktop_live_download_items_with_expected(self, series, item, |
245 | 1209 | self.assertTrue( | 1209 | filenames, |
246 | 1210 | download_live_items(self.config, "i386", "server-squashfs")) | 1210 | expected_files): |
247 | 1211 | url = ("http://cardamom.buildd/~buildd/LiveCD/trusty/ubuntu-server/" | 1211 | self.assert_live_download_items("ubuntu", "", series, item, |
248 | 1212 | "current/livecd.ubuntu-server.squashfs") | 1212 | filenames, expected_files) |
249 | 1213 | target_dir = os.path.join( | 1213 | |
250 | 1214 | self.temp_dir, "scratch", "edubuntu", "trusty", "dvd", "live") | 1214 | def assert_server_live_download_items(self, series, item, filenames): |
251 | 1215 | mock_fetch.assert_called_once_with( | 1215 | self.assert_live_download_items("ubuntu-server", "live", series, item, |
252 | 1216 | self.config, url, os.path.join(target_dir, "i386.server-squashfs")) | 1216 | filenames, filenames) |
253 | 1217 | 1217 | ||
254 | 1218 | @mock.patch("cdimage.osextras.fetch") | 1218 | @mock.patch("cdimage.osextras.fetch") |
255 | 1219 | def assert_server_live_download_items(self, series, item, filenames, | 1219 | def assert_live_download_items(self, project, subproject, series, item, |
256 | 1220 | mock_fetch): | 1220 | filenames, expected_files, mock_fetch): |
257 | 1221 | self.config["PROJECT"] = "ubuntu-server" | 1221 | artefacts_dir = self.use_temp_dir() |
258 | 1222 | self.config["SUBPROJECT"] = "live" | 1222 | self.config["PROJECT"] = project |
259 | 1223 | self.config["SUBPROJECT"] = subproject | ||
260 | 1223 | self.config["DIST"] = series | 1224 | self.config["DIST"] = series |
261 | 1224 | self.config["IMAGE_TYPE"] = "daily-live" | 1225 | self.config["IMAGE_TYPE"] = "daily-live" |
264 | 1225 | self.assertTrue( | 1226 | self.config["LIVECD"] = artefacts_dir |
263 | 1226 | download_live_items(self.config, "amd64", item)) | ||
265 | 1227 | calls = [] | 1227 | calls = [] |
266 | 1228 | project_path = project | ||
267 | 1229 | if subproject: | ||
268 | 1230 | project_path = "%s-%s" % (project_path, subproject) | ||
269 | 1228 | for filename in filenames: | 1231 | for filename in filenames: |
272 | 1229 | url = ("http://kapok.buildd/~buildd/LiveCD/%s/ubuntu-server-live/" | 1232 | uri = os.path.join( |
273 | 1230 | "current/livecd.ubuntu-server.%s") % (series, filename) | 1233 | artefacts_dir, series, |
274 | 1234 | project_path, "current", | ||
275 | 1235 | "livecd.%s.%s" % (project, filename)) | ||
276 | 1236 | touch(uri) | ||
277 | 1237 | for filename in expected_files: | ||
278 | 1231 | target = os.path.join( | 1238 | target = os.path.join( |
280 | 1232 | self.temp_dir, "scratch", "ubuntu-server", series, | 1239 | self.temp_dir, "scratch", project, series, |
281 | 1233 | "daily-live", "live", "amd64." + filename) | 1240 | "daily-live", "live", "amd64." + filename) |
283 | 1234 | calls.append(mock.call(self.config, url, target)) | 1241 | uri = os.path.join( |
284 | 1242 | artefacts_dir, series, | ||
285 | 1243 | project_path, "current", | ||
286 | 1244 | "livecd.%s.%s" % (project, filename)) | ||
287 | 1245 | calls.append(mock.call(self.config, uri, target)) | ||
288 | 1246 | |||
289 | 1247 | self.assertTrue( | ||
290 | 1248 | download_live_items(self.config, "amd64", item)) | ||
291 | 1235 | self.assertCountEqual(mock_fetch.call_args_list, calls) | 1249 | self.assertCountEqual(mock_fetch.call_args_list, calls) |
292 | 1236 | 1250 | ||
293 | 1237 | def test_download_live_items_installer_squashfs(self): | 1251 | def test_download_live_items_installer_squashfs(self): |
294 | 1238 | self.assert_server_live_download_items( | 1252 | self.assert_server_live_download_items( |
304 | 1239 | "bionic", "installer.squashfs", ["installer.squashfs"]) | 1253 | "bionic", "squashfs", ["installer.squashfs"]) |
296 | 1240 | |||
297 | 1241 | def test_download_live_items_maas_rack_squashfs(self): | ||
298 | 1242 | self.assert_server_live_download_items( | ||
299 | 1243 | "bionic", "maas-rack.squashfs", ["maas-rack.squashfs"]) | ||
300 | 1244 | |||
301 | 1245 | def test_download_live_items_maas_region_squashfs(self): | ||
302 | 1246 | self.assert_server_live_download_items( | ||
303 | 1247 | "bionic", "maas-region.squashfs", ["maas-region.squashfs"]) | ||
305 | 1248 | 1254 | ||
306 | 1249 | def test_download_live_server_boot_items(self): | 1255 | def test_download_live_server_boot_items(self): |
307 | 1250 | self.assert_server_live_download_items( | 1256 | self.assert_server_live_download_items( |
308 | @@ -1257,6 +1263,50 @@ | |||
309 | 1257 | "bionic", "modules.squashfs", | 1263 | "bionic", "modules.squashfs", |
310 | 1258 | ["modules.squashfs-generic", "modules.squashfs-generic-hwe"]) | 1264 | ["modules.squashfs-generic", "modules.squashfs-generic-hwe"]) |
311 | 1259 | 1265 | ||
312 | 1266 | @mock.patch("cdimage.osextras.fetch") | ||
313 | 1267 | def test_download_live_items_multi_layers_squashfs(self, mock_fetch): | ||
314 | 1268 | self.assert_desktop_live_download_items( | ||
315 | 1269 | "disco", "squashfs", | ||
316 | 1270 | ["minimal.standard.live.squashfs"]) | ||
317 | 1271 | |||
318 | 1272 | @mock.patch("cdimage.osextras.fetch") | ||
319 | 1273 | def test_download_live_items_multiple_squashfses(self, mock_fetch): | ||
320 | 1274 | self.assert_desktop_live_download_items( | ||
321 | 1275 | "disco", "squashfs", | ||
322 | 1276 | ["minimal.squashfs", | ||
323 | 1277 | "minimal.standard.squashfs", | ||
324 | 1278 | "minimal.standard.live.squashfs"]) | ||
325 | 1279 | |||
326 | 1280 | @mock.patch("cdimage.osextras.fetch") | ||
327 | 1281 | def test_download_live_items_filter_suffix(self, mock_fetch): | ||
328 | 1282 | self.assert_desktop_live_download_items_with_expected( | ||
329 | 1283 | "disco", "squashfs", | ||
330 | 1284 | ["minimal.squashfs", "minimal.size"], ["minimal.squashfs"]) | ||
331 | 1285 | |||
332 | 1286 | @mock.patch("cdimage.osextras.fetch") | ||
333 | 1287 | def test_download_remote_doesnt_honor_suffix(self, mock_fetch): | ||
334 | 1288 | '''Downloading from remote (not LP or local path) will only download | ||
335 | 1289 | basic names''' | ||
336 | 1290 | self.config["PROJECT"] = "ubuntu" | ||
337 | 1291 | self.config["DIST"] = "disco" | ||
338 | 1292 | self.config["IMAGE_TYPE"] = "daily-live" | ||
339 | 1293 | target_dir = os.path.join( | ||
340 | 1294 | self.temp_dir, "scratch", "ubuntu", "disco", "daily-live", "live") | ||
341 | 1295 | |||
342 | 1296 | self.assertTrue( | ||
343 | 1297 | download_live_items(self.config, "amd64", "squashfs")) | ||
344 | 1298 | mock_fetch.assert_called_once_with( | ||
345 | 1299 | self.config, | ||
346 | 1300 | "http://kapok.buildd/~buildd/LiveCD/disco/ubuntu/" +\ | ||
347 | 1301 | # This can't be livecd.ubuntu.minimal.standard.live.squashfs for | ||
348 | 1302 | # instance | ||
349 | 1303 | "current/livecd.ubuntu.squashfs", | ||
350 | 1304 | os.path.join( | ||
351 | 1305 | target_dir, | ||
352 | 1306 | # This can't be amd64.minimal.standard.live.squashfs for | ||
353 | 1307 | # instance | ||
354 | 1308 | "amd64.squashfs")) | ||
355 | 1309 | |||
356 | 1260 | def test_write_autorun(self): | 1310 | def test_write_autorun(self): |
357 | 1261 | self.config["PROJECT"] = "ubuntu" | 1311 | self.config["PROJECT"] = "ubuntu" |
358 | 1262 | self.config["DIST"] = "trusty" | 1312 | self.config["DIST"] = "trusty" |
Rebased on trunk, could you please review? Thanks