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
=== modified file 'scripts/publish_to_snapshots.py'
--- scripts/publish_to_snapshots.py 2012-03-26 10:45:51 +0000
+++ scripts/publish_to_snapshots.py 2012-03-28 19:50:23 +0000
@@ -26,6 +26,7 @@
26acceptable_job_types = [26acceptable_job_types = [
27 'android',27 'android',
28 'kernel-hwpack',28 'kernel-hwpack',
29 'prebuilt'
29 ]30 ]
3031
31class SnapshotsPublisher(object):32class SnapshotsPublisher(object):
@@ -48,7 +49,9 @@
48 ret_val = jobname.split("_") 49 ret_val = jobname.split("_")
49 elif args.job_type == "kernel-hwpack":50 elif args.job_type == "kernel-hwpack":
50 ret_val = jobname.split('_')[0].replace(".", "_")51 ret_val = jobname.split('_')[0].replace(".", "_")
51 return ret_val 52 elif args.job_type == "prebuilt":
53 ret_val = '' #just need non-null since its isn't needed
54 return ret_val
5255
53 def validate_paths(self, args, uploads_path, target_path):56 def validate_paths(self, args, uploads_path, target_path):
54 build_dir_path = target_dir_path = None57 build_dir_path = target_dir_path = None
@@ -71,6 +74,10 @@
71 target_dir = '/'.join([args.job_type, kernel_tree, 74 target_dir = '/'.join([args.job_type, kernel_tree,
72 args.job_name])75 args.job_name])
73 target_dir_path = os.path.join(target_path, target_dir)76 target_dir_path = os.path.join(target_path, target_dir)
77 elif args.job_type == "prebuilt":
78 build_path = '%s/%d' % (args.job_name, args.build_num)
79 build_dir_path = os.path.join(uploads_path, build_path)
80 target_dir_path = target_path
74 else:81 else:
75 return None, None82 return None, None
7683
@@ -155,7 +162,7 @@
155162
156 self.move_dir_content(build_dir_path, target_dir_path)163 self.move_dir_content(build_dir_path, target_dir_path)
157164
158 if args.job_type != "kernel-hwpack":165 if args.job_type == "android":
159 ret = self.create_symlink(target_dir_path)166 ret = self.create_symlink(target_dir_path)
160 if ret != PASS:167 if ret != PASS:
161 return ret168 return ret
162169
=== modified file 'testing/test_publish_to_snapshots.py'
--- testing/test_publish_to_snapshots.py 2012-03-26 11:27:06 +0000
+++ testing/test_publish_to_snapshots.py 2012-03-28 19:50:23 +0000
@@ -47,6 +47,10 @@
47 '-n', '1'])47 '-n', '1'])
48 self.publisher.validate_args(param)48 self.publisher.validate_args(param)
4949
50 param = self.parser.parse_args(['-t', 'prebuilt', '-j', 'dummy_job_name',
51 '-n', '1'])
52 self.publisher.validate_args(param)
53
50 def test_validate_args_invalid_job_type(self):54 def test_validate_args_invalid_job_type(self):
51 orig_stderr = sys.stderr55 orig_stderr = sys.stderr
52 stderr = sys.stderr = StringIO()56 stderr = sys.stderr = StringIO()
@@ -183,7 +187,32 @@
183 finally:187 finally:
184 sys.stdout = orig_stdout188 sys.stdout = orig_stdout
185 pass189 pass
186 190
191 stdout.seek(0)
192 self.assertIn("Moved the files from", stdout.read())
193
194 def test_move_artifacts_prebuilt_successful_move(self):
195 orig_stdout = sys.stdout
196 stdout = sys.stdout = StringIO()
197 self.publisher = SnapshotsPublisher()
198 param = self.parser.parse_args(['-t', 'prebuilt', '-j', 'dummy_job_name',
199 '-n', '1'])
200 self.publisher.validate_args(param)
201 build_dir = '/'.join([param.job_name, str(param.build_num)])
202 build_path = os.path.join(self.uploads_path, build_dir,'oneiric')
203 os.makedirs(build_path)
204 tempfiles = tempfile.mkstemp(dir=build_path)
205 try:
206 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param,
207 self.uploads_path, self.target_path)
208 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
209 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
210 orig_stdout.write("andy: (%s) (%s)\n" % (uploads_dir_path, target_dir_path))
211 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)
212 finally:
213 sys.stdout = orig_stdout
214 pass
215
187 stdout.seek(0)216 stdout.seek(0)
188 self.assertIn("Moved the files from", stdout.read())217 self.assertIn("Moved the files from", stdout.read())
189218

Subscribers

People subscribed via source and target branches