Merge lp:~danilo/linaro-license-protection/cleanups into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Данило Шеган
Status: Merged
Approved by: Данило Шеган
Approved revision: 82
Merged at revision: 76
Proposed branch: lp:~danilo/linaro-license-protection/cleanups
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 1011 lines (+262/-198)
11 files modified
.bzrignore (+1/-0)
.testr.conf (+1/-1)
README (+49/-24)
scripts/do_if_old.py (+2/-0)
scripts/publish_to_snapshots.py (+58/-50)
testplans/releases.txt (+1/-1)
testplans/snapshots.txt (+1/-1)
tests/__init__.py (+3/-7)
tests/test_click_through_license.py (+11/-6)
tests/test_php_unit.py (+4/-1)
tests/test_publish_to_snapshots.py (+131/-107)
To merge this branch: bzr merge lp:~danilo/linaro-license-protection/cleanups
Reviewer Review Type Date Requested Status
Deepti B. Kalakeri (community) Approve
Review via email: mp+106249@code.launchpad.net

Description of the change

Move testing/ to tests/, clean up code to pass pep8/pyflakes and improve the README.

To post a comment you must log in.
Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :
Download full text (49.5 KiB)

I am not able to run the tests successfully and it fails with the following
error:

AttributeError: 'module' object has no attribute 'test_php_unit'

This is same with the latest linaro-license-protection as well.
Also, I tried the testplan testing instructions given in the README, but it
fails with the same error.

PS: I tested this on Natty, so might be specific to my case.

Between I did not like the alignment in the following lines:
=== modified file 'scripts/publish_to_snapshots.py'
--- scripts/publish_to_snapshots.py 2012-05-17 19:13:54 +0000
+++ scripts/publish_to_snapshots.py 2012-05-18 07:34:37 +0000
@@ -119,9 +119,9 @@
                 timestamp = f.read().strip()
                 f.close()
                 os.remove(ts_file)
- target_dir_path = os.path.join(
- target_path, 'android', args.job_type, ret_val[0],
- timestamp)

We could probably change it to
+ target_dir_path = os.path.join(target_path, 'android',
+ args.job_type, ret_val[0],
+ timestamp)
         else:

On Fri, May 18, 2012 at 1:31 AM, Данило Шеган <email address hidden> wrote:

> Данило Шеган has proposed merging
> lp:~danilo/linaro-license-protection/cleanups into
> lp:linaro-license-protection.
>
> Requested reviews:
> Linaro Infrastructure (linaro-infrastructure)
>
> For more details, see:
>
> https://code.launchpad.net/~danilo/linaro-license-protection/cleanups/+merge/106249<https://code.launchpad.net/%7Edanilo/linaro-license-protection/cleanups/+merge/106249>
>
> Move testing/ to tests/, clean up code to pass pep8/pyflakes and improve
> the README.
> --
>
> https://code.launchpad.net/~danilo/linaro-license-protection/cleanups/+merge/106249<https://code.launchpad.net/%7Edanilo/linaro-license-protection/cleanups/+merge/106249>
> Your team Linaro Infrastructure is requested to review the proposed merge
> of lp:~danilo/linaro-license-protection/cleanups into
> lp:linaro-license-protection.
>
> === added file '.bzrignore'
> --- .bzrignore 1970-01-01 00:00:00 +0000
> +++ .bzrignore 2012-05-17 20:00:28 +0000
> @@ -0,0 +1,1 @@
> +.testrepository
>
> === modified file '.testr.conf'
> --- .testr.conf 2012-01-12 14:07:05 +0000
> +++ .testr.conf 2012-05-17 20:00:28 +0000
> @@ -1,3 +1,3 @@
> [DEFAULT]
> test_command=python -m subunit.run $IDLIST
> -test_id_list_default=testing.test_suite
> +test_id_list_default=tests.test_suite
>
> === modified file 'README'
> --- README 2012-05-17 12:37:39 +0000
> +++ README 2012-05-17 20:00:28 +0000
> @@ -1,19 +1,31 @@
> Linaro downloads license protection
> ===================================
>
> -Linaro builds sometimes contain "binary blobs"—pieces of binary-only code
> which enable extra features like accelerated graphics or multimedia. These
> pieces are distributed under a separate license, and downloading images or
> collections containing them requires some sort of license protection.
> -
> -This code provides such license protection on the hosting web server:
> other parts of infrastructure need to properly integrate with it (see eg.
> android-build...

Revision history for this message
Данило Шеган (danilo) wrote :

Deepti, what Python version is on natty (I assume 2.6)?

As for indentation, I believe this reads much better, since the lines tend to be long.

Revision history for this message
Georgy Redkozubov (gesha) wrote :

> I am not able to run the tests successfully and it fails with the following
> error:
>
> AttributeError: 'module' object has no attribute 'test_php_unit'
>
> This is same with the latest linaro-license-protection as well.
> Also, I tried the testplan testing instructions given in the README, but it
> fails with the same error.
>
> PS: I tested this on Natty, so might be specific to my case.

It works on Precise, all tests passed.

Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :

On Fri, May 18, 2012 at 1:25 PM, Данило Шеган <email address hidden> wrote:

> Deepti, what Python version is on natty (I assume 2.6)?
>

No its python 2.7. Are we suppose to verify this only on precise or the
test needs to be backward compatible as well ?

>
> As for indentation, I believe this reads much better, since the lines tend
> to be long.
>

ok, if you say so, everything else looks ok. +1

> --
>
> https://code.launchpad.net/~danilo/linaro-license-protection/cleanups/+merge/106249<https://code.launchpad.net/%7Edanilo/linaro-license-protection/cleanups/+merge/106249>
> Your team Linaro Infrastructure is requested to review the proposed merge
> of lp:~danilo/linaro-license-protection/cleanups into
> lp:linaro-license-protection.
>

--
Thanks and Regards,
Deepti

Revision history for this message
Stevan Radaković (stevanr) wrote :

On 05/18/2012 09:56 AM, Georgy Redkozubov wrote:
>> I am not able to run the tests successfully and it fails with the following
>> error:
>>
>> AttributeError: 'module' object has no attribute 'test_php_unit'
>>
>> This is same with the latest linaro-license-protection as well.
>> Also, I tried the testplan testing instructions given in the README, but it
>> fails with the same error.
>>
>> PS: I tested this on Natty, so might be specific to my case.
> It works on Precise, all tests passed.

What gesha said. I run precise as well.

Revision history for this message
Данило Шеган (danilo) wrote :

I've tried it on Lucid as well (with Python 2.6), and there are a few problems:
 - more dependencies are needed (will update the README)
 - testtools and testrepository that come with it are too old
 - unittest requires modules to be imported in tests/__init__.py, which is not required with the version coming with Python 2.7.

Since we are not using distribution-provided versions of testtools and testrepository anyway, I'll build the latest versions for Lucid and try it out. If that is not sufficient, I'll claim we require Python 2.7 :)

Revision history for this message
Данило Шеган (danilo) wrote :

Deepti, for indentation, see the http://www.python.org/dev/peps/pep-0008/#indentation (both are acceptable according to PEP-8).

More recent testtools and testrepository depend on Python 2.7, so I'll up that dependency in our docs as well.

82. By Данило Шеган

Update the dependencies to require Python 2.7.

Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :

On Fri, May 18, 2012 at 1:58 PM, Данило Шеган <email address hidden> wrote:

> Deepti, for indentation, see the
> http://www.python.org/dev/peps/pep-0008/#indentation (both are acceptable
> according to PEP-8).
>
> More recent testtools and testrepository depend on Python 2.7, so I'll up
> that dependency in our docs as well.
>

Sounds good.

> --
>
> https://code.launchpad.net/~danilo/linaro-license-protection/cleanups/+merge/106249<https://code.launchpad.net/%7Edanilo/linaro-license-protection/cleanups/+merge/106249>
> Your team Linaro Infrastructure is requested to review the proposed merge
> of lp:~danilo/linaro-license-protection/cleanups into
> lp:linaro-license-protection.
>

--
Thanks and Regards,
Deepti

Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :

+1 Approved.

