Merge lp:~cprov/core-image-tester/message-test-branch into lp:core-image-tester

Proposed by Celso Providelo
Status: Merged
Approved by: Francis Ginther
Approved revision: 30
Merged at revision: 29
Proposed branch: lp:~cprov/core-image-tester/message-test-branch
Merge into: lp:core-image-tester
Diff against target: 65 lines (+22/-1)
1 file modified
core_image_tester/worker.py (+22/-1)
To merge this branch: bzr merge lp:~cprov/core-image-tester/message-test-branch
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Para Siva (community) Approve
Review via email: mp+255520@code.launchpad.net

Commit message

Recording 'test_branch' and 'test_branch_revno' in the request message. This way we will be able to completely reproduce the testing experience after the testing attempt (up to the deadletter queue).

Description of the change

Recording 'test_branch' and 'test_branch_revno' in the request message. This way we will be able to completely reproduce the testing experience after the testing attempt (up to the deadletter queue).

To post a comment you must log in.
Revision history for this message
Para Siva (psivaa) wrote :

LGTM

review: Approve
Revision history for this message
Francis Ginther (fginther) wrote :

I think we should also add the test_branch_revno to the metadata.

review: Needs Fixing
30. By Celso Providelo

'test_branch_revno' in the results metadata too.

Revision history for this message
Celso Providelo (cprov) wrote :

Francis & Psivaa,

Thanks for the review, r30 addresses your comments.

Revision history for this message
Francis Ginther (fginther) wrote :

Approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'core_image_tester/worker.py'
--- core_image_tester/worker.py 2015-04-08 00:07:26 +0000
+++ core_image_tester/worker.py 2015-04-08 16:18:36 +0000
@@ -19,6 +19,7 @@
19import logging19import logging
20import os20import os
21import shutil21import shutil
22import subprocess
22import tarfile23import tarfile
23import tempfile24import tempfile
2425
@@ -62,12 +63,16 @@
6263
63 with tempfile.TemporaryDirectory() as test_dir:64 with tempfile.TemporaryDirectory() as test_dir:
64 logger.info("Downloading test sources...", extra=extra)65 logger.info("Downloading test sources...", extra=extra)
66 test_branch = self.config['adt']['test_branch']
65 try:67 try:
66 get_test_sources(test_dir, self.config['adt']['test_branch'])68 get_test_sources(test_dir, test_branch)
67 except utils.BetterCalledProcessError as e:69 except utils.BetterCalledProcessError as e:
68 logger.error("Unable to retrieve test sources: %s",70 logger.error("Unable to retrieve test sources: %s",
69 e, extra=extra)71 e, extra=extra)
70 return MessageActions.Retry72 return MessageActions.Retry
73 body['test_branch'] = test_branch
74 body['test_branch_revno'] = get_test_sources_revno(test_branch)
75 extra.update(body)
71 logger.info("Test sources downloaded OK.", extra=extra)76 logger.info("Test sources downloaded OK.", extra=extra)
7277
73 with tempfile.TemporaryDirectory() as result_dir:78 with tempfile.TemporaryDirectory() as result_dir:
@@ -85,6 +90,7 @@
85 e, extra=extra)90 e, extra=extra)
86 return MessageActions.Retry91 return MessageActions.Retry
87 body['exit_code'] = exit_code92 body['exit_code'] = exit_code
93 extra.update(body)
88 logger.info(94 logger.info(
89 "Autopkgtest completed with exit code %s.",95 "Autopkgtest completed with exit code %s.",
90 exit_code,96 exit_code,
@@ -142,6 +148,8 @@
142 key_whitelist = [148 key_whitelist = [
143 'channel',149 'channel',
144 'device',150 'device',
151 'test_branch',
152 'test_branch_revno',
145 'exit_code',153 'exit_code',
146 'nova_image_id',154 'nova_image_id',
147 'image_name',155 'image_name',
@@ -153,6 +161,19 @@
153 outfile.write("{}\t{}\n".format(key, request[key]))161 outfile.write("{}\t{}\n".format(key, request[key]))
154162
155163
164def get_test_sources_revno(test_branch):
165 """Return the current 'test_branch' revision number.
166
167 Errors are explicitly ignored and '-' is returned as revno.
168 """
169 try:
170 out = subprocess.check_output(['bzr', 'revno', test_branch])
171 except subprocess.CalledProcessError:
172 return '-'
173
174 return out.strip()
175
176
156def get_test_sources(target_dir, test_branch):177def get_test_sources(target_dir, test_branch):
157 """Copy the test sources into the target_dir.178 """Copy the test sources into the target_dir.
158179

Subscribers

People subscribed via source and target branches