Merge lp:~cprov/snappy-proposed-selftest-agent/source-binaries into lp:snappy-proposed-selftest-agent

Proposed by Celso Providelo
Status: Merged
Approved by: Celso Providelo
Approved revision: 15
Merged at revision: 14
Proposed branch: lp:~cprov/snappy-proposed-selftest-agent/source-binaries
Merge into: lp:snappy-proposed-selftest-agent
Diff against target: 106 lines (+36/-23)
2 files modified
snappy_proposed_selftest_agent/tests/test_worker.py (+16/-3)
snappy_proposed_selftest_agent/worker.py (+20/-20)
To merge this branch: bzr merge lp:~cprov/snappy-proposed-selftest-agent/source-binaries
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+260573@code.launchpad.net

Commit message

Using 'source_binaries' payload provided by Britney.

Description of the change

Using 'source_binaries' payload provided by Britney from https://code.launchpad.net/~cprov/britney/source-binaries/+merge/260540

To post a comment you must log in.
15. By Celso Providelo

Including 'image_binaries' in the payload, to be zipped with 'source_version' in the image-builder to ensure the rootfs contains the required binaries for this test.

Revision history for this message
Paul Larson (pwlars) wrote :

This looks great, thanks! +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy_proposed_selftest_agent/tests/test_worker.py'
2--- snappy_proposed_selftest_agent/tests/test_worker.py 2015-05-29 01:57:53 +0000
3+++ snappy_proposed_selftest_agent/tests/test_worker.py 2015-05-29 13:41:36 +0000
4@@ -29,7 +29,7 @@
5 mock_fetch_manifest.return_value = {}
6 conn = kombu.Connection('memory:///')
7 queue_message(conn, {'test': 'value',
8- 'source_name': 'foo',
9+ 'source_binaries': ['foo'],
10 'series': 'wily'})
11
12 build_worker = LoggingConsumer()
13@@ -43,9 +43,15 @@
14
15 @mock.patch.object(CoreSelftestAgentWorker, '_fetch_manifest')
16 def test_package_in_manifest(self, mock_fetch_manifest):
17- mock_fetch_manifest.return_value = {'foo': '1.0'}
18+ mock_fetch_manifest.return_value = {
19+ 'foo': '1.0',
20+ 'bar': '1.0',
21+ }
22 conn = kombu.Connection('memory:///')
23- queue_message(conn, {'source_name': 'foo', 'series': 'wily'})
24+ queue_message(conn, {
25+ 'source_binaries': ['foo', 'bar', 'baz'],
26+ 'series': 'wily',
27+ })
28 build_worker = LoggingConsumer()
29 result_worker = LoggingConsumer()
30 config = read_config()
31@@ -56,6 +62,13 @@
32 build_worker.messages_seen[0].get('test_name'), 'snappy-selftest')
33 self.assertEqual(
34 result_worker.messages_seen[0].get('test_name'), 'snappy-selftest')
35+ # 'image_binaries' payload contains a list of binaries produced
36+ # by the source candidate and mentioned on the image manifest. It
37+ # should be zipped with the 'source_version' to ensure the correct
38+ # binaries are installed in the testing 'rootfs'.
39+ self.assertEqual(
40+ ['foo', 'bar'],
41+ build_worker.messages_seen[0].get('image_binaries'))
42
43
44 class LoggingConsumer(object):
45
46=== modified file 'snappy_proposed_selftest_agent/worker.py'
47--- snappy_proposed_selftest_agent/worker.py 2015-05-29 02:07:03 +0000
48+++ snappy_proposed_selftest_agent/worker.py 2015-05-29 13:41:36 +0000
49@@ -62,30 +62,29 @@
50 extra=constants.LOGGING_EXTRA)
51 return None
52
53- def check_package(self, body):
54- """Check if we need to handle this package or not."""
55-
56- release = constants.RELEASE_MAP[constants.RELEASE]
57- source_series = body['series']
58- source_name = body['source_name']
59- arch = constants.ARCH
60-
61- if source_series != release:
62- # This is not the series we are looking for
63- return False
64-
65- manifest = self._fetch_manifest(release, arch)
66- if source_name in manifest:
67- # This package is one we need to test
68- return True
69- else:
70- return False
71+ def get_manifest_binaries(self, binaries, series, arch):
72+ """Yields binary names mentioned in the corresponding manifest."""
73+ manifest = self._fetch_manifest(series, arch)
74+ for binary in binaries:
75+ if binary in manifest:
76+ yield binary
77
78 def process(self, body, message):
79 """ Process incoming messages about candidate packages """
80+ # Dismiss if it's not the series (derived from ubuntu 'release')
81+ # this agent cares about.
82+ context_series = constants.RELEASE_MAP[constants.RELEASE]
83+ if context_series != body['series']:
84+ message.ack()
85+ return
86
87- if not self.check_package(body):
88- # If we don't have this package in our channel/image, just exit
89+ # If no binaries produced by the source candidate are mentioned
90+ # in the image manifest, it does not need testing.
91+ image_binaries = list(
92+ self.get_manifest_binaries(
93+ body['source_binaries'], context_series, constants.ARCH)
94+ )
95+ if not image_binaries:
96 message.ack()
97 return
98
99@@ -101,6 +100,7 @@
100 'channel': constants.CHANNEL,
101 'release': constants.RELEASE,
102 'device': constants.DEVICE,
103+ 'image_binaries': image_binaries,
104 'test_name': constants.TEST_NAME,
105 'test_status': 'RUNNING',
106 # XXX cprov 20150528: this context can't possibly set the

Subscribers

People subscribed via source and target branches