Merge lp:~doanac/linaro-license-protection/prebuilt-support into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Andy Doan
Status: Merged
Merged at revision: 52
Proposed branch: lp:~doanac/linaro-license-protection/prebuilt-support
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 90 lines (+39/-3)
2 files modified
scripts/publish_to_snapshots.py (+9/-2)
testing/test_publish_to_snapshots.py (+30/-1)
To merge this branch: bzr merge lp:~doanac/linaro-license-protection/prebuilt-support
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) Approve
Review via email: mp+99776@code.launchpad.net

Description of the change

This allows pre-built images to be published

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

found a small bug. I need to fix before this can be merged.

51. By Andy Doan

fix layout issue for prebuilt

The original commit for pre-built layouts assumed jenkins could
pass something like 20120328. This isn't known by jenkins so we
instead change the layout to use jobname and build number.

Revision history for this message
Andy Doan (doanac) wrote :

> found a small bug. I need to fix before this can be merged.
Its been fixed by commit 51. Code is ready for review again.

Revision history for this message
Guilherme Salgado (salgado) wrote :

It looks reasonable to me. Can you add a test for it in testing/test_publish_to_snapshots.py? From what I can tell it should be easy but if it turns out to be tricky we can file a bug to have one added later.

review: Approve
52. By Andy Doan

add test code for prebuilt

Revision history for this message
Andy Doan (doanac) wrote :

On 03/28/2012 01:07 PM, Guilherme Salgado wrote:
> Review: Approve
>
> It looks reasonable to me. Can you add a test for it in testing/test_publish_to_snapshots.py? From what I can tell it should be easy but if it turns out to be tricky we can file a bug to have one added later.

test case added.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/publish_to_snapshots.py'
2--- scripts/publish_to_snapshots.py 2012-03-26 10:45:51 +0000
3+++ scripts/publish_to_snapshots.py 2012-03-28 19:50:23 +0000
4@@ -26,6 +26,7 @@
5 acceptable_job_types = [
6 'android',
7 'kernel-hwpack',
8+ 'prebuilt'
9 ]
10
11 class SnapshotsPublisher(object):
12@@ -48,7 +49,9 @@
13 ret_val = jobname.split("_")
14 elif args.job_type == "kernel-hwpack":
15 ret_val = jobname.split('_')[0].replace(".", "_")
16- return ret_val
17+ elif args.job_type == "prebuilt":
18+ ret_val = '' #just need non-null since its isn't needed
19+ return ret_val
20
21 def validate_paths(self, args, uploads_path, target_path):
22 build_dir_path = target_dir_path = None
23@@ -71,6 +74,10 @@
24 target_dir = '/'.join([args.job_type, kernel_tree,
25 args.job_name])
26 target_dir_path = os.path.join(target_path, target_dir)
27+ elif args.job_type == "prebuilt":
28+ build_path = '%s/%d' % (args.job_name, args.build_num)
29+ build_dir_path = os.path.join(uploads_path, build_path)
30+ target_dir_path = target_path
31 else:
32 return None, None
33
34@@ -155,7 +162,7 @@
35
36 self.move_dir_content(build_dir_path, target_dir_path)
37
38- if args.job_type != "kernel-hwpack":
39+ if args.job_type == "android":
40 ret = self.create_symlink(target_dir_path)
41 if ret != PASS:
42 return ret
43
44=== modified file 'testing/test_publish_to_snapshots.py'
45--- testing/test_publish_to_snapshots.py 2012-03-26 11:27:06 +0000
46+++ testing/test_publish_to_snapshots.py 2012-03-28 19:50:23 +0000
47@@ -47,6 +47,10 @@
48 '-n', '1'])
49 self.publisher.validate_args(param)
50
51+ param = self.parser.parse_args(['-t', 'prebuilt', '-j', 'dummy_job_name',
52+ '-n', '1'])
53+ self.publisher.validate_args(param)
54+
55 def test_validate_args_invalid_job_type(self):
56 orig_stderr = sys.stderr
57 stderr = sys.stderr = StringIO()
58@@ -183,7 +187,32 @@
59 finally:
60 sys.stdout = orig_stdout
61 pass
62-
63+
64+ stdout.seek(0)
65+ self.assertIn("Moved the files from", stdout.read())
66+
67+ def test_move_artifacts_prebuilt_successful_move(self):
68+ orig_stdout = sys.stdout
69+ stdout = sys.stdout = StringIO()
70+ self.publisher = SnapshotsPublisher()
71+ param = self.parser.parse_args(['-t', 'prebuilt', '-j', 'dummy_job_name',
72+ '-n', '1'])
73+ self.publisher.validate_args(param)
74+ build_dir = '/'.join([param.job_name, str(param.build_num)])
75+ build_path = os.path.join(self.uploads_path, build_dir,'oneiric')
76+ os.makedirs(build_path)
77+ tempfiles = tempfile.mkstemp(dir=build_path)
78+ try:
79+ uploads_dir_path, target_dir_path = self.publisher.validate_paths(param,
80+ self.uploads_path, self.target_path)
81+ uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
82+ target_dir_path = os.path.join(self.orig_dir, target_dir_path)
83+ orig_stdout.write("andy: (%s) (%s)\n" % (uploads_dir_path, target_dir_path))
84+ self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)
85+ finally:
86+ sys.stdout = orig_stdout
87+ pass
88+
89 stdout.seek(0)
90 self.assertIn("Moved the files from", stdout.read())
91

Subscribers

People subscribed via source and target branches