Merge lp:~sinzui/juju-ci-tools/juju-core2 into lp:juju-ci-tools

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
Reviewer Review Type Date Requested Status
Juju Release Engineering Pending
Review via email: mp+309757@code.launchpad.net

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 making a tree of tools and metadata, and lastly publishing the tools.
6 you can skip the tarball and package steps if you just want to publish
7 the juju tools (AKA jujud, servers, agents). If you want to test a fix
8-that is in the juju-core trunk branch, you can make your own release
9+that is in the juju master branch, you can make your own release
10 tarball and package.
11
12 Once juju is published to the test clouds, individual tests can be performed.
13
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 """
19
20 SERIES_TO_NUMBERS = {
21- 'trusty': '14.04',
22- 'precise': '12.04',
23+ 'xenial': '16.04',
24 }
25 JENKINS_KVM = 'JENKINS_KVM'
26 WORKSPACE = 'WORKSPACE'
27@@ -33,8 +32,7 @@
28 def get_package_globs(series, arch):
29 series_number = SERIES_TO_NUMBERS[series]
30 return {
31- 'core': 'juju-core_*%s*_%s.deb' % (series_number, arch),
32- 'local': 'juju-local_*%s*_all.deb' % series_number,
33+ 'juju2': 'juju2_*%s*_%s.deb' % (series_number, arch),
34 }
35
36
37@@ -78,8 +76,7 @@
38 env = os.environ.copy()
39 env['BUILD_FOR'] = '%s:%s' % (series, arch)
40 if package_info is not None:
41- env['JUJU_CORE_PKG'] = package_info['core']
42- env['JUJU_LOCAL_PKG'] = package_info['local']
43+ env['JUJU_CORE_PKG'] = package_info['juju2']
44 builder_path = os.path.join(jenkins_kvm, 'build-juju-local.sh')
45 build_dir = '%s-%s' % (series, arch)
46 logging.info('Building Vagrant box for %s %s' % (series, arch))
47@@ -140,11 +137,8 @@
48 package_info = get_debian_packages(
49 credentials, args.workspace, args.series, args.arch,
50 args.use_ci_juju_packages)
51- if 'core' not in package_info:
52- logging.error('Could not find juju-core package')
53- sys.exit(1)
54- if 'local' not in package_info:
55- logging.error('Could not find juju-local package')
56+ if 'juju2' not in package_info:
57+ logging.error('Could not find juju2 package')
58 sys.exit(1)
59 else:
60 package_info = None
61
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 get_artifacts,
67 get_credentials,
68 JENKINS_URL,
69+ PackageNamer,
70 PUBLISH_REVISION
71 )
72 from utility import (
73@@ -80,7 +81,7 @@
74 if not pr_number:
75 pr_number = find_publish_revision_number(credentials, br_number)
76 get_artifacts(
77- credentials, PUBLISH_REVISION, pr_number, 'juju-core*', candidate_dir,
78+ credentials, PUBLISH_REVISION, pr_number, 'juju*deb', candidate_dir,
79 dry_run=dry_run, verbose=verbose)
80
81
82@@ -95,11 +96,12 @@
83
84
85 def get_package(artifacts_path, version):
86- """Return the path to the expected juju-core package for the localhost."""
87+ """Return the path to the expected juju package for the localhost."""
88 release = subprocess.check_output(['lsb_release', '-sr']).strip()
89 arch = get_deb_arch()
90- package_name = 'juju-core_{}-0ubuntu1~{}.1~juju1_{}.deb'.format(
91- version, release, arch)
92+ deb_name = PackageNamer.get_juju_package_name(version)
93+ package_name = '{}_{}-0ubuntu1~{}.1~juju1_{}.deb'.format(
94+ deb_name, version, release, arch)
95 package_path = os.path.join(artifacts_path, package_name)
96 return package_path
97
98
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 JENKINS_URL = 'http://juju-ci.vapour.ws:8080'
104 BUILD_REVISION = 'build-revision'
105 PUBLISH_REVISION = 'publish-revision'
106-CERTIFY_UBUNTU_PACKAGES = 'certify-ubuntu-packages'
107
108 Artifact = namedtuple('Artifact', ['file_name', 'location'])
109
110@@ -174,13 +173,6 @@
111 return get_juju_binary(credentials, file_name, build_data, workspace)
112
113
114-def get_certification_bin(credentials, version, workspace):
115- build_data = get_build_data(JENKINS_URL, credentials,
116- CERTIFY_UBUNTU_PACKAGES, 'lastBuild')
117- file_name = PackageNamer.factory().get_certification_package(version)
118- return get_juju_binary(credentials, file_name, build_data, workspace)
119-
120-
121 def get_juju_binary(credentials, file_name, build_data, workspace):
122 artifact = get_filename_artifact(file_name, build_data)
123 target_path = os.path.join(workspace, artifact.file_name)
124@@ -340,15 +332,6 @@
125 parser_get_juju_bin.add_argument('workspace', nargs='?', default='.',
126 help='The place to store binaries.')
127 add_credential_args(parser_get_juju_bin)
128- parser_get_certification_bin = subparsers.add_parser(
129- 'get-certification-bin',
130- help='Retrieve and extract juju binaries for certification.')
131- parser_get_certification_bin.add_argument(
132- 'version', help='The version to get certification for.')
133- parser_get_certification_bin.add_argument(
134- 'workspace', nargs='?', default='.',
135- help='The place to store binaries.')
136- add_credential_args(parser_get_certification_bin)
137 parser_get_buildvars = subparsers.add_parser(
138 'get-build-vars',
139 help='Retrieve the build-vars for a build-revision.')
140@@ -424,20 +407,22 @@
141 class PackageNamer(Namer):
142 """A class knows the names of packages."""
143
144+ @staticmethod
145+ def get_juju_package_name(version):
146+ """Return the name of the package based on the Juju version."""
147+ if version.startswith('1.'):
148+ return 'juju-core'
149+ return 'juju2'
150+
151 def get_release_package_suffix(self):
152 return '-0ubuntu1~{distro_release}.1~juju1_{arch}.deb'.format(
153 distro_release=self.distro_release, arch=self.arch)
154
155 def get_release_package(self, version):
156 return (
157- 'juju-core_{version}{suffix}'
158- ).format(version=version, suffix=self.get_release_package_suffix())
159-
160- def get_certification_package(self, version):
161- return (
162- 'juju-core_{version}~{distro_release}.1_{arch}.deb'
163- ).format(version=version, distro_release=self.distro_release,
164- arch=self.arch)
165+ '{deb_name}_{version}{suffix}').format(
166+ deb_name=self.get_juju_package_name(version),
167+ version=version, suffix=self.get_release_package_suffix())
168
169
170 class JobNamer(Namer):
171@@ -471,10 +456,6 @@
172 dry_run=args.dry_run, verbose=args.verbose)
173 elif args.command == 'get-juju-bin':
174 print_now(get_juju_bin(credentials, args.workspace))
175- elif args.command == 'get-certification-bin':
176- path = get_certification_bin(credentials, args.version,
177- args.workspace)
178- print_now(path)
179 elif args.command == 'get-build-vars':
180 text = get_buildvars(
181 credentials, args.build, env=args.env,
182
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
188
189 def get_git_revision_info(branch, revision_spec):
190- """Find the commit and juju-core version of a branch.
191+ """Find the commit and juju version of a branch.
192
193 Returns a tuple comparable to revno, revision-id, version.
194 The revno is always None. The revision-id is the commit hash.
195
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-#!/bin/bash
201-# Download Ubuntu juju packages that match the version under test.
202-set -eu
203-
204-: ${LOCAL_JENKINS_URL=http://juju-ci.vapour.ws:8080}
205-ARTIFACTS_PATH=$WORKSPACE/artifacts
206-
207-: ${SCRIPTS=$(readlink -f $(dirname $0))}
208-export PATH="$SCRIPTS:$PATH"
209-
210-UBUNTU_ARCH="http://archive.ubuntu.com/ubuntu/pool/universe/j/juju-core/"
211-PORTS_ARCH="http://ports.ubuntu.com/pool/universe/j/juju-core/"
212-ALL_ARCHIVES="$UBUNTU_ARCH $PORTS_ARCH"
213-
214-TRUSTY_AMD64="certify-trusty-amd64"
215-TRUSTY_PPC64="certify-trusty-ppc64"
216-TRUSTY_I386="certify-trusty-i386"
217-
218-set -x
219-
220-usage() {
221- echo "usage: $0 VERSION"
222- echo " VERSION: The juju package version to retrive."
223- exit 1
224-}
225-
226-
227-check_deps() {
228- echo "Phase 0: Checking requirements."
229- has_deps=1
230- which lftp || has_deps=0
231- if [[ $has_deps == 0 ]]; then
232- echo "Install lftp."
233- exit 2
234- fi
235-}
236-
237-
238-retrieve_packages() {
239- # Retrieve the $RELEASE packages that contain jujud,
240- # or copy a locally built package.
241- echo "Phase 1: Retrieving juju-core packages from archives"
242- cd $WORKSPACE
243- for archive in $ALL_ARCHIVES; do
244- safe_archive=$(echo "$archive" | sed -e 's,//.*@,//,')
245- echo "checking $safe_archive for $VERSION."
246- lftp -c mirror -I "juju*${VERSION}*.deb" $archive;
247- done
248- if [ -d $WORKSPACE/juju-core ]; then
249- found=$(find $WORKSPACE/juju-core/ -name "*deb")
250- if [[ $found != "" ]]; then
251- mv $WORKSPACE/juju-core/*deb ./
252- fi
253- rm -r $WORKSPACE/juju-core
254- fi
255-}
256-
257-
258-start_series_arch_tests() {
259- [[ -z $TOKEN ]] && return 0
260- encoded_version=$(echo "$VERSION" | sed 's,[+],%2B,')
261- query="token=$TOKEN&VERSION=$encoded_version"
262- for job in $TRUSTY_AMD64 $TRUSTY_PPC64 $TRUSTY_I386; do
263- curl -o /dev/null \
264- "$LOCAL_JENKINS_URL/job/$job/buildWithParameters?$query"
265- done
266-}
267-
268-
269-TOKEN=""
270-while [[ "${1-}" != "" && $1 =~ ^-.* ]]; do
271- case $1 in
272- --start-other-tests)
273- shift
274- TOKEN=$1
275- ;;
276- esac
277- shift
278-done
279-
280-test $# -eq 1 || usage
281-VERSION=$1
282-
283-check_deps
284-retrieve_packages
285-start_series_arch_tests
286
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 suffix = PackageNamer.factory().get_release_package_suffix()
292 filtered = [
293 (k, f) for k, f in filter_keys(keys, suffix)
294- if f.startswith('juju-core_')]
295+ if f.startswith('juju2_') or f.startswith('juju-core_')]
296 if len(filtered) == 0:
297 raise PackageNotFound('Package could not be found.')
298 return sorted(filtered, key=lambda x: int(
299
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 self.assertEqual(options, kwargs)
305 output, args, kwargs = ga_mock.mock_calls[1]
306 self.assertEqual(
307- (credentials, 'publish-revision', 5678, 'juju-core*',
308+ (credentials, 'publish-revision', 5678, 'juju*deb',
309 '~/candidate/1.24.4-artifacts'),
310 args)
311 self.assertEqual(options, kwargs)
312@@ -159,7 +159,26 @@
313 self.assertEqual(
314 ['1.21-artifacts', 'master-artifacts'], sorted(dirs))
315
316- def test_get_package(self):
317+ def test_get_package_2x(self):
318+ def subprocessor(*args, **kwargs):
319+ command = args[0]
320+ if 'lsb_release' in command:
321+ return '14.04'
322+ elif 'dpkg' in command:
323+ return 'amd64'
324+
325+ with patch('subprocess.check_output',
326+ side_effect=subprocessor) as co_mock:
327+ name = get_package('foo', '2.2.3')
328+ self.assertEqual(
329+ 'foo/juju2_2.2.3-0ubuntu1~14.04.1~juju1_amd64.deb', name)
330+ self.assertEqual(2, co_mock.call_count)
331+ output, args, kwargs = co_mock.mock_calls[0]
332+ self.assertEqual((['lsb_release', '-sr'], ), args)
333+ output, args, kwargs = co_mock.mock_calls[1]
334+ self.assertEqual((['dpkg', '--print-architecture'], ), args)
335+
336+ def test_get_package_1x(self):
337 def subprocessor(*args, **kwargs):
338 command = args[0]
339 if 'lsb_release' in command:
340
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 from jujuci import (
346 add_artifacts,
347 Artifact,
348- CERTIFY_UBUNTU_PACKAGES,
349 clean_environment,
350 Credentials,
351 CredentialsMissing,
352@@ -18,7 +17,6 @@
353 get_artifacts,
354 get_build_data,
355 get_buildvars,
356- get_certification_bin,
357 get_credentials,
358 get_job_data,
359 get_juju_bin,
360@@ -481,33 +479,6 @@
361 JENKINS_URL, credentials, 'build-binary-wacky-a64', 'lastBuild')
362 self.assertEqual(1, jnf_mock.call_count)
363
364- def test_get_certification_bin(self):
365- package_namer = PackageNamer('foo', 'bar', 'baz')
366- build_data = {
367- 'url': 'http://foo/',
368- 'artifacts': [{
369- 'fileName': 'juju-core_36.1~0ubuntu1~bar.1_foo.deb',
370- 'relativePath': 'baz',
371- }]
372- }
373- credentials = Credentials('jrandom', 'password1')
374-
375- with self.get_juju_binary_mocks() as (workspace, ur_mock, cc_mock):
376- with patch('jujuci.get_build_data', return_value=build_data,
377- autospec=True) as gbd_mock:
378- with patch.object(PackageNamer, 'factory',
379- return_value=package_namer):
380- bin_loc = get_certification_bin(credentials,
381- '36.1~0ubuntu1',
382- workspace)
383- self.assertEqual(bin_loc, os.path.join(
384- workspace, 'extracted-bin', 'subdir', 'sub-subdir', 'juju'))
385- ur_mock.assert_called_once_with(
386- 'http://jrandom:password1@foo/artifact/baz',
387- os.path.join(workspace, 'juju-core_36.1~0ubuntu1~bar.1_foo.deb'))
388- gbd_mock.assert_called_once_with(
389- JENKINS_URL, credentials, CERTIFY_UBUNTU_PACKAGES, 'lastBuild')
390-
391 @contextmanager
392 def get_juju_binary_mocks(self):
393 def mock_extract_deb(args):
394@@ -749,16 +720,16 @@
395 class TestPackageNamer(TestNamer):
396
397 def test_get_release_package(self):
398- package_namer = PackageNamer('amd42', '42.34', 'wacky')
399+ package_namer = PackageNamer('amd42', '18.04', 'wacky')
400 self.assertEqual(
401- package_namer.get_release_package('27.6'),
402- 'juju-core_27.6-0ubuntu1~42.34.1~juju1_amd42.deb')
403+ package_namer.get_release_package('1.25'),
404+ 'juju-core_1.25-0ubuntu1~18.04.1~juju1_amd42.deb')
405
406- def test_get_certification_package(self):
407- package_namer = PackageNamer('amd42', '42.34', 'wacky')
408- self.assertEqual(
409- package_namer.get_certification_package('27.6~0ubuntu1'),
410- 'juju-core_27.6~0ubuntu1~42.34.1_amd42.deb')
411+ def test_get_juju_package_name(self):
412+ self.assertEqual(
413+ 'juju-core', PackageNamer.get_juju_package_name('1.2.3'))
414+ self.assertEqual(
415+ 'juju2', PackageNamer.get_juju_package_name('2.2.3'))
416
417
418 class TestJobNamer(TestNamer):
419
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 return key
425
426
427-def mock_package_key(revision_build, build=27, distro_release=None):
428+def mock_package_key(revision_build, build=27,
429+ distro_release=None, version='1.24.0'):
430 namer = PackageNamer.factory()
431 if distro_release is not None:
432 namer.distro_release = distro_release
433- package = namer.get_release_package('109.6')
434+ package = namer.get_release_package(version)
435 job = JobNamer.factory().get_build_binary_job()
436 return mock_key(revision_build, job, build, package)
437
438@@ -177,8 +178,18 @@
439 use_context(self, patch('utility.get_deb_arch', return_value='amd65',
440 autospec=True))
441
442- def test_find_package_key(self):
443- key = mock_package_key(390)
444+ def test_find_package_key_1x(self):
445+ key = mock_package_key(390, version='1.25.0')
446+ bucket = mock_bucket([key])
447+ namer = JobNamer.factory()
448+ job = namer.get_build_binary_job()
449+ found_key, filename = find_package_key(bucket, 390)
450+ bucket.list.assert_called_once_with(get_job_path(390, job))
451+ self.assertIs(key, found_key)
452+ self.assertEqual(filename, get_key_filename(key))
453+
454+ def test_find_package_key_2x(self):
455+ key = mock_package_key(390, version='2.1.0')
456 bucket = mock_bucket([key])
457 namer = JobNamer.factory()
458 job = namer.get_build_binary_job()
459@@ -201,7 +212,7 @@
460 find_package_key(bucket, 390)
461
462 def test_wrong_file(self):
463- key = mock_package_key(390)
464+ key = mock_package_key(390, version='1.25.0')
465 key.name = key.name.replace('juju-core', 'juju-dore')
466 bucket = FakeBucket([key])
467 with self.assertRaises(PackageNotFound):

Subscribers

People subscribed via source and target branches