Thanks!!!
Deepti

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.bzrignore'
--- .bzrignore 1970-01-01 00:00:00 +0000
+++ .bzrignore 2012-05-18 08:34:31 +0000
@@ -0,0 +1,1 @@
1.testrepository
02
=== modified file '.testr.conf'
--- .testr.conf 2012-01-12 14:07:05 +0000
+++ .testr.conf 2012-05-18 08:34:31 +0000
@@ -1,3 +1,3 @@
1[DEFAULT]1[DEFAULT]
2test_command=python -m subunit.run $IDLIST2test_command=python -m subunit.run $IDLIST
3test_id_list_default=testing.test_suite3test_id_list_default=tests.test_suite
44
=== modified file 'README'
--- README 2012-05-17 12:37:39 +0000
+++ README 2012-05-18 08:34:31 +0000
@@ -1,26 +1,47 @@
1Linaro downloads license protection1Linaro downloads license protection
2===================================2===================================
33
4Linaro builds sometimes contain "binary blobs"—pieces of binary-only code which enable extra features like accelerated graphics or multimedia. These pieces are distributed under a separate license, and downloading images or collections containing them requires some sort of license protection.4Linaro builds sometimes contain "binary blobs"—pieces of binary-only code
55which enable extra features like accelerated graphics or multimedia.
6This code provides such license protection on the hosting web server: other parts of infrastructure need to properly integrate with it (see eg. android-build.linaro.org section). At the moment, it's implemented as a click-through license acceptance on the Apache side.6These pieces are distributed under a separate license, and downloading
77images or collections containing them requires some sort of license
8To ensure and prove this keeps working, we are also using automated tests with this code.8protection.
9
10This code provides such license protection on the hosting web server:
11other parts of infrastructure need to properly integrate with it (see
12eg. android-build.linaro.org section). At the moment, it's implemented as
13a click-through license acceptance on the Apache side.
14
15To ensure and prove this keeps working, we are also using automated tests
16with this code.
917
1018
11Setup19Setup
12-----20-----
1321
14This tree is the base for snapshots.linaro.org and releases.linaro.org www roots as served by Apache. It makes heavy use of mod_rewrite from within the .htaccess file.22This tree is the base for snapshots.linaro.org and releases.linaro.org www
23roots as served by Apache. It makes heavy use of mod_rewrite from within
24the .htaccess file.
1525
16Currently, all directories/files containing either 'origen' or 'snowball' in the URL path are protected with appropriate license (Samsung or ST-E) click-through.26Currently, all directories/files containing either 'origen' or 'snowball'
27in the URL path are protected with appropriate license (Samsung or ST-E)
28click-through.
1729
18Dependencies30Dependencies
19............31............
2032
21libapache2-mod-php533libapache2-mod-php5
2234
23Testing: phpunit, testrepository, python-html2text35Testing:
36 phpunit, python 2.7, testrepository (>=0.0.6), python-html2text,
37 python-subunit, python-beautifulsoup
38
39Recent (as of 2012-05-08) Ubuntu/Debian releases have a broken phpunit
40package and thus require installation of phpunit through PEAR:
41
42 $ sudo apt-get install php-pear
43 $ sudo pear config-set auto_discover 1
44 $ sudo pear install pear.phpunit.de/PHPUnit
2445
2546
26Technical details47Technical details
@@ -32,7 +53,9 @@
32Root directory for releases.linaro.org includes .htaccess and licenses/*.53Root directory for releases.linaro.org includes .htaccess and licenses/*.
33It has mod_rewrite enabled.54It has mod_rewrite enabled.
3455
35It allows a few hard-coded hosts to bypass the click-through protection, by their IPs:56It allows a few hard-coded hosts to bypass the click-through protection,
57by their IPs:
58
36 * android-build.linaro.org (50.17.250.69)59 * android-build.linaro.org (50.17.250.69)
37 * validation.linaro.org (213.123.120.124)60 * validation.linaro.org (213.123.120.124)
3861
@@ -57,7 +80,8 @@
57 limited to executing only a single command through80 limited to executing only a single command through
58 /etc/ssh/user-authorized-keys/android-build-linaro-trigger81 /etc/ssh/user-authorized-keys/android-build-linaro-trigger
5982
60 command="/home/android-build-linaro-trigger/scripts/trigger-android-build-linaro.sh ${SSH_ORIGINAL_COMMAND#* }"83 command="/home/android-build-linaro-trigger/scripts
84 /trigger-android-build-linaro.sh ${SSH_ORIGINAL_COMMAND#* }"
6185
62 (this passes the arguments received from the remote end as well)86 (this passes the arguments received from the remote end as well)
6387
@@ -72,7 +96,8 @@
72android-build.linaro.org96android-build.linaro.org
73........................97........................
7498
75Runs Jenkins and uses SFTP plugin to access the above two users. Private keys live in99Runs Jenkins and uses SFTP plugin to access the above two users. Private
100keys live in
76101
77 /home/ubuntu/snapshots-sync/snapshots-sync — android-build-linaro102 /home/ubuntu/snapshots-sync/snapshots-sync — android-build-linaro
78 /home/ubuntu/snapshots-sync/snapshots-filemove — android-build-linaro-trigger103 /home/ubuntu/snapshots-sync/snapshots-filemove — android-build-linaro-trigger
@@ -90,24 +115,24 @@
90 $ testr init115 $ testr init
91 $ testr run116 $ testr run
92117
93To run the production test plans (NOTE: They will take a bit more time to run)118Test plans
94execute the following:119..........
120
121To run the test plans from testplans/ subdirectory against
122snapshots.linaro.org and releases.linaro.org, execute the following:
95123
96 $ testr init124 $ testr init
97 $ testr run testplans.test_suite125 $ testr run testplans.test_suite
98126
127These tests require an internet connection.
99128
100Tests for PHP license-matching logic129Tests for PHP license-matching logic
101....................................130....................................
102131
103There's currently only one unit test file, LicenseHelperTest.php under testing directory. You first need to install the phpunit package from ubuntu repos:132Unit tests for the license-matching logic written in PHP are automatically
104 $ sudo apt-get install php-unit133ran as part of the full test suite (testr run). However, for a more
105134detailed output, you may need to run phpunit directly.
106135
107Recent (as of 2012-05-08) Ubuntu/Debian releases have a broken phpunit package and thus require installation in a different manner:136To run the tests separately, do the following:
108 $ sudo apt-get install php-pear137
109 $ sudo pear config-set auto_discover 1138 $ phpunit tests/LicenseHelperTest
110 $ sudo pear install pear.phpunit.de/PHPUnit
111
112PHPUnit tests execution is already included in the python integration tests, but if you wish to run unit tests separately, do the following:
113 $ phpunit testing/LicenseHelperTest
114139
=== modified file 'scripts/do_if_old.py'
--- scripts/do_if_old.py 2012-01-11 17:31:40 +0000
+++ scripts/do_if_old.py 2012-05-18 08:34:31 +0000
@@ -5,6 +5,7 @@
5import time5import time
6import sys6import sys
77
8
8def search_and_run(root_dir, command, trigger_age_string):9def search_and_run(root_dir, command, trigger_age_string):
9 """Run command on old directories10 """Run command on old directories
1011
@@ -44,6 +45,7 @@
44 if (time.time() - mod_time) > trigger_age_seconds:45 if (time.time() - mod_time) > trigger_age_seconds:
45 os.system(command + " " + path)46 os.system(command + " " + path)
4647
48
47if __name__ == '__main__':49if __name__ == '__main__':
48 """Run command on directories that are older than trigger-age."""50 """Run command on directories that are older than trigger-age."""
4951
5052
=== modified file 'scripts/publish_to_snapshots.py'
--- scripts/publish_to_snapshots.py 2012-05-04 17:44:47 +0000
+++ scripts/publish_to_snapshots.py 2012-05-18 08:34:31 +0000
@@ -9,20 +9,22 @@
9parser = argparse.ArgumentParser()9parser = argparse.ArgumentParser()
10parser.add_argument("-t", "--job-type", dest="job_type",10parser.add_argument("-t", "--job-type", dest="job_type",
11 help="Specify the job type (Ex: android/kernel-hwpack)")11 help="Specify the job type (Ex: android/kernel-hwpack)")
12parser.add_argument("-j", "--job-name", dest="job_name",12parser.add_argument(
13 help="Specify the job name which resulted the archive to "\13 "-j", "--job-name", dest="job_name",
14 "be stored. Ex: ${JOB_NAME} should be specified for "\14 help=("Specify the job name which resulted the archive to "
15 "android/ubuntu-{hwpacks,images,sysroots}/binaries and for"\15 "be stored. Ex: ${JOB_NAME} should be specified for "
16 "kernel-hwpack ${KERNEL_JOB_NAME}")16 "android/ubuntu-{hwpacks,images,sysroots}/binaries and for"
17parser.add_argument("-n", "--build-num", dest="build_num", type=int,17 "kernel-hwpack ${KERNEL_JOB_NAME}"))
18 help="Specify the job build number for android/"\18parser.add_argument(
19 "ubuntu-{hwpacks,images,sysroots}/binaries")19 "-n", "--build-num", dest="build_num", type=int,
20 help=("Specify the job build number for android/"
21 "ubuntu-{hwpacks,images,sysroots}/binaries"))
20parser.add_argument("-m", "--manifest", dest="manifest", action='store_true',22parser.add_argument("-m", "--manifest", dest="manifest", action='store_true',
21 help="Optional parameter to generate MANIFEST file")23 help="Optional parameter to generate MANIFEST file")
2224
23uploads_path = '/srv/snapshots.linaro.org/uploads/'25uploads_path = '/srv/snapshots.linaro.org/uploads/'
24target_path = '/srv/snapshots.linaro.org/www/'26target_path = '/srv/snapshots.linaro.org/www/'
25PASS = 0 27PASS = 0
26FAIL = 128FAIL = 1
27acceptable_job_types = [29acceptable_job_types = [
28 'android',30 'android',
@@ -35,14 +37,16 @@
35 'binaries'37 'binaries'
36 ]38 ]
3739
40
38class SnapshotsPublisher(object):41class SnapshotsPublisher(object):
3942
40 def validate_args(self, args):43 def validate_args(self, args):
41 # Validate that all the required information 44 # Validate that all the required information
42 # is passed on the command line45 # is passed on the command line
43 if (args.job_type == None or args.job_name == None or \46 if (args.job_type == None or args.job_name == None or
44 args.build_num == None): 47 args.build_num == None):
45 parser.error("\nYou must specify job-type, job-name and build-num")48 parser.error(
49 "\nYou must specify job-type, job-name and build-num")
46 return FAIL50 return FAIL
4751
48 if (args.job_type not in acceptable_job_types):52 if (args.job_type not in acceptable_job_types):
@@ -52,16 +56,17 @@
52 def jobname_to_target_subdir(self, args, jobname):56 def jobname_to_target_subdir(self, args, jobname):
53 ret_val = None57 ret_val = None
54 if args.job_type == "android":58 if args.job_type == "android":
55 ret_val = jobname.split("_") 59 ret_val = jobname.split("_")
56 elif args.job_type == "kernel-hwpack":60 elif args.job_type == "kernel-hwpack":
57 ret_val = jobname.split('_')[0].replace(".", "_")61 ret_val = jobname.split('_')[0].replace(".", "_")
58 elif args.job_type == "ubuntu-hwpacks" or \62 elif (args.job_type == "ubuntu-hwpacks" or
59 args.job_type == "ubuntu-images" or\63 args.job_type == "ubuntu-images" or
60 args.job_type == "ubuntu-restricted" or\64 args.job_type == "ubuntu-restricted" or
61 args.job_type == "ubuntu-sysroots":65 args.job_type == "ubuntu-sysroots"):
62 ret_val = jobname.split('-', 2)66 ret_val = jobname.split('-', 2)
63 elif args.job_type == "prebuilt":67 elif args.job_type == "prebuilt":
64 ret_val = '' #just need non-null since its isn't needed68 # Return value must not be None when we want to ignore it.
69 ret_val = ''
65 elif args.job_type == "binaries":70 elif args.job_type == "binaries":
66 ret_val = jobname.split('-', 2)71 ret_val = jobname.split('-', 2)
67 return ret_val72 return ret_val
@@ -73,31 +78,32 @@
73 if args.job_type == "android":78 if args.job_type == "android":
74 build_path = '/'.join([args.job_type, args.job_name,79 build_path = '/'.join([args.job_type, args.job_name,
75 str(args.build_num)])80 str(args.build_num)])
76 build_dir_path = os.path.join(uploads_path, build_path) 81 build_dir_path = os.path.join(uploads_path, build_path)
77 user_name = ret_val[0]82 user_name = ret_val[0]
78 job_name = '_'.join(ret_val[1:])83 job_name = '_'.join(ret_val[1:])
79 target_dir = '/'.join([args.job_type, "~%s" % user_name, 84 target_dir = '/'.join([args.job_type, "~%s" % user_name,
80 job_name, str(args.build_num)])85 job_name, str(args.build_num)])
81 target_dir_path = os.path.join(target_path, target_dir)86 target_dir_path = os.path.join(target_path, target_dir)
82 elif args.job_type == "kernel-hwpack":87 elif args.job_type == "kernel-hwpack":
83 kernel_tree = ret_val88 kernel_tree = ret_val
84 build_path = '/'.join([args.job_type, args.job_name, 89 build_path = '/'.join([args.job_type, args.job_name,
85 str(args.build_num)])90 str(args.build_num)])
86 build_dir_path = os.path.join(uploads_path, build_path)91 build_dir_path = os.path.join(uploads_path, build_path)
87 target_dir = '/'.join([args.job_type, kernel_tree, 92 target_dir = '/'.join([args.job_type, kernel_tree,
88 args.job_name])93 args.job_name])
89 target_dir_path = os.path.join(target_path, target_dir)94 target_dir_path = os.path.join(target_path, target_dir)
90 elif args.job_type == "ubuntu-hwpacks" or \95 elif (args.job_type == "ubuntu-hwpacks" or
91 args.job_type == "ubuntu-images" or\96 args.job_type == "ubuntu-images" or
92 args.job_type == "ubuntu-restricted" or\97 args.job_type == "ubuntu-restricted" or
93 args.job_type == "ubuntu-sysroots":98 args.job_type == "ubuntu-sysroots"):
94 dist_name = ret_val[0]99 dist_name = ret_val[0]
95 hwpack_image = args.job_type.split("-")[1]100 hwpack_image = args.job_type.split("-")[1]
96 board_rootfs_name = ret_val[2]101 board_rootfs_name = ret_val[2]
97 build_dir_path = os.path.join(uploads_path, args.job_name, 102 build_dir_path = os.path.join(uploads_path, args.job_name,
98 str(args.build_num))103 str(args.build_num))
99 target_dir = '/'.join([dist_name, hwpack_image, 104 target_dir = '/'.join(
100 board_rootfs_name, str(args.build_num)])105 [dist_name, hwpack_image, board_rootfs_name,
106 str(args.build_num)])
101 target_dir_path = os.path.join(target_path, target_dir)107 target_dir_path = os.path.join(target_path, target_dir)
102 elif args.job_type == "prebuilt":108 elif args.job_type == "prebuilt":
103 build_path = '%s/%d' % (args.job_name, args.build_num)109 build_path = '%s/%d' % (args.job_name, args.build_num)
@@ -113,11 +119,9 @@
113 timestamp = f.read().strip()119 timestamp = f.read().strip()
114 f.close()120 f.close()
115 os.remove(ts_file)121 os.remove(ts_file)
116 target_dir_path = os.path.join(target_path,122 target_dir_path = os.path.join(
117 'android',123 target_path, 'android', args.job_type, ret_val[0],
118 args.job_type,124 timestamp)
119 ret_val[0],
120 timestamp)
121 else:125 else:
122 return None, None126 return None, None
123127
@@ -157,7 +161,7 @@
157 return FAIL161 return FAIL
158162
159 def create_manifest_file(self, target_dir):163 def create_manifest_file(self, target_dir):
160 orig_dir=os.getcwd()164 orig_dir = os.getcwd()
161 os.chdir(target_dir)165 os.chdir(target_dir)
162 fn = os.path.join(target_dir, "MANIFEST")166 fn = os.path.join(target_dir, "MANIFEST")
163 lines = []167 lines = []
@@ -165,7 +169,8 @@
165 try:169 try:
166 for path, subdirs, files in os.walk("."):170 for path, subdirs, files in os.walk("."):
167 for name in files:171 for name in files:
168 lines.append(os.path.join(path, name).split("./")[1] + "\n")172 lines.append(
173 os.path.join(path, name).split("./")[1] + "\n")
169174
170 if len(lines) != 0:175 if len(lines) != 0:
171 fd = open(fn, "w+")176 fd = open(fn, "w+")
@@ -174,7 +179,7 @@
174 fd.write(line)179 fd.write(line)
175 fd.close()180 fd.close()
176 else:181 else:
177 raise Exception("Uploads directory was empty, "\182 raise Exception("Uploads directory was empty, "
178 "nothing got moved to destination")183 "nothing got moved to destination")
179184
180 os.chdir(orig_dir)185 os.chdir(orig_dir)
@@ -218,11 +223,11 @@
218223
219 self.move_dir_content(build_dir_path, target_dir_path)224 self.move_dir_content(build_dir_path, target_dir_path)
220225
221 if args.job_type == "android" or\226 if (args.job_type == "android" or
222 args.job_type == "ubuntu-hwpacks" or\227 args.job_type == "ubuntu-hwpacks" or
223 args.job_type == "ubuntu-images" or\228 args.job_type == "ubuntu-images" or
224 args.job_type == "ubuntu-restricted" or\229 args.job_type == "ubuntu-restricted" or
225 args.job_type == "ubuntu-sysroots":230 args.job_type == "ubuntu-sysroots"):
226 ret = self.create_symlink(args, target_dir_path)231 ret = self.create_symlink(args, target_dir_path)
227 if ret != PASS:232 if ret != PASS:
228 return ret233 return ret
@@ -233,30 +238,33 @@
233 print "Failed to create manifest file"238 print "Failed to create manifest file"
234 return ret239 return ret
235240
236 print "Moved the files from '",build_dir_path, "' to '",\241 print (
237 target_dir_path, "'"242 "Moved the files from '%s' to '%s'" % (
243 build_dir_path, target_dir_path))
238 return PASS244 return PASS
239245
240 except OSError, details:246 except OSError, details:
241 print "Failed to create the target path", target_dir_path, \247 print (
242 ":", details 248 "Failed to create the target path %s: %s" % (
249 target_dir_path, details))
243 return FAIL250 return FAIL
244251
245 except shutil.Error:252 except shutil.Error:
246 print "Failed to move files destination path", target_dir_path253 print "Failed to move files destination path", target_dir_path
247 return FAIL254 return FAIL
248255
256
249def main():257def main():
250 publisher = SnapshotsPublisher()258 publisher = SnapshotsPublisher()
251 args = parser.parse_args()259 args = parser.parse_args()
252 publisher.validate_args(args)260 publisher.validate_args(args)
253 try:261 try:
254 build_dir_path, target_dir_path = publisher.validate_paths(args, uploads_path, 262 build_dir_path, target_dir_path = publisher.validate_paths(
255 target_path)263 args, uploads_path, target_path)
256 if build_dir_path == None or target_dir_path == None:264 if build_dir_path == None or target_dir_path == None:
257 print "Problem with build/target path, move failed"265 print "Problem with build/target path, move failed"
258 return FAIL266 return FAIL
259 ret = publisher.move_artifacts(args, build_dir_path, target_dir_path)267 ret = publisher.move_artifacts(args, build_dir_path, target_dir_path)
260 if ret != PASS:268 if ret != PASS:
261 print "Move Failed"269 print "Move Failed"
262 return FAIL270 return FAIL
263271
=== modified file 'testplans/releases.txt'
--- testplans/releases.txt 2012-05-16 16:46:12 +0000
+++ testplans/releases.txt 2012-05-18 08:34:31 +0000
@@ -6,7 +6,7 @@
66
7Import class we will use for this test and init browser object.7Import class we will use for this test and init browser object.
88
9 >>> from testing.doctest_production_browser import DoctestProductionBrowser9 >>> from tests.doctest_production_browser import DoctestProductionBrowser
10 >>> browser = DoctestProductionBrowser("http://releases.linaro.org/")10 >>> browser = DoctestProductionBrowser("http://releases.linaro.org/")
1111
12Visiting homepage and check for title.12Visiting homepage and check for title.
1313
=== modified file 'testplans/snapshots.txt'
--- testplans/snapshots.txt 2012-05-16 16:30:19 +0000
+++ testplans/snapshots.txt 2012-05-18 08:34:31 +0000
@@ -6,7 +6,7 @@
66
7Import class we will use for this test and init browser object.7Import class we will use for this test and init browser object.
88
9 >>> from testing.doctest_production_browser import DoctestProductionBrowser9 >>> from tests.doctest_production_browser import DoctestProductionBrowser
10 >>> browser = DoctestProductionBrowser("http://snapshots.linaro.org/")10 >>> browser = DoctestProductionBrowser("http://snapshots.linaro.org/")
1111
12Visiting homepage and check for title.12Visiting homepage and check for title.
1313
=== renamed directory 'testing' => 'tests'
=== modified file 'tests/__init__.py'
--- testing/__init__.py 2012-05-17 12:37:39 +0000
+++ tests/__init__.py 2012-05-18 08:34:31 +0000
@@ -1,15 +1,11 @@
1import os
2import unittest1import unittest
32
4from testing.test_click_through_license import *
5from testing.test_publish_to_snapshots import *
6
73
8def test_suite():4def test_suite():
9 module_names = [5 module_names = [
10 'testing.test_click_through_license.TestLicense',6 'tests.test_click_through_license.TestLicense',
11 'testing.test_publish_to_snapshots.TestSnapshotsPublisher',7 'tests.test_publish_to_snapshots.TestSnapshotsPublisher',
12 'testing.test_php_unit.PhpUnitTest',8 'tests.test_php_unit.PhpUnitTest',
13 ]9 ]
14 loader = unittest.TestLoader()10 loader = unittest.TestLoader()
15 suite = loader.loadTestsFromNames(module_names)11 suite = loader.loadTestsFromNames(module_names)
1612
=== modified file 'tests/test_click_through_license.py'
--- testing/test_click_through_license.py 2012-05-11 12:07:43 +0000
+++ tests/test_click_through_license.py 2012-05-18 08:34:31 +0000
@@ -14,7 +14,7 @@
14fetcher = LicenseProtectedFileFetcher()14fetcher = LicenseProtectedFileFetcher()
15cwd = os.getcwd()15cwd = os.getcwd()
16docroot = cwd16docroot = cwd
17srvroot = os.path.abspath(os.path.join(*([cwd] + ['testing'])))17srvroot = os.path.abspath(os.path.join(*([cwd] + ['tests'])))
18local_rewrite = 'RewriteCond %{REMOTE_ADDR} 127.0.0.1 [OR]'18local_rewrite = 'RewriteCond %{REMOTE_ADDR} 127.0.0.1 [OR]'
1919
20host = 'http://127.0.0.1'20host = 'http://127.0.0.1'
@@ -23,12 +23,15 @@
23ste_license_path = '/licenses/ste.html'23ste_license_path = '/licenses/ste.html'
24linaro_license_path = '/licenses/linaro.html'24linaro_license_path = '/licenses/linaro.html'
25samsung_test_file = '/android/~linaro-android/staging-origen/test.txt'25samsung_test_file = '/android/~linaro-android/staging-origen/test.txt'
26ste_test_file = '/android/~linaro-android/staging-snowball/173/target/product/snowball/test.txt'26ste_test_file = ('/android/~linaro-android/staging-snowball'
27 '/173/target/product/snowball/test.txt')
27ste_open_test_file = '/android/~linaro-android/staging-snowball/173/test.txt'28ste_open_test_file = '/android/~linaro-android/staging-snowball/173/test.txt'
28never_available = '/android/~linaro-android/staging-imx53/test.txt'29never_available = '/android/~linaro-android/staging-imx53/test.txt'
29linaro_test_file = '/android/~linaro-android/staging-panda/test.txt'30linaro_test_file = '/android/~linaro-android/staging-panda/test.txt'
30not_protected_test_file = '/android/~linaro-android/staging-vexpress-a9/test.txt'31not_protected_test_file = ('/android/~linaro-android/staging-vexpress-a9'
31not_found_test_file = '/android/~linaro-android/staging-vexpress-a9/notfound.txt'32 '/test.txt')
33not_found_test_file = ('/android/~linaro-android/staging-vexpress-a9'
34 '/notfound.txt')
32per_file_samsung_test_file = '/android/images/origen-blob.txt'35per_file_samsung_test_file = '/android/images/origen-blob.txt'
33per_file_ste_test_file = '/android/images/snowball-blob.txt'36per_file_ste_test_file = '/android/images/snowball-blob.txt'
34per_file_not_protected_test_file = '/android/images/MANIFEST'37per_file_not_protected_test_file = '/android/images/MANIFEST'
@@ -267,13 +270,15 @@
267 def test_per_file_license_accepted_samsung(self):270 def test_per_file_license_accepted_samsung(self):
268 search = "This is protected with click-through Samsung license."271 search = "This is protected with click-through Samsung license."
269 os.rename("%s/cookies.samsung" % docroot, "%s/cookies.txt" % docroot)272 os.rename("%s/cookies.samsung" % docroot, "%s/cookies.txt" % docroot)
270 testfile = fetcher.get(host + per_file_samsung_test_file, ignore_license=True)273 testfile = fetcher.get(host + per_file_samsung_test_file,
274 ignore_license=True)
271 self.assertThat(testfile, Contains(search))275 self.assertThat(testfile, Contains(search))
272276
273 def test_per_file_license_accepted_ste(self):277 def test_per_file_license_accepted_ste(self):
274 search = "This is protected with click-through ST-E license."278 search = "This is protected with click-through ST-E license."
275 os.rename("%s/cookies.ste" % docroot, "%s/cookies.txt" % docroot)279 os.rename("%s/cookies.ste" % docroot, "%s/cookies.txt" % docroot)
276 testfile = fetcher.get(host + per_file_ste_test_file, ignore_license=True)280 testfile = fetcher.get(host + per_file_ste_test_file,
281 ignore_license=True)
277 self.assertThat(testfile, Contains(search))282 self.assertThat(testfile, Contains(search))
278283
279 def test_per_file_non_protected_dirs(self):284 def test_per_file_non_protected_dirs(self):
280285
=== modified file 'tests/test_php_unit.py'
--- testing/test_php_unit.py 2012-05-14 10:39:08 +0000
+++ tests/test_php_unit.py 2012-05-18 08:34:31 +0000
@@ -7,6 +7,9 @@
7from testtools.matchers import Equals7from testtools.matchers import Equals
8from testtools.matchers import AllMatch8from testtools.matchers import AllMatch
99
10from tests.test_click_through_license import CommandNotFoundException
11
12
10class PhpUnitTest(TestCase):13class PhpUnitTest(TestCase):
11 '''Tests for executing the PHP Unit tests'''14 '''Tests for executing the PHP Unit tests'''
1215
@@ -14,7 +17,7 @@
14 super(PhpUnitTest, self).setUp()17 super(PhpUnitTest, self).setUp()
15 self.xml_path = tempfile.mkstemp()[1]18 self.xml_path = tempfile.mkstemp()[1]
16 if subprocess.Popen(['phpunit', '--log-junit',19 if subprocess.Popen(['phpunit', '--log-junit',
17 self.xml_path, 'testing/LicenseHelperTest'],20 self.xml_path, 'tests/LicenseHelperTest'],
18 stdout=open('/dev/null', 'w'),21 stdout=open('/dev/null', 'w'),
19 stderr=subprocess.STDOUT).wait():22 stderr=subprocess.STDOUT).wait():
20 raise CommandNotFoundException("phpunit command not found. Please "23 raise CommandNotFoundException("phpunit command not found. Please "
2124
=== modified file 'tests/test_publish_to_snapshots.py'
--- testing/test_publish_to_snapshots.py 2012-05-02 18:34:30 +0000
+++ tests/test_publish_to_snapshots.py 2012-05-18 08:34:31 +0000
@@ -9,22 +9,25 @@
9from testtools import TestCase9from testtools import TestCase
10from scripts.publish_to_snapshots import SnapshotsPublisher10from scripts.publish_to_snapshots import SnapshotsPublisher
1111
12
12class TestSnapshotsPublisher(TestCase):13class TestSnapshotsPublisher(TestCase):
13 '''Tests for publishing files to the snapshots.l.o www are.'''14 '''Tests for publishing files to the snapshots.l.o www area.'''
1415
15 uploads_path = "uploads/"16 uploads_path = "uploads/"
16 target_path = "www/"17 target_path = "www/"
17 orig_dir = os.getcwd()18 orig_dir = os.getcwd()
1819
19 def setUp(self):20 def setUp(self):
20 self.parser = argparse.ArgumentParser()21 self.parser = argparse.ArgumentParser()
21 self.parser.add_argument("-t", "--job-type", dest="job_type")22 self.parser.add_argument("-t", "--job-type", dest="job_type")
22 self.parser.add_argument("-j", "--job-name", dest="job_name")23 self.parser.add_argument("-j", "--job-name", dest="job_name")
23 self.parser.add_argument("-n", "--build-num", dest="build_num", type=int)24 self.parser.add_argument("-n", "--build-num", dest="build_num",
24 self.parser.add_argument("-m", "--manifest", dest="manifest", action='store_true')25 type=int)
26 self.parser.add_argument("-m", "--manifest", dest="manifest",
27 action='store_true')
25 if not os.path.isdir(self.uploads_path):28 if not os.path.isdir(self.uploads_path):
26 os.mkdir(self.uploads_path)29 os.mkdir(self.uploads_path)
27 30
28 if not os.path.isdir(self.target_path):31 if not os.path.isdir(self.target_path):
29 os.mkdir(self.target_path)32 os.mkdir(self.target_path)
30 super(TestSnapshotsPublisher, self).setUp()33 super(TestSnapshotsPublisher, self).setUp()
@@ -40,38 +43,38 @@
4043
41 def test_validate_args_valid_job_values(self):44 def test_validate_args_valid_job_values(self):
42 self.publisher = SnapshotsPublisher()45 self.publisher = SnapshotsPublisher()
43 param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name', 46 param = self.parser.parse_args(
44 '-n', '1'])47 ['-t', 'android', '-j', 'dummy_job_name', '-n', '1'])
45 self.publisher.validate_args(param)48 self.publisher.validate_args(param)
46 param = self.parser.parse_args(['-t', 'kernel-hwpack', '-j', 'dummy_job_name', 49 param = self.parser.parse_args(
47 '-n', '1'])50 ['-t', 'kernel-hwpack', '-j', 'dummy_job_name', '-n', '1'])
48 self.publisher.validate_args(param)51 self.publisher.validate_args(param)
4952
50 param = self.parser.parse_args(['-t', 'prebuilt', '-j', 'dummy_job_name',53 param = self.parser.parse_args(
51 '-n', '1'])54 ['-t', 'prebuilt', '-j', 'dummy_job_name', '-n', '1'])
52 self.publisher.validate_args(param)55 self.publisher.validate_args(param)
53 param = self.parser.parse_args(['-t', 'ubuntu-hwpacks', '-j', 'dummy_job_name',56 param = self.parser.parse_args(
54 '-n', '1'])57 ['-t', 'ubuntu-hwpacks', '-j', 'dummy_job_name', '-n', '1'])
55 self.publisher.validate_args(param)58 self.publisher.validate_args(param)
56 param = self.parser.parse_args(['-t', 'ubuntu-images', '-j', 'dummy_job_name',59 param = self.parser.parse_args(
57 '-n', '1'])60 ['-t', 'ubuntu-images', '-j', 'dummy_job_name', '-n', '1'])
58 self.publisher.validate_args(param)61 self.publisher.validate_args(param)
59 param = self.parser.parse_args(['-t', 'ubuntu-restricted', '-j', 'dummy_job_name',62 param = self.parser.parse_args(
60 '-n', '1'])63 ['-t', 'ubuntu-restricted', '-j', 'dummy_job_name', '-n', '1'])
61 self.publisher.validate_args(param)64 self.publisher.validate_args(param)
62 param = self.parser.parse_args(['-t', 'ubuntu-sysroots', '-j', 'dummy_job_name',65 param = self.parser.parse_args(
63 '-n', '1'])66 ['-t', 'ubuntu-sysroots', '-j', 'dummy_job_name', '-n', '1'])
64 self.publisher.validate_args(param)67 self.publisher.validate_args(param)
65 param = self.parser.parse_args(['-t', 'binaries', '-j', 'dummy_job_name',68 param = self.parser.parse_args(
66 '-n', '1'])69 ['-t', 'binaries', '-j', 'dummy_job_name', '-n', '1'])
67 self.publisher.validate_args(param)70 self.publisher.validate_args(param)
6871
69 def test_validate_args_invalid_job_type(self):72 def test_validate_args_invalid_job_type(self):
70 orig_stderr = sys.stderr73 orig_stderr = sys.stderr
71 stderr = sys.stderr = StringIO()74 stderr = sys.stderr = StringIO()
72 self.publisher = SnapshotsPublisher()75 self.publisher = SnapshotsPublisher()
73 param = self.parser.parse_args(['-t', 'invalid_job_type', '-j', 'dummy_job_name', 76 param = self.parser.parse_args(
74 '-n', '1'])77 ['-t', 'invalid_job_type', '-j', 'dummy_job_name', '-n', '1'])
75 try:78 try:
76 self.publisher.validate_args(param)79 self.publisher.validate_args(param)
77 except SystemExit, err:80 except SystemExit, err:
@@ -82,7 +85,6 @@
82 stderr.seek(0)85 stderr.seek(0)
83 self.assertIn("Invalid job type", stderr.read())86 self.assertIn("Invalid job type", stderr.read())
8487
85
86 def test_validate_args_run_invalid_argument(self):88 def test_validate_args_run_invalid_argument(self):
87 orig_stderr = sys.stderr89 orig_stderr = sys.stderr
88 stderr = sys.stderr = StringIO()90 stderr = sys.stderr = StringIO()
@@ -111,7 +113,7 @@
111 sys.stderr = orig_stderr113 sys.stderr = orig_stderr
112114
113 stderr.seek(0)115 stderr.seek(0)
114 self.assertIn("argument -n/--build-num: invalid int value: 'N'", 116 self.assertIn("argument -n/--build-num: invalid int value: 'N'",
115 stderr.read())117 stderr.read())
116118
117 def test_validate_args_run_none_values(self):119 def test_validate_args_run_none_values(self):
@@ -119,7 +121,8 @@
119 stderr = sys.stderr = StringIO()121 stderr = sys.stderr = StringIO()
120 self.publisher = SnapshotsPublisher()122 self.publisher = SnapshotsPublisher()
121 try:123 try:
122 param = self.parser.parse_args(['-t', None , '-j', None , '-n' , 0])124 param = self.parser.parse_args(
125 ['-t', None, '-j', None, '-n', 0])
123 self.publisher.validate_args(param)126 self.publisher.validate_args(param)
124 except SystemExit, err:127 except SystemExit, err:
125 self.assertEqual(err.code, 2, "None values are not acceptable")128 self.assertEqual(err.code, 2, "None values are not acceptable")
@@ -127,20 +130,21 @@
127 sys.stderr = orig_stderr130 sys.stderr = orig_stderr
128131
129 stderr.seek(0)132 stderr.seek(0)
130 self.assertIn("You must specify job-type, job-name and build-num", 133 self.assertIn("You must specify job-type, job-name and build-num",
131 stderr.read())134 stderr.read())
132135
133 def test_validate_paths_invalid_uploads_path(self):136 def test_validate_paths_invalid_uploads_path(self):
134 orig_stdout = sys.stdout137 orig_stdout = sys.stdout
135 stdout = sys.stdout = StringIO()138 stdout = sys.stdout = StringIO()
136 self.publisher = SnapshotsPublisher()139 self.publisher = SnapshotsPublisher()
137 param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name', 140 param = self.parser.parse_args(
138 '-n', '1'])141 ['-t', 'android', '-j', 'dummy_job_name', '-n', '1'])
139142
140 self.publisher.validate_args(param)143 self.publisher.validate_args(param)
141 uploads_path = "./dummy_uploads_path"144 uploads_path = "./dummy_uploads_path"
142 try:145 try:
143 self.publisher.validate_paths(param, uploads_path, self.target_path)146 self.publisher.validate_paths(param, uploads_path,
147 self.target_path)
144 finally:148 finally:
145 sys.stdout = orig_stdout149 sys.stdout = orig_stdout
146150
@@ -151,16 +155,18 @@
151 orig_stdout = sys.stdout155 orig_stdout = sys.stdout
152 stdout = sys.stdout = StringIO()156 stdout = sys.stdout = StringIO()
153 self.publisher = SnapshotsPublisher()157 self.publisher = SnapshotsPublisher()
154 param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name', 158 param = self.parser.parse_args(
155 '-n', '1'])159 ['-t', 'android', '-j', 'dummy_job_name', '-n', '1'])
156160
157 self.publisher.validate_args(param)161 self.publisher.validate_args(param)
158 build_path = os.path.join(self.uploads_path, param.job_type, param.job_name,162 build_path = os.path.join(
159 str(param.build_num))163 self.uploads_path, param.job_type, param.job_name,
164 str(param.build_num))
160 os.makedirs(build_path)165 os.makedirs(build_path)
161 self.target_path = "./dummy_target_path"166 self.target_path = "./dummy_target_path"
162 try:167 try:
163 self.publisher.validate_paths(param, self.uploads_path, self.target_path)168 self.publisher.validate_paths(param, self.uploads_path,
169 self.target_path)
164 finally:170 finally:
165 sys.stdout = orig_stdout171 sys.stdout = orig_stdout
166172
@@ -171,19 +177,21 @@
171 orig_stdout = sys.stdout177 orig_stdout = sys.stdout
172 stdout = sys.stdout = StringIO()178 stdout = sys.stdout = StringIO()
173 self.publisher = SnapshotsPublisher()179 self.publisher = SnapshotsPublisher()
174 param = self.parser.parse_args(['-t', 'kernel-hwpack', '-j', 'dummy_job_name', 180 param = self.parser.parse_args(
175 '-n', '1'])181 ['-t', 'kernel-hwpack', '-j', 'dummy_job_name', '-n', '1'])
176 self.publisher.validate_args(param)182 self.publisher.validate_args(param)
177 build_path = os.path.join(self.uploads_path, param.job_type, param.job_name,183 build_path = os.path.join(
178 str(param.build_num))184 self.uploads_path, param.job_type, param.job_name,
185 str(param.build_num))
179 os.makedirs(build_path)186 os.makedirs(build_path)
180 tempfile.mkstemp(dir=build_path)187 tempfile.mkstemp(dir=build_path)
181 try:188 try:
182 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param, 189 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
183 self.uploads_path, self.target_path)190 param, self.uploads_path, self.target_path)
184 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)191 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
185 target_dir_path = os.path.join(self.orig_dir, target_dir_path)192 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
186 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)193 self.publisher.move_artifacts(param, uploads_dir_path,
194 target_dir_path)
187 finally:195 finally:
188 sys.stdout = orig_stdout196 sys.stdout = orig_stdout
189 pass197 pass
@@ -195,19 +203,21 @@
195 orig_stdout = sys.stdout203 orig_stdout = sys.stdout
196 stdout = sys.stdout = StringIO()204 stdout = sys.stdout = StringIO()
197 self.publisher = SnapshotsPublisher()205 self.publisher = SnapshotsPublisher()
198 param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name', 206 param = self.parser.parse_args(
199 '-n', '1'])207 ['-t', 'android', '-j', 'dummy_job_name', '-n', '1'])
200 self.publisher.validate_args(param)208 self.publisher.validate_args(param)
201 build_dir = '/'.join([param.job_type, param.job_name, str(param.build_num)])209 build_dir = '/'.join(
210 [param.job_type, param.job_name, str(param.build_num)])
202 build_path = os.path.join(self.uploads_path, build_dir)211 build_path = os.path.join(self.uploads_path, build_dir)
203 os.makedirs(build_path)212 os.makedirs(build_path)
204 tempfile.mkstemp(dir=build_path)213 tempfile.mkstemp(dir=build_path)
205 try:214 try:
206 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param, 215 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
207 self.uploads_path, self.target_path)216 param, self.uploads_path, self.target_path)
208 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)217 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)218 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
210 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)219 self.publisher.move_artifacts(param, uploads_dir_path,
220 target_dir_path)
211 finally:221 finally:
212 sys.stdout = orig_stdout222 sys.stdout = orig_stdout
213 pass223 pass
@@ -219,19 +229,20 @@
219 orig_stdout = sys.stdout229 orig_stdout = sys.stdout
220 stdout = sys.stdout = StringIO()230 stdout = sys.stdout = StringIO()
221 self.publisher = SnapshotsPublisher()231 self.publisher = SnapshotsPublisher()
222 param = self.parser.parse_args(['-t', 'prebuilt', '-j', 'dummy_job_name',232 param = self.parser.parse_args(
223 '-n', '1'])233 ['-t', 'prebuilt', '-j', 'dummy_job_name', '-n', '1'])
224 self.publisher.validate_args(param)234 self.publisher.validate_args(param)
225 build_dir = '/'.join([param.job_name, str(param.build_num)])235 build_dir = '/'.join([param.job_name, str(param.build_num)])
226 build_path = os.path.join(self.uploads_path, build_dir,'oneiric')236 build_path = os.path.join(self.uploads_path, build_dir, 'oneiric')
227 os.makedirs(build_path)237 os.makedirs(build_path)
228 tempfile.mkstemp(dir=build_path)238 tempfile.mkstemp(dir=build_path)
229 try:239 try:
230 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param,240 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
231 self.uploads_path, self.target_path)241 param, self.uploads_path, self.target_path)
232 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)242 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
233 target_dir_path = os.path.join(self.orig_dir, target_dir_path)243 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
234 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)244 self.publisher.move_artifacts(param, uploads_dir_path,
245 target_dir_path)
235 finally:246 finally:
236 sys.stdout = orig_stdout247 sys.stdout = orig_stdout
237 pass248 pass
@@ -243,7 +254,7 @@
243 orig_stdout = sys.stdout254 orig_stdout = sys.stdout
244 stdout = sys.stdout = StringIO()255 stdout = sys.stdout = StringIO()
245 self.publisher = SnapshotsPublisher()256 self.publisher = SnapshotsPublisher()
246 param = self.parser.parse_args(['-t', 'ubuntu-hwpacks', '-j', 257 param = self.parser.parse_args(['-t', 'ubuntu-hwpacks', '-j',
247 'precise-armhf-lt-panda', '-n', '1'])258 'precise-armhf-lt-panda', '-n', '1'])
248 self.publisher.validate_args(param)259 self.publisher.validate_args(param)
249 build_dir = '/'.join([param.job_name, str(param.build_num)])260 build_dir = '/'.join([param.job_name, str(param.build_num)])
@@ -251,11 +262,12 @@
251 os.makedirs(build_path)262 os.makedirs(build_path)
252 tempfile.mkstemp(dir=build_path)263 tempfile.mkstemp(dir=build_path)
253 try:264 try:
254 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param, 265 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
255 self.uploads_path, self.target_path)266 param, self.uploads_path, self.target_path)
256 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)267 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
257 target_dir_path = os.path.join(self.orig_dir, target_dir_path)268 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
258 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)269 self.publisher.move_artifacts(param, uploads_dir_path,
270 target_dir_path)
259 finally:271 finally:
260 sys.stdout = orig_stdout272 sys.stdout = orig_stdout
261 pass273 pass
@@ -267,19 +279,21 @@
267 orig_stdout = sys.stdout279 orig_stdout = sys.stdout
268 stdout = sys.stdout = StringIO()280 stdout = sys.stdout = StringIO()
269 self.publisher = SnapshotsPublisher()281 self.publisher = SnapshotsPublisher()
270 param = self.parser.parse_args(['-t', 'ubuntu-images', '-j', 282 param = self.parser.parse_args(
271 'precise-armhf-ubuntu-desktop', '-n', '1'])283 ['-t', 'ubuntu-images', '-j', 'precise-armhf-ubuntu-desktop',
284 '-n', '1'])
272 self.publisher.validate_args(param)285 self.publisher.validate_args(param)
273 build_dir = '/'.join([param.job_name, str(param.build_num)])286 build_dir = '/'.join([param.job_name, str(param.build_num)])
274 build_path = os.path.join(self.uploads_path, build_dir)287 build_path = os.path.join(self.uploads_path, build_dir)
275 os.makedirs(build_path)288 os.makedirs(build_path)
276 tempfile.mkstemp(dir=build_path)289 tempfile.mkstemp(dir=build_path)
277 try:290 try:
278 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param,291 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
279 self.uploads_path, self.target_path)292 param, self.uploads_path, self.target_path)
280 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)293 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
281 target_dir_path = os.path.join(self.orig_dir, target_dir_path)294 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
282 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)295 self.publisher.move_artifacts(param, uploads_dir_path,
296 target_dir_path)
283 finally:297 finally:
284 sys.stdout = orig_stdout298 sys.stdout = orig_stdout
285 pass299 pass
@@ -291,20 +305,21 @@
291 orig_stdout = sys.stdout305 orig_stdout = sys.stdout
292 stdout = sys.stdout = StringIO()306 stdout = sys.stdout = StringIO()
293 self.publisher = SnapshotsPublisher()307 self.publisher = SnapshotsPublisher()
294 param = self.parser.parse_args(['-t', 'ubuntu-restricted', '-j',308 param = self.parser.parse_args(
295 'precise-armhf-integrated-big.little-fastmodels',309 ['-t', 'ubuntu-restricted', '-j',
296 '-n', '1'])310 'precise-armhf-integrated-big.little-fastmodels', '-n', '1'])
297 self.publisher.validate_args(param)311 self.publisher.validate_args(param)
298 build_dir = '/'.join([param.job_name, str(param.build_num)])312 build_dir = '/'.join([param.job_name, str(param.build_num)])
299 build_path = os.path.join(self.uploads_path, build_dir)313 build_path = os.path.join(self.uploads_path, build_dir)
300 os.makedirs(build_path)314 os.makedirs(build_path)
301 tempfile.mkstemp(dir=build_path)315 tempfile.mkstemp(dir=build_path)
302 try:316 try:
303 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param,317 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
304 self.uploads_path, self.target_path)318 param, self.uploads_path, self.target_path)
305 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)319 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
306 target_dir_path = os.path.join(self.orig_dir, target_dir_path)320 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
307 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)321 self.publisher.move_artifacts(param, uploads_dir_path,
322 target_dir_path)
308 finally:323 finally:
309 sys.stdout = orig_stdout324 sys.stdout = orig_stdout
310 pass325 pass
@@ -316,19 +331,21 @@
316 orig_stdout = sys.stdout331 orig_stdout = sys.stdout
317 stdout = sys.stdout = StringIO()332 stdout = sys.stdout = StringIO()
318 self.publisher = SnapshotsPublisher()333 self.publisher = SnapshotsPublisher()
319 param = self.parser.parse_args(['-t', 'ubuntu-sysroots', '-j',334 param = self.parser.parse_args(
320 'precise-armhf-ubuntu-desktop-dev', '-n', '1'])335 ['-t', 'ubuntu-sysroots', '-j',
336 'precise-armhf-ubuntu-desktop-dev', '-n', '1'])
321 self.publisher.validate_args(param)337 self.publisher.validate_args(param)
322 build_dir = '/'.join([param.job_name, str(param.build_num)])338 build_dir = '/'.join([param.job_name, str(param.build_num)])
323 build_path = os.path.join(self.uploads_path, build_dir)339 build_path = os.path.join(self.uploads_path, build_dir)
324 os.makedirs(build_path)340 os.makedirs(build_path)
325 tempfile.mkstemp(dir=build_path)341 tempfile.mkstemp(dir=build_path)
326 try:342 try:
327 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param,343 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
328 self.uploads_path, self.target_path)344 param, self.uploads_path, self.target_path)
329 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)345 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
330 target_dir_path = os.path.join(self.orig_dir, target_dir_path)346 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
331 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)347 self.publisher.move_artifacts(param, uploads_dir_path,
348 target_dir_path)
332 finally:349 finally:
333 sys.stdout = orig_stdout350 sys.stdout = orig_stdout
334 pass351 pass
@@ -353,12 +370,12 @@
353 f.write('20120416')370 f.write('20120416')
354 f.close()371 f.close()
355 try:372 try:
356 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param,373 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
357 self.uploads_path,374 param, self.uploads_path, self.target_path)
358 self.target_path)
359 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)375 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
360 target_dir_path = os.path.join(self.orig_dir, target_dir_path)376 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
361 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)377 self.publisher.move_artifacts(param, uploads_dir_path,
378 target_dir_path)
362 finally:379 finally:
363 sys.stdout = orig_stdout380 sys.stdout = orig_stdout
364 pass381 pass
@@ -366,23 +383,25 @@
366 stdout.seek(0)383 stdout.seek(0)
367 self.assertIn("Moved the files from", stdout.read())384 self.assertIn("Moved the files from", stdout.read())
368385
369 def test_move_artifacts_android_successful_move(self):386 def test_move_artifacts_android_successful_move2(self):
370 orig_stdout = sys.stdout387 orig_stdout = sys.stdout
371 stdout = sys.stdout = StringIO()388 stdout = sys.stdout = StringIO()
372 self.publisher = SnapshotsPublisher()389 self.publisher = SnapshotsPublisher()
373 param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name', 390 param = self.parser.parse_args(
374 '-n', '1'])391 ['-t', 'android', '-j', 'dummy_job_name', '-n', '1'])
375 self.publisher.validate_args(param)392 self.publisher.validate_args(param)
376 build_dir = '/'.join([param.job_type, param.job_name, str(param.build_num)])393 build_dir = '/'.join(
394 [param.job_type, param.job_name, str(param.build_num)])
377 build_path = os.path.join(self.uploads_path, build_dir)395 build_path = os.path.join(self.uploads_path, build_dir)
378 os.makedirs(build_path)396 os.makedirs(build_path)
379 tempfile.mkstemp(dir=build_path)397 tempfile.mkstemp(dir=build_path)
380 try:398 try:
381 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param, 399 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
382 self.uploads_path, self.target_path)400 param, self.uploads_path, self.target_path)
383 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)401 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
384 target_dir_path = os.path.join(self.orig_dir, target_dir_path)402 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
385 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)403 self.publisher.move_artifacts(param, uploads_dir_path,
404 target_dir_path)
386 finally:405 finally:
387 sys.stdout = orig_stdout406 sys.stdout = orig_stdout
388 pass407 pass
@@ -394,52 +413,57 @@
394 orig_stdout = sys.stdout413 orig_stdout = sys.stdout
395 stdout = sys.stdout = StringIO()414 stdout = sys.stdout = StringIO()
396 self.publisher = SnapshotsPublisher()415 self.publisher = SnapshotsPublisher()
397 param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name', 416 param = self.parser.parse_args(
398 '-n', '1'])417 ['-t', 'android', '-j', 'dummy_job_name', '-n', '1'])
399 self.publisher.validate_args(param)418 self.publisher.validate_args(param)
400 build_dir = '/'.join([param.job_type, param.job_name, str(param.build_num)])419 build_dir = '/'.join(
420 [param.job_type, param.job_name, str(param.build_num)])
401 build_path = os.path.join(self.uploads_path, build_dir)421 build_path = os.path.join(self.uploads_path, build_dir)
402 os.makedirs(build_path)422 os.makedirs(build_path)
403 tempfile.mkstemp(dir=build_path)423 tempfile.mkstemp(dir=build_path)
404 try:424 try:
405 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param, 425 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
406 self.uploads_path, self.target_path)426 param, self.uploads_path, self.target_path)
407 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)427 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
408 target_dir_path = os.path.join(self.orig_dir, target_dir_path)428 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
409 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)429 self.publisher.move_artifacts(param, uploads_dir_path,
430 target_dir_path)
410 finally:431 finally:
411 sys.stdout = orig_stdout432 sys.stdout = orig_stdout
412 pass433 pass
413434
414 stdout.seek(0)435 stdout.seek(0)
415 msg = "The latest build is now linked to " + target_dir_path436 msg = "The latest build is now linked to " + target_dir_path
416 self.assertIn(msg, stdout.read())437 self.assertIn(msg, stdout.read())
417438
418 def test_create_manifest_file_option(self):439 def test_create_manifest_file_option(self):
419 orig_stdout = sys.stdout440 orig_stdout = sys.stdout
420 stdout = sys.stdout = StringIO()441 stdout = sys.stdout = StringIO()
421 self.publisher = SnapshotsPublisher()442 self.publisher = SnapshotsPublisher()
422 param = self.parser.parse_args(['-t', 'android', '-j', 'dummy_job_name', 443 param = self.parser.parse_args(
423 '-n', '1', '-m'])444 ['-t', 'android', '-j', 'dummy_job_name', '-n', '1', '-m'])
424 self.publisher.validate_args(param)445 self.publisher.validate_args(param)
425 build_dir = '/'.join([param.job_type, param.job_name, str(param.build_num)])446 build_dir = '/'.join(
447 [param.job_type, param.job_name, str(param.build_num)])
426 build_path = os.path.join(self.uploads_path, build_dir)448 build_path = os.path.join(self.uploads_path, build_dir)
427 os.makedirs(build_path)449 os.makedirs(build_path)
428 tempfile.mkstemp(dir=build_path)450 tempfile.mkstemp(dir=build_path)
429 lines = []451 lines = []
430 try:452 try:
431 uploads_dir_path, target_dir_path = self.publisher.validate_paths(param, 453 uploads_dir_path, target_dir_path = self.publisher.validate_paths(
432 self.uploads_path, self.target_path)454 param, self.uploads_path, self.target_path)
433 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)455 uploads_dir_path = os.path.join(self.orig_dir, uploads_dir_path)
434 target_dir_path = os.path.join(self.orig_dir, target_dir_path)456 target_dir_path = os.path.join(self.orig_dir, target_dir_path)
435 os.chdir(uploads_dir_path)457 os.chdir(uploads_dir_path)
436 for path, subdirs, files in os.walk("."):458 for path, subdirs, files in os.walk("."):
437 for name in files:459 for name in files:
438 lines.append(os.path.join(path, name).split("./")[1] + "\n")460 lines.append(
461 os.path.join(path, name).split("./")[1] + "\n")
439 os.chdir(self.orig_dir)462 os.chdir(self.orig_dir)
440 self.publisher.move_artifacts(param, uploads_dir_path, target_dir_path)463 self.publisher.move_artifacts(param, uploads_dir_path,
464 target_dir_path)
441465
442 manifest_file=os.path.join(target_dir_path, "MANIFEST")466 manifest_file = os.path.join(target_dir_path, "MANIFEST")
443 dest = open(manifest_file, "r").read()467 dest = open(manifest_file, "r").read()
444468
445 if len(lines) != 0:469 if len(lines) != 0:
@@ -449,8 +473,8 @@
449 fd.write(line)473 fd.write(line)
450 fd.close()474 fd.close()
451 orig = open(tempfiles[1], "r").read()475 orig = open(tempfiles[1], "r").read()
452 476
453 except Exception, details:477 except:
454 pass478 pass
455479
456 finally:480 finally:

Subscribers

People subscribed via source and target branches