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.
Para Siva (psivaa) wrote :

LGTM

review: Approve
Francis Ginther (fginther) wrote :

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

review: Needs Fixing
30. By Celso Providelo on 2015-04-08

'test_branch_revno' in the results metadata too.

Celso Providelo (cprov) wrote :

Francis & Psivaa,

Thanks for the review, r30 addresses your comments.

Francis Ginther (fginther) wrote :

Approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'core_image_tester/worker.py'
2--- core_image_tester/worker.py 2015-04-08 00:07:26 +0000
3+++ core_image_tester/worker.py 2015-04-08 16:18:36 +0000
4@@ -19,6 +19,7 @@
5 import logging
6 import os
7 import shutil
8+import subprocess
9 import tarfile
10 import tempfile
11
12@@ -62,12 +63,16 @@
13
14 with tempfile.TemporaryDirectory() as test_dir:
15 logger.info("Downloading test sources...", extra=extra)
16+ test_branch = self.config['adt']['test_branch']
17 try:
18- get_test_sources(test_dir, self.config['adt']['test_branch'])
19+ get_test_sources(test_dir, test_branch)
20 except utils.BetterCalledProcessError as e:
21 logger.error("Unable to retrieve test sources: %s",
22 e, extra=extra)
23 return MessageActions.Retry
24+ body['test_branch'] = test_branch
25+ body['test_branch_revno'] = get_test_sources_revno(test_branch)
26+ extra.update(body)
27 logger.info("Test sources downloaded OK.", extra=extra)
28
29 with tempfile.TemporaryDirectory() as result_dir:
30@@ -85,6 +90,7 @@
31 e, extra=extra)
32 return MessageActions.Retry
33 body['exit_code'] = exit_code
34+ extra.update(body)
35 logger.info(
36 "Autopkgtest completed with exit code %s.",
37 exit_code,
38@@ -142,6 +148,8 @@
39 key_whitelist = [
40 'channel',
41 'device',
42+ 'test_branch',
43+ 'test_branch_revno',
44 'exit_code',
45 'nova_image_id',
46 'image_name',
47@@ -153,6 +161,19 @@
48 outfile.write("{}\t{}\n".format(key, request[key]))
49
50
51+def get_test_sources_revno(test_branch):
52+ """Return the current 'test_branch' revision number.
53+
54+ Errors are explicitly ignored and '-' is returned as revno.
55+ """
56+ try:
57+ out = subprocess.check_output(['bzr', 'revno', test_branch])
58+ except subprocess.CalledProcessError:
59+ return '-'
60+
61+ return out.strip()
62+
63+
64 def get_test_sources(target_dir, test_branch):
65 """Copy the test sources into the target_dir.
66

Subscribers

People subscribed via source and target branches