Merge lp:~sinzui/juju-ci-tools/juju-core2 into lp:juju-ci-tools
- juju-core2
- Merge into trunk
Proposed by
Curtis Hovey
Status: | Work in progress |
---|---|
Proposed branch: | lp:~sinzui/juju-ci-tools/juju-core2 |
Merge into: | lp:juju-ci-tools |
Diff against target: |
467 lines (+69/-177) 10 files modified
README.md (+1/-1) build_vagrant_boxes.py (+5/-11) candidate.py (+6/-4) jujuci.py (+10/-29) make-buildvars (+1/-1) retrieve-ubuntu-packages.bash (+0/-86) s3ci.py (+1/-1) tests/test_candidate.py (+21/-2) tests/test_jujuci.py (+8/-37) tests/test_s3ci.py (+16/-5) |
To merge this branch: | bzr merge lp:~sinzui/juju-ci-tools/juju-core2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Release Engineering | Pending | ||
Review via email: mp+309757@code.launchpad.net |
Commit message
Description of the change
support juju-core and juju-2.0 binary package names.
This branch was started many months ago. It does not work since scripts and the packaging changed
To post a comment you must log in.
Unmerged revisions
- 1293. By Curtis Hovey
-
Merged trunk
- 1292. By Curtis Hovey
-
Merged trunk
- 1291. By Curtis Hovey
-
Remove ambiguous uses og juju-core.
- 1290. By Curtis Hovey
-
Update s3ci to get juju2 package name.
- 1289. By Curtis Hovey
-
Removed unused certify scripts. Determine deb package name based on Juju version.
- 1288. By Curtis Hovey
-
Merged trunk.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'README.md' | |||
2 | --- README.md 2016-06-02 21:48:54 +0000 | |||
3 | +++ README.md 2016-11-01 14:01:39 +0000 | |||
4 | @@ -14,7 +14,7 @@ | |||
5 | 14 | making a tree of tools and metadata, and lastly publishing the tools. | 14 | making a tree of tools and metadata, and lastly publishing the tools. |
6 | 15 | you can skip the tarball and package steps if you just want to publish | 15 | you can skip the tarball and package steps if you just want to publish |
7 | 16 | the juju tools (AKA jujud, servers, agents). If you want to test a fix | 16 | the juju tools (AKA jujud, servers, agents). If you want to test a fix |
9 | 17 | that is in the juju-core trunk branch, you can make your own release | 17 | that is in the juju master branch, you can make your own release |
10 | 18 | tarball and package. | 18 | tarball and package. |
11 | 19 | 19 | ||
12 | 20 | Once juju is published to the test clouds, individual tests can be performed. | 20 | Once juju is published to the test clouds, individual tests can be performed. |
13 | 21 | 21 | ||
14 | === modified file 'build_vagrant_boxes.py' | |||
15 | --- build_vagrant_boxes.py 2016-02-19 06:41:06 +0000 | |||
16 | +++ build_vagrant_boxes.py 2016-11-01 14:01:39 +0000 | |||
17 | @@ -23,8 +23,7 @@ | |||
18 | 23 | """ | 23 | """ |
19 | 24 | 24 | ||
20 | 25 | SERIES_TO_NUMBERS = { | 25 | SERIES_TO_NUMBERS = { |
23 | 26 | 'trusty': '14.04', | 26 | 'xenial': '16.04', |
22 | 27 | 'precise': '12.04', | ||
24 | 28 | } | 27 | } |
25 | 29 | JENKINS_KVM = 'JENKINS_KVM' | 28 | JENKINS_KVM = 'JENKINS_KVM' |
26 | 30 | WORKSPACE = 'WORKSPACE' | 29 | WORKSPACE = 'WORKSPACE' |
27 | @@ -33,8 +32,7 @@ | |||
28 | 33 | def get_package_globs(series, arch): | 32 | def get_package_globs(series, arch): |
29 | 34 | series_number = SERIES_TO_NUMBERS[series] | 33 | series_number = SERIES_TO_NUMBERS[series] |
30 | 35 | return { | 34 | return { |
33 | 36 | 'core': 'juju-core_*%s*_%s.deb' % (series_number, arch), | 35 | 'juju2': 'juju2_*%s*_%s.deb' % (series_number, arch), |
32 | 37 | 'local': 'juju-local_*%s*_all.deb' % series_number, | ||
34 | 38 | } | 36 | } |
35 | 39 | 37 | ||
36 | 40 | 38 | ||
37 | @@ -78,8 +76,7 @@ | |||
38 | 78 | env = os.environ.copy() | 76 | env = os.environ.copy() |
39 | 79 | env['BUILD_FOR'] = '%s:%s' % (series, arch) | 77 | env['BUILD_FOR'] = '%s:%s' % (series, arch) |
40 | 80 | if package_info is not None: | 78 | if package_info is not None: |
43 | 81 | env['JUJU_CORE_PKG'] = package_info['core'] | 79 | env['JUJU_CORE_PKG'] = package_info['juju2'] |
42 | 82 | env['JUJU_LOCAL_PKG'] = package_info['local'] | ||
44 | 83 | builder_path = os.path.join(jenkins_kvm, 'build-juju-local.sh') | 80 | builder_path = os.path.join(jenkins_kvm, 'build-juju-local.sh') |
45 | 84 | build_dir = '%s-%s' % (series, arch) | 81 | build_dir = '%s-%s' % (series, arch) |
46 | 85 | logging.info('Building Vagrant box for %s %s' % (series, arch)) | 82 | logging.info('Building Vagrant box for %s %s' % (series, arch)) |
47 | @@ -140,11 +137,8 @@ | |||
48 | 140 | package_info = get_debian_packages( | 137 | package_info = get_debian_packages( |
49 | 141 | credentials, args.workspace, args.series, args.arch, | 138 | credentials, args.workspace, args.series, args.arch, |
50 | 142 | args.use_ci_juju_packages) | 139 | args.use_ci_juju_packages) |
56 | 143 | if 'core' not in package_info: | 140 | if 'juju2' not in package_info: |
57 | 144 | logging.error('Could not find juju-core package') | 141 | logging.error('Could not find juju2 package') |
53 | 145 | sys.exit(1) | ||
54 | 146 | if 'local' not in package_info: | ||
55 | 147 | logging.error('Could not find juju-local package') | ||
58 | 148 | sys.exit(1) | 142 | sys.exit(1) |
59 | 149 | else: | 143 | else: |
60 | 150 | package_info = None | 144 | package_info = None |
61 | 151 | 145 | ||
62 | === modified file 'candidate.py' | |||
63 | --- candidate.py 2016-08-04 16:38:06 +0000 | |||
64 | +++ candidate.py 2016-11-01 14:01:39 +0000 | |||
65 | @@ -19,6 +19,7 @@ | |||
66 | 19 | get_artifacts, | 19 | get_artifacts, |
67 | 20 | get_credentials, | 20 | get_credentials, |
68 | 21 | JENKINS_URL, | 21 | JENKINS_URL, |
69 | 22 | PackageNamer, | ||
70 | 22 | PUBLISH_REVISION | 23 | PUBLISH_REVISION |
71 | 23 | ) | 24 | ) |
72 | 24 | from utility import ( | 25 | from utility import ( |
73 | @@ -80,7 +81,7 @@ | |||
74 | 80 | if not pr_number: | 81 | if not pr_number: |
75 | 81 | pr_number = find_publish_revision_number(credentials, br_number) | 82 | pr_number = find_publish_revision_number(credentials, br_number) |
76 | 82 | get_artifacts( | 83 | get_artifacts( |
78 | 83 | credentials, PUBLISH_REVISION, pr_number, 'juju-core*', candidate_dir, | 84 | credentials, PUBLISH_REVISION, pr_number, 'juju*deb', candidate_dir, |
79 | 84 | dry_run=dry_run, verbose=verbose) | 85 | dry_run=dry_run, verbose=verbose) |
80 | 85 | 86 | ||
81 | 86 | 87 | ||
82 | @@ -95,11 +96,12 @@ | |||
83 | 95 | 96 | ||
84 | 96 | 97 | ||
85 | 97 | def get_package(artifacts_path, version): | 98 | def get_package(artifacts_path, version): |
87 | 98 | """Return the path to the expected juju-core package for the localhost.""" | 99 | """Return the path to the expected juju package for the localhost.""" |
88 | 99 | release = subprocess.check_output(['lsb_release', '-sr']).strip() | 100 | release = subprocess.check_output(['lsb_release', '-sr']).strip() |
89 | 100 | arch = get_deb_arch() | 101 | arch = get_deb_arch() |
92 | 101 | package_name = 'juju-core_{}-0ubuntu1~{}.1~juju1_{}.deb'.format( | 102 | deb_name = PackageNamer.get_juju_package_name(version) |
93 | 102 | version, release, arch) | 103 | package_name = '{}_{}-0ubuntu1~{}.1~juju1_{}.deb'.format( |
94 | 104 | deb_name, version, release, arch) | ||
95 | 103 | package_path = os.path.join(artifacts_path, package_name) | 105 | package_path = os.path.join(artifacts_path, package_name) |
96 | 104 | return package_path | 106 | return package_path |
97 | 105 | 107 | ||
98 | 106 | 108 | ||
99 | === modified file 'jujuci.py' | |||
100 | --- jujuci.py 2016-07-01 11:05:05 +0000 | |||
101 | +++ jujuci.py 2016-11-01 14:01:39 +0000 | |||
102 | @@ -40,7 +40,6 @@ | |||
103 | 40 | JENKINS_URL = 'http://juju-ci.vapour.ws:8080' | 40 | JENKINS_URL = 'http://juju-ci.vapour.ws:8080' |
104 | 41 | BUILD_REVISION = 'build-revision' | 41 | BUILD_REVISION = 'build-revision' |
105 | 42 | PUBLISH_REVISION = 'publish-revision' | 42 | PUBLISH_REVISION = 'publish-revision' |
106 | 43 | CERTIFY_UBUNTU_PACKAGES = 'certify-ubuntu-packages' | ||
107 | 44 | 43 | ||
108 | 45 | Artifact = namedtuple('Artifact', ['file_name', 'location']) | 44 | Artifact = namedtuple('Artifact', ['file_name', 'location']) |
109 | 46 | 45 | ||
110 | @@ -174,13 +173,6 @@ | |||
111 | 174 | return get_juju_binary(credentials, file_name, build_data, workspace) | 173 | return get_juju_binary(credentials, file_name, build_data, workspace) |
112 | 175 | 174 | ||
113 | 176 | 175 | ||
114 | 177 | def get_certification_bin(credentials, version, workspace): | ||
115 | 178 | build_data = get_build_data(JENKINS_URL, credentials, | ||
116 | 179 | CERTIFY_UBUNTU_PACKAGES, 'lastBuild') | ||
117 | 180 | file_name = PackageNamer.factory().get_certification_package(version) | ||
118 | 181 | return get_juju_binary(credentials, file_name, build_data, workspace) | ||
119 | 182 | |||
120 | 183 | |||
121 | 184 | def get_juju_binary(credentials, file_name, build_data, workspace): | 176 | def get_juju_binary(credentials, file_name, build_data, workspace): |
122 | 185 | artifact = get_filename_artifact(file_name, build_data) | 177 | artifact = get_filename_artifact(file_name, build_data) |
123 | 186 | target_path = os.path.join(workspace, artifact.file_name) | 178 | target_path = os.path.join(workspace, artifact.file_name) |
124 | @@ -340,15 +332,6 @@ | |||
125 | 340 | parser_get_juju_bin.add_argument('workspace', nargs='?', default='.', | 332 | parser_get_juju_bin.add_argument('workspace', nargs='?', default='.', |
126 | 341 | help='The place to store binaries.') | 333 | help='The place to store binaries.') |
127 | 342 | add_credential_args(parser_get_juju_bin) | 334 | add_credential_args(parser_get_juju_bin) |
128 | 343 | parser_get_certification_bin = subparsers.add_parser( | ||
129 | 344 | 'get-certification-bin', | ||
130 | 345 | help='Retrieve and extract juju binaries for certification.') | ||
131 | 346 | parser_get_certification_bin.add_argument( | ||
132 | 347 | 'version', help='The version to get certification for.') | ||
133 | 348 | parser_get_certification_bin.add_argument( | ||
134 | 349 | 'workspace', nargs='?', default='.', | ||
135 | 350 | help='The place to store binaries.') | ||
136 | 351 | add_credential_args(parser_get_certification_bin) | ||
137 | 352 | parser_get_buildvars = subparsers.add_parser( | 335 | parser_get_buildvars = subparsers.add_parser( |
138 | 353 | 'get-build-vars', | 336 | 'get-build-vars', |
139 | 354 | help='Retrieve the build-vars for a build-revision.') | 337 | help='Retrieve the build-vars for a build-revision.') |
140 | @@ -424,20 +407,22 @@ | |||
141 | 424 | class PackageNamer(Namer): | 407 | class PackageNamer(Namer): |
142 | 425 | """A class knows the names of packages.""" | 408 | """A class knows the names of packages.""" |
143 | 426 | 409 | ||
144 | 410 | @staticmethod | ||
145 | 411 | def get_juju_package_name(version): | ||
146 | 412 | """Return the name of the package based on the Juju version.""" | ||
147 | 413 | if version.startswith('1.'): | ||
148 | 414 | return 'juju-core' | ||
149 | 415 | return 'juju2' | ||
150 | 416 | |||
151 | 427 | def get_release_package_suffix(self): | 417 | def get_release_package_suffix(self): |
152 | 428 | return '-0ubuntu1~{distro_release}.1~juju1_{arch}.deb'.format( | 418 | return '-0ubuntu1~{distro_release}.1~juju1_{arch}.deb'.format( |
153 | 429 | distro_release=self.distro_release, arch=self.arch) | 419 | distro_release=self.distro_release, arch=self.arch) |
154 | 430 | 420 | ||
155 | 431 | def get_release_package(self, version): | 421 | def get_release_package(self, version): |
156 | 432 | return ( | 422 | return ( |
165 | 433 | 'juju-core_{version}{suffix}' | 423 | '{deb_name}_{version}{suffix}').format( |
166 | 434 | ).format(version=version, suffix=self.get_release_package_suffix()) | 424 | deb_name=self.get_juju_package_name(version), |
167 | 435 | 425 | version=version, suffix=self.get_release_package_suffix()) | |
160 | 436 | def get_certification_package(self, version): | ||
161 | 437 | return ( | ||
162 | 438 | 'juju-core_{version}~{distro_release}.1_{arch}.deb' | ||
163 | 439 | ).format(version=version, distro_release=self.distro_release, | ||
164 | 440 | arch=self.arch) | ||
168 | 441 | 426 | ||
169 | 442 | 427 | ||
170 | 443 | class JobNamer(Namer): | 428 | class JobNamer(Namer): |
171 | @@ -471,10 +456,6 @@ | |||
172 | 471 | dry_run=args.dry_run, verbose=args.verbose) | 456 | dry_run=args.dry_run, verbose=args.verbose) |
173 | 472 | elif args.command == 'get-juju-bin': | 457 | elif args.command == 'get-juju-bin': |
174 | 473 | print_now(get_juju_bin(credentials, args.workspace)) | 458 | print_now(get_juju_bin(credentials, args.workspace)) |
175 | 474 | elif args.command == 'get-certification-bin': | ||
176 | 475 | path = get_certification_bin(credentials, args.version, | ||
177 | 476 | args.workspace) | ||
178 | 477 | print_now(path) | ||
179 | 478 | elif args.command == 'get-build-vars': | 459 | elif args.command == 'get-build-vars': |
180 | 479 | text = get_buildvars( | 460 | text = get_buildvars( |
181 | 480 | credentials, args.build, env=args.env, | 461 | credentials, args.build, env=args.env, |
182 | 481 | 462 | ||
183 | === modified file 'make-buildvars' | |||
184 | --- make-buildvars 2016-02-18 20:53:26 +0000 | |||
185 | +++ make-buildvars 2016-11-01 14:01:39 +0000 | |||
186 | @@ -41,7 +41,7 @@ | |||
187 | 41 | 41 | ||
188 | 42 | 42 | ||
189 | 43 | def get_git_revision_info(branch, revision_spec): | 43 | def get_git_revision_info(branch, revision_spec): |
191 | 44 | """Find the commit and juju-core version of a branch. | 44 | """Find the commit and juju version of a branch. |
192 | 45 | 45 | ||
193 | 46 | Returns a tuple comparable to revno, revision-id, version. | 46 | Returns a tuple comparable to revno, revision-id, version. |
194 | 47 | The revno is always None. The revision-id is the commit hash. | 47 | The revno is always None. The revision-id is the commit hash. |
195 | 48 | 48 | ||
196 | === removed file 'retrieve-ubuntu-packages.bash' | |||
197 | --- retrieve-ubuntu-packages.bash 2015-04-06 20:11:19 +0000 | |||
198 | +++ retrieve-ubuntu-packages.bash 1970-01-01 00:00:00 +0000 | |||
199 | @@ -1,86 +0,0 @@ | |||
200 | 1 | #!/bin/bash | ||
201 | 2 | # Download Ubuntu juju packages that match the version under test. | ||
202 | 3 | set -eu | ||
203 | 4 | |||
204 | 5 | : ${LOCAL_JENKINS_URL=http://juju-ci.vapour.ws:8080} | ||
205 | 6 | ARTIFACTS_PATH=$WORKSPACE/artifacts | ||
206 | 7 | |||
207 | 8 | : ${SCRIPTS=$(readlink -f $(dirname $0))} | ||
208 | 9 | export PATH="$SCRIPTS:$PATH" | ||
209 | 10 | |||
210 | 11 | UBUNTU_ARCH="http://archive.ubuntu.com/ubuntu/pool/universe/j/juju-core/" | ||
211 | 12 | PORTS_ARCH="http://ports.ubuntu.com/pool/universe/j/juju-core/" | ||
212 | 13 | ALL_ARCHIVES="$UBUNTU_ARCH $PORTS_ARCH" | ||
213 | 14 | |||
214 | 15 | TRUSTY_AMD64="certify-trusty-amd64" | ||
215 | 16 | TRUSTY_PPC64="certify-trusty-ppc64" | ||
216 | 17 | TRUSTY_I386="certify-trusty-i386" | ||
217 | 18 | |||
218 | 19 | set -x | ||
219 | 20 | |||
220 | 21 | usage() { | ||
221 | 22 | echo "usage: $0 VERSION" | ||
222 | 23 | echo " VERSION: The juju package version to retrive." | ||
223 | 24 | exit 1 | ||
224 | 25 | } | ||
225 | 26 | |||
226 | 27 | |||
227 | 28 | check_deps() { | ||
228 | 29 | echo "Phase 0: Checking requirements." | ||
229 | 30 | has_deps=1 | ||
230 | 31 | which lftp || has_deps=0 | ||
231 | 32 | if [[ $has_deps == 0 ]]; then | ||
232 | 33 | echo "Install lftp." | ||
233 | 34 | exit 2 | ||
234 | 35 | fi | ||
235 | 36 | } | ||
236 | 37 | |||
237 | 38 | |||
238 | 39 | retrieve_packages() { | ||
239 | 40 | # Retrieve the $RELEASE packages that contain jujud, | ||
240 | 41 | # or copy a locally built package. | ||
241 | 42 | echo "Phase 1: Retrieving juju-core packages from archives" | ||
242 | 43 | cd $WORKSPACE | ||
243 | 44 | for archive in $ALL_ARCHIVES; do | ||
244 | 45 | safe_archive=$(echo "$archive" | sed -e 's,//.*@,//,') | ||
245 | 46 | echo "checking $safe_archive for $VERSION." | ||
246 | 47 | lftp -c mirror -I "juju*${VERSION}*.deb" $archive; | ||
247 | 48 | done | ||
248 | 49 | if [ -d $WORKSPACE/juju-core ]; then | ||
249 | 50 | found=$(find $WORKSPACE/juju-core/ -name "*deb") | ||
250 | 51 | if [[ $found != "" ]]; then | ||
251 | 52 | mv $WORKSPACE/juju-core/*deb ./ | ||
252 | 53 | fi | ||
253 | 54 | rm -r $WORKSPACE/juju-core | ||
254 | 55 | fi | ||
255 | 56 | } | ||
256 | 57 | |||
257 | 58 | |||
258 | 59 | start_series_arch_tests() { | ||
259 | 60 | [[ -z $TOKEN ]] && return 0 | ||
260 | 61 | encoded_version=$(echo "$VERSION" | sed 's,[+],%2B,') | ||
261 | 62 | query="token=$TOKEN&VERSION=$encoded_version" | ||
262 | 63 | for job in $TRUSTY_AMD64 $TRUSTY_PPC64 $TRUSTY_I386; do | ||
263 | 64 | curl -o /dev/null \ | ||
264 | 65 | "$LOCAL_JENKINS_URL/job/$job/buildWithParameters?$query" | ||
265 | 66 | done | ||
266 | 67 | } | ||
267 | 68 | |||
268 | 69 | |||
269 | 70 | TOKEN="" | ||
270 | 71 | while [[ "${1-}" != "" && $1 =~ ^-.* ]]; do | ||
271 | 72 | case $1 in | ||
272 | 73 | --start-other-tests) | ||
273 | 74 | shift | ||
274 | 75 | TOKEN=$1 | ||
275 | 76 | ;; | ||
276 | 77 | esac | ||
277 | 78 | shift | ||
278 | 79 | done | ||
279 | 80 | |||
280 | 81 | test $# -eq 1 || usage | ||
281 | 82 | VERSION=$1 | ||
282 | 83 | |||
283 | 84 | check_deps | ||
284 | 85 | retrieve_packages | ||
285 | 86 | start_series_arch_tests | ||
286 | 87 | 0 | ||
287 | === modified file 's3ci.py' | |||
288 | --- s3ci.py 2016-02-19 06:41:06 +0000 | |||
289 | +++ s3ci.py 2016-11-01 14:01:39 +0000 | |||
290 | @@ -99,7 +99,7 @@ | |||
291 | 99 | suffix = PackageNamer.factory().get_release_package_suffix() | 99 | suffix = PackageNamer.factory().get_release_package_suffix() |
292 | 100 | filtered = [ | 100 | filtered = [ |
293 | 101 | (k, f) for k, f in filter_keys(keys, suffix) | 101 | (k, f) for k, f in filter_keys(keys, suffix) |
295 | 102 | if f.startswith('juju-core_')] | 102 | if f.startswith('juju2_') or f.startswith('juju-core_')] |
296 | 103 | if len(filtered) == 0: | 103 | if len(filtered) == 0: |
297 | 104 | raise PackageNotFound('Package could not be found.') | 104 | raise PackageNotFound('Package could not be found.') |
298 | 105 | return sorted(filtered, key=lambda x: int( | 105 | return sorted(filtered, key=lambda x: int( |
299 | 106 | 106 | ||
300 | === modified file 'tests/test_candidate.py' | |||
301 | --- tests/test_candidate.py 2016-08-04 16:38:06 +0000 | |||
302 | +++ tests/test_candidate.py 2016-11-01 14:01:39 +0000 | |||
303 | @@ -128,7 +128,7 @@ | |||
304 | 128 | self.assertEqual(options, kwargs) | 128 | self.assertEqual(options, kwargs) |
305 | 129 | output, args, kwargs = ga_mock.mock_calls[1] | 129 | output, args, kwargs = ga_mock.mock_calls[1] |
306 | 130 | self.assertEqual( | 130 | self.assertEqual( |
308 | 131 | (credentials, 'publish-revision', 5678, 'juju-core*', | 131 | (credentials, 'publish-revision', 5678, 'juju*deb', |
309 | 132 | '~/candidate/1.24.4-artifacts'), | 132 | '~/candidate/1.24.4-artifacts'), |
310 | 133 | args) | 133 | args) |
311 | 134 | self.assertEqual(options, kwargs) | 134 | self.assertEqual(options, kwargs) |
312 | @@ -159,7 +159,26 @@ | |||
313 | 159 | self.assertEqual( | 159 | self.assertEqual( |
314 | 160 | ['1.21-artifacts', 'master-artifacts'], sorted(dirs)) | 160 | ['1.21-artifacts', 'master-artifacts'], sorted(dirs)) |
315 | 161 | 161 | ||
317 | 162 | def test_get_package(self): | 162 | def test_get_package_2x(self): |
318 | 163 | def subprocessor(*args, **kwargs): | ||
319 | 164 | command = args[0] | ||
320 | 165 | if 'lsb_release' in command: | ||
321 | 166 | return '14.04' | ||
322 | 167 | elif 'dpkg' in command: | ||
323 | 168 | return 'amd64' | ||
324 | 169 | |||
325 | 170 | with patch('subprocess.check_output', | ||
326 | 171 | side_effect=subprocessor) as co_mock: | ||
327 | 172 | name = get_package('foo', '2.2.3') | ||
328 | 173 | self.assertEqual( | ||
329 | 174 | 'foo/juju2_2.2.3-0ubuntu1~14.04.1~juju1_amd64.deb', name) | ||
330 | 175 | self.assertEqual(2, co_mock.call_count) | ||
331 | 176 | output, args, kwargs = co_mock.mock_calls[0] | ||
332 | 177 | self.assertEqual((['lsb_release', '-sr'], ), args) | ||
333 | 178 | output, args, kwargs = co_mock.mock_calls[1] | ||
334 | 179 | self.assertEqual((['dpkg', '--print-architecture'], ), args) | ||
335 | 180 | |||
336 | 181 | def test_get_package_1x(self): | ||
337 | 163 | def subprocessor(*args, **kwargs): | 182 | def subprocessor(*args, **kwargs): |
338 | 164 | command = args[0] | 183 | command = args[0] |
339 | 165 | if 'lsb_release' in command: | 184 | if 'lsb_release' in command: |
340 | 166 | 185 | ||
341 | === modified file 'tests/test_jujuci.py' | |||
342 | --- tests/test_jujuci.py 2016-07-01 15:50:09 +0000 | |||
343 | +++ tests/test_jujuci.py 2016-11-01 14:01:39 +0000 | |||
344 | @@ -10,7 +10,6 @@ | |||
345 | 10 | from jujuci import ( | 10 | from jujuci import ( |
346 | 11 | add_artifacts, | 11 | add_artifacts, |
347 | 12 | Artifact, | 12 | Artifact, |
348 | 13 | CERTIFY_UBUNTU_PACKAGES, | ||
349 | 14 | clean_environment, | 13 | clean_environment, |
350 | 15 | Credentials, | 14 | Credentials, |
351 | 16 | CredentialsMissing, | 15 | CredentialsMissing, |
352 | @@ -18,7 +17,6 @@ | |||
353 | 18 | get_artifacts, | 17 | get_artifacts, |
354 | 19 | get_build_data, | 18 | get_build_data, |
355 | 20 | get_buildvars, | 19 | get_buildvars, |
356 | 21 | get_certification_bin, | ||
357 | 22 | get_credentials, | 20 | get_credentials, |
358 | 23 | get_job_data, | 21 | get_job_data, |
359 | 24 | get_juju_bin, | 22 | get_juju_bin, |
360 | @@ -481,33 +479,6 @@ | |||
361 | 481 | JENKINS_URL, credentials, 'build-binary-wacky-a64', 'lastBuild') | 479 | JENKINS_URL, credentials, 'build-binary-wacky-a64', 'lastBuild') |
362 | 482 | self.assertEqual(1, jnf_mock.call_count) | 480 | self.assertEqual(1, jnf_mock.call_count) |
363 | 483 | 481 | ||
364 | 484 | def test_get_certification_bin(self): | ||
365 | 485 | package_namer = PackageNamer('foo', 'bar', 'baz') | ||
366 | 486 | build_data = { | ||
367 | 487 | 'url': 'http://foo/', | ||
368 | 488 | 'artifacts': [{ | ||
369 | 489 | 'fileName': 'juju-core_36.1~0ubuntu1~bar.1_foo.deb', | ||
370 | 490 | 'relativePath': 'baz', | ||
371 | 491 | }] | ||
372 | 492 | } | ||
373 | 493 | credentials = Credentials('jrandom', 'password1') | ||
374 | 494 | |||
375 | 495 | with self.get_juju_binary_mocks() as (workspace, ur_mock, cc_mock): | ||
376 | 496 | with patch('jujuci.get_build_data', return_value=build_data, | ||
377 | 497 | autospec=True) as gbd_mock: | ||
378 | 498 | with patch.object(PackageNamer, 'factory', | ||
379 | 499 | return_value=package_namer): | ||
380 | 500 | bin_loc = get_certification_bin(credentials, | ||
381 | 501 | '36.1~0ubuntu1', | ||
382 | 502 | workspace) | ||
383 | 503 | self.assertEqual(bin_loc, os.path.join( | ||
384 | 504 | workspace, 'extracted-bin', 'subdir', 'sub-subdir', 'juju')) | ||
385 | 505 | ur_mock.assert_called_once_with( | ||
386 | 506 | 'http://jrandom:password1@foo/artifact/baz', | ||
387 | 507 | os.path.join(workspace, 'juju-core_36.1~0ubuntu1~bar.1_foo.deb')) | ||
388 | 508 | gbd_mock.assert_called_once_with( | ||
389 | 509 | JENKINS_URL, credentials, CERTIFY_UBUNTU_PACKAGES, 'lastBuild') | ||
390 | 510 | |||
391 | 511 | @contextmanager | 482 | @contextmanager |
392 | 512 | def get_juju_binary_mocks(self): | 483 | def get_juju_binary_mocks(self): |
393 | 513 | def mock_extract_deb(args): | 484 | def mock_extract_deb(args): |
394 | @@ -749,16 +720,16 @@ | |||
395 | 749 | class TestPackageNamer(TestNamer): | 720 | class TestPackageNamer(TestNamer): |
396 | 750 | 721 | ||
397 | 751 | def test_get_release_package(self): | 722 | def test_get_release_package(self): |
399 | 752 | package_namer = PackageNamer('amd42', '42.34', 'wacky') | 723 | package_namer = PackageNamer('amd42', '18.04', 'wacky') |
400 | 753 | self.assertEqual( | 724 | self.assertEqual( |
403 | 754 | package_namer.get_release_package('27.6'), | 725 | package_namer.get_release_package('1.25'), |
404 | 755 | 'juju-core_27.6-0ubuntu1~42.34.1~juju1_amd42.deb') | 726 | 'juju-core_1.25-0ubuntu1~18.04.1~juju1_amd42.deb') |
405 | 756 | 727 | ||
411 | 757 | def test_get_certification_package(self): | 728 | def test_get_juju_package_name(self): |
412 | 758 | package_namer = PackageNamer('amd42', '42.34', 'wacky') | 729 | self.assertEqual( |
413 | 759 | self.assertEqual( | 730 | 'juju-core', PackageNamer.get_juju_package_name('1.2.3')) |
414 | 760 | package_namer.get_certification_package('27.6~0ubuntu1'), | 731 | self.assertEqual( |
415 | 761 | 'juju-core_27.6~0ubuntu1~42.34.1_amd42.deb') | 732 | 'juju2', PackageNamer.get_juju_package_name('2.2.3')) |
416 | 762 | 733 | ||
417 | 763 | 734 | ||
418 | 764 | class TestJobNamer(TestNamer): | 735 | class TestJobNamer(TestNamer): |
419 | 765 | 736 | ||
420 | === modified file 'tests/test_s3ci.py' | |||
421 | --- tests/test_s3ci.py 2016-02-19 06:41:06 +0000 | |||
422 | +++ tests/test_s3ci.py 2016-11-01 14:01:39 +0000 | |||
423 | @@ -146,11 +146,12 @@ | |||
424 | 146 | return key | 146 | return key |
425 | 147 | 147 | ||
426 | 148 | 148 | ||
428 | 149 | def mock_package_key(revision_build, build=27, distro_release=None): | 149 | def mock_package_key(revision_build, build=27, |
429 | 150 | distro_release=None, version='1.24.0'): | ||
430 | 150 | namer = PackageNamer.factory() | 151 | namer = PackageNamer.factory() |
431 | 151 | if distro_release is not None: | 152 | if distro_release is not None: |
432 | 152 | namer.distro_release = distro_release | 153 | namer.distro_release = distro_release |
434 | 153 | package = namer.get_release_package('109.6') | 154 | package = namer.get_release_package(version) |
435 | 154 | job = JobNamer.factory().get_build_binary_job() | 155 | job = JobNamer.factory().get_build_binary_job() |
436 | 155 | return mock_key(revision_build, job, build, package) | 156 | return mock_key(revision_build, job, build, package) |
437 | 156 | 157 | ||
438 | @@ -177,8 +178,18 @@ | |||
439 | 177 | use_context(self, patch('utility.get_deb_arch', return_value='amd65', | 178 | use_context(self, patch('utility.get_deb_arch', return_value='amd65', |
440 | 178 | autospec=True)) | 179 | autospec=True)) |
441 | 179 | 180 | ||
444 | 180 | def test_find_package_key(self): | 181 | def test_find_package_key_1x(self): |
445 | 181 | key = mock_package_key(390) | 182 | key = mock_package_key(390, version='1.25.0') |
446 | 183 | bucket = mock_bucket([key]) | ||
447 | 184 | namer = JobNamer.factory() | ||
448 | 185 | job = namer.get_build_binary_job() | ||
449 | 186 | found_key, filename = find_package_key(bucket, 390) | ||
450 | 187 | bucket.list.assert_called_once_with(get_job_path(390, job)) | ||
451 | 188 | self.assertIs(key, found_key) | ||
452 | 189 | self.assertEqual(filename, get_key_filename(key)) | ||
453 | 190 | |||
454 | 191 | def test_find_package_key_2x(self): | ||
455 | 192 | key = mock_package_key(390, version='2.1.0') | ||
456 | 182 | bucket = mock_bucket([key]) | 193 | bucket = mock_bucket([key]) |
457 | 183 | namer = JobNamer.factory() | 194 | namer = JobNamer.factory() |
458 | 184 | job = namer.get_build_binary_job() | 195 | job = namer.get_build_binary_job() |
459 | @@ -201,7 +212,7 @@ | |||
460 | 201 | find_package_key(bucket, 390) | 212 | find_package_key(bucket, 390) |
461 | 202 | 213 | ||
462 | 203 | def test_wrong_file(self): | 214 | def test_wrong_file(self): |
464 | 204 | key = mock_package_key(390) | 215 | key = mock_package_key(390, version='1.25.0') |
465 | 205 | key.name = key.name.replace('juju-core', 'juju-dore') | 216 | key.name = key.name.replace('juju-core', 'juju-dore') |
466 | 206 | bucket = FakeBucket([key]) | 217 | bucket = FakeBucket([key]) |
467 | 207 | with self.assertRaises(PackageNotFound): | 218 | with self.assertRaises(PackageNotFound): |