Merge ~pelpsi/launchpad:oval-data-ajust-indexing-code into launchpad:master

Proposed by Simone Pelosi
Status: Merged
Approved by: Simone Pelosi
Approved revision: 60c404b847e81adac53dfd09b0ba1e9eb0df512b
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pelpsi/launchpad:oval-data-ajust-indexing-code
Merge into: launchpad:master
Diff against target: 79 lines (+57/-0)
2 files modified
lib/lp/archivepublisher/publishing.py (+9/-0)
lib/lp/archivepublisher/tests/test_publisher.py (+48/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+439832@code.launchpad.net

Commit message

Adjusted indexing code to include OVAL files

Now _writeSuite function supports OVAL data in various formats.
Added new test case for that functionality.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
60c404b... by Simone Pelosi

Used name.encode() rather than six.ensure_binary(name)

six was used as part of the Python 2 to 3 port, and we haven't yet removed all the leftovers of that,
but we don't need to introduce new ones now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py
2index 877ca78..105a393 100644
3--- a/lib/lp/archivepublisher/publishing.py
4+++ b/lib/lp/archivepublisher/publishing.py
5@@ -1468,6 +1468,15 @@ class Publisher:
6 extra_files.add(cnf_path)
7 except FileNotFoundError:
8 pass
9+ oval_dir = os.path.join(suite_dir, component, "oval")
10+ try:
11+ for oval_file in os.listdir(oval_dir):
12+ if ".oval.xml" in oval_file:
13+ oval_path = os.path.join(component, "oval", oval_file)
14+ extra_files.add(remove_suffix(oval_path))
15+ extra_files.add(oval_path)
16+ except FileNotFoundError:
17+ pass
18 for architecture in all_architectures:
19 for contents_path in get_suffixed_indices(
20 "Contents-" + architecture
21diff --git a/lib/lp/archivepublisher/tests/test_publisher.py b/lib/lp/archivepublisher/tests/test_publisher.py
22index 46556e3..c7bbea7 100644
23--- a/lib/lp/archivepublisher/tests/test_publisher.py
24+++ b/lib/lp/archivepublisher/tests/test_publisher.py
25@@ -2483,6 +2483,54 @@ class TestPublisher(TestPublisherBase):
26 release, "Contents-i386.gz", contents_file.read()
27 )
28
29+ def testReleaseFileForOval(self):
30+ # Test Release file writing for Oval metadata.
31+ publisher = Publisher(
32+ self.logger,
33+ self.config,
34+ self.disk_pool,
35+ self.ubuntutest.main_archive,
36+ )
37+
38+ # Put some Oval metadata files in place, and force the publisher
39+ # to republish that suite.
40+ series_path = os.path.join(self.config.distsroot, "breezy-autotest")
41+ oval_path = os.path.join(series_path, "main", "oval")
42+ oval_names = (
43+ "data1.oval.xml.gz",
44+ "data2.oval.xml.bz2",
45+ "data3.oval.xml",
46+ "data4.oval.xml.bz2",
47+ )
48+ os.makedirs(oval_path)
49+ for name in oval_names:
50+ if name.endswith(".gz"):
51+ with gzip.GzipFile(os.path.join(oval_path, name), "wb") as f:
52+ f.write(name.encode())
53+ elif name.endswith(".bz2"):
54+ with bz2.open(os.path.join(oval_path, name), "wb") as f:
55+ f.write(name.encode())
56+ else:
57+ with open(os.path.join(oval_path, name), "wb") as f:
58+ f.write(name.encode())
59+
60+ publisher.markSuiteDirty(
61+ self.ubuntutest.getSeries("breezy-autotest"),
62+ PackagePublishingPocket.RELEASE,
63+ )
64+
65+ publisher.A_publish(False)
66+ publisher.C_doFTPArchive(False)
67+ publisher.D_writeReleaseFiles(False)
68+
69+ # The metadata files are listed correctly in Release.
70+ release = self.parseRelease(os.path.join(series_path, "Release"))
71+ for name in oval_names:
72+ with open(os.path.join(oval_path, name), "rb") as f:
73+ self.assertReleaseContentsMatch(
74+ release, os.path.join("main", "oval", name), f.read()
75+ )
76+
77 def testReleaseFileForDEP11(self):
78 # Test Release file writing for DEP-11 metadata.
79 publisher = Publisher(

Subscribers

People subscribed via source and target branches

to status/vote changes: