Merge lp:~soren/swift/versioning into lp:~hudson-openstack/swift/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: John Dickinson
Approved revision: 304
Merged at revision: 301
Proposed branch: lp:~soren/swift/versioning
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 81 lines (+55/-2)
3 files modified
setup.py (+1/-1)
swift/__init__.py (+17/-1)
test/unit/common/test_init.py (+37/-0)
To merge this branch: bzr merge lp:~soren/swift/versioning
Reviewer Review Type Date Requested Status
Swift Core security contacts Pending
Review via email: mp+62439@code.launchpad.net

Commit message

Add a __canonical_version__ attribute to the swift module. This is only the numbered part of the version string, no "-dev" or similar suffixes.

Add a couple of unit tests to make sure __version__ and __canonical_version__ are generated correctly and to ensure __canonical_version__ never accidentally has anything other than numbers and points in it.

Description of the change

This aligns the release process for all of Swift, Glance and Nova.

__canonical_version__ should be used for anything that affects the release process in any way. E.g. the directory name in the generated tarball, versioned path elements in documentation, etc. As soon as work commences on a release (e.g. once 1.4.0 and you start working on 1.4.1), this version is bumped to '1.4.1'. This ensures that all the automation that has been set up and has run against trunk throughout the dev cycle will apply in exactly the same way to the final release instead of having the release be different in various ways. This reduces the chance of error.

__version__ is constructed of __canonical_version__ + '-dev'. It can be used in documentation *strings* (not path elements), in logs, etc.

It may look like overkill with the class in the swift/__init__.py, but my first couple of attempts without it made testing this stuff quite awkward, and since it's covered by unit tests, it should be safe enough.

To post a comment you must log in.
Revision history for this message
Thierry Carrez (ttx) wrote :

I think that should be (1.4.0, False): the idea would be to switch to (1.4.0, True) at release time on the release branch.

Revision history for this message
John Dickinson (notmyname) wrote :

also, pep8

Revision history for this message
Thierry Carrez (ttx) wrote :

Also this shouldn't be accepted before Jenkins is tweaked to use timestamps instead of bzrREV, to avoid collisions between branches.

Revision history for this message
Soren Hansen (soren) wrote :

> also, pep8

Oh, I got the distinct impression you didn't care about pep8.

/me fixes.

Revision history for this message
Soren Hansen (soren) wrote :

The Jenkins magic is now in place and this should be ready for merge.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :
Download full text (78.6 KiB)

The attempt to merge lp:~soren/swift/versioning into lp:swift failed. Below is the output from the failed tests.

running test
running egg_info
creating swift.egg-info
writing swift.egg-info/PKG-INFO
writing top-level names to swift.egg-info/top_level.txt
writing dependency_links to swift.egg-info/dependency_links.txt
writing entry points to swift.egg-info/entry_points.txt
writing manifest file 'swift.egg-info/SOURCES.txt'
reading manifest file 'swift.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'ChangeLog'
writing manifest file 'swift.egg-info/SOURCES.txt'
running build_ext

UNABLE TO READ FUNCTIONAL TESTS CONFIG FILE
UNABLE TO READ FUNCTIONAL TESTS CONFIG FILE
SKIPPING FUNCTIONAL TESTS DUE TO NO CONFIG
testAccountHead (test.functional.tests.TestAccount) ... SKIP
testContainerListing (test.functional.tests.TestAccount) ... SKIP
testContainerSerializedInfo (test.functional.tests.TestAccount) ... SKIP
testContainersOrderedByName (test.functional.tests.TestAccount) ... SKIP
testInvalidAuthToken (test.functional.tests.TestAccount) ... SKIP
testInvalidPath (test.functional.tests.TestAccount) ... SKIP
testInvalidUTF8Path (test.functional.tests.TestAccount) ... SKIP
testLastContainerMarker (test.functional.tests.TestAccount) ... SKIP
testListingLimit (test.functional.tests.TestAccount) ... SKIP
testMarkerLimitContainerList (test.functional.tests.TestAccount) ... SKIP
testNoAuthToken (test.functional.tests.TestAccount) ... SKIP
testPUT (test.functional.tests.TestAccount) ... SKIP
testVersionOnlyPath (test.functional.tests.TestAccount) ... SKIP
testGetRequest (test.functional.tests.TestAccountNoContainers) ... SKIP
testGetRequest (test.functional.tests.TestAccountNoContainersUTF8) ... SKIP
testAccountHead (test.functional.tests.TestAccountUTF8) ... SKIP
testContainerListing (test.functional.tests.TestAccountUTF8) ... SKIP
testContainerSerializedInfo (test.functional.tests.TestAccountUTF8) ... SKIP
testContainersOrderedByName (test.functional.tests.TestAccountUTF8) ... SKIP
testInvalidAuthToken (test.functional.tests.TestAccountUTF8) ... SKIP
testInvalidPath (test.functional.tests.TestAccountUTF8) ... SKIP
testInvalidUTF8Path (test.functional.tests.TestAccountUTF8) ... SKIP
testLastContainerMarker (test.functional.tests.TestAccountUTF8) ... SKIP
testListingLimit (test.functional.tests.TestAccountUTF8) ... SKIP
testMarkerLimitContainerList (test.functional.tests.TestAccountUTF8) ... SKIP
testNoAuthToken (test.functional.tests.TestAccountUTF8) ... SKIP
testPUT (test.functional.tests.TestAccountUTF8) ... SKIP
testVersionOnlyPath (test.functional.tests.TestAccountUTF8) ... SKIP
testContainerExistenceCachingProblem (test.functional.tests.TestContainer) ... SKIP
testContainerFileList (test.functional.tests.TestContainer) ... SKIP
testContainerFileListOnContainerThatDoesNotExist (test.functional.tests.TestContainer) ... SKIP
testContainerFileListWithLimit (test.functional.tests.TestContainer) ... SKIP
testContainerInfo (test.functional.tests.TestContainer) ... SKIP
testContainerInfoOnContainerThatDoesNotExist (test.functional.tests.TestContainer) ... SKIP
testContainerNameLimit (test.functional.tests.TestCont...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2011-05-12 21:24:51 +0000
3+++ setup.py 2011-05-26 14:29:28 +0000
4@@ -23,7 +23,7 @@
5 except ImportError:
6 frontend = None
7
8-from swift import __version__ as version
9+from swift import __canonical_version__ as version
10
11
12 class local_sdist(sdist):
13
14=== modified file 'swift/__init__.py'
15--- swift/__init__.py 2011-04-15 09:54:32 +0000
16+++ swift/__init__.py 2011-05-26 14:29:28 +0000
17@@ -1,5 +1,21 @@
18 import gettext
19
20
21-__version__ = '1.4-dev'
22+class Version(object):
23+ def __init__(self, canonical_version, final):
24+ self.canonical_version = canonical_version
25+ self.final = final
26+
27+ @property
28+ def pretty_version(self):
29+ if self.final:
30+ return self.canonical_version
31+ else:
32+ return '%s-dev' % (self.canonical_version,)
33+
34+
35+_version = Version('1.4.0', False)
36+__version__ = _version.pretty_version
37+__canonical_version__ = _version.canonical_version
38+
39 gettext.install('swift')
40
41=== added file 'test/unit/common/test_init.py'
42--- test/unit/common/test_init.py 1970-01-01 00:00:00 +0000
43+++ test/unit/common/test_init.py 2011-05-26 14:29:28 +0000
44@@ -0,0 +1,37 @@
45+# Copyright (c) 2010-2011 OpenStack, LLC.
46+#
47+# Licensed under the Apache License, Version 2.0 (the "License");
48+# you may not use this file except in compliance with the License.
49+# You may obtain a copy of the License at
50+#
51+# http://www.apache.org/licenses/LICENSE-2.0
52+#
53+# Unless required by applicable law or agreed to in writing, software
54+# distributed under the License is distributed on an "AS IS" BASIS,
55+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
56+# implied.
57+# See the License for the specific language governing permissions and
58+# limitations under the License.
59+
60+import re
61+import unittest
62+import swift
63+
64+class TestVersioning(unittest.TestCase):
65+ def test_canonical_version_is_clean(self):
66+ """Ensure that a non-clean canonical_version never happens"""
67+ pattern = re.compile('^\d+(\.\d+)*$')
68+ self.assertTrue(pattern.match(swift.__canonical_version__) is not None)
69+
70+ def test_canonical_version_equals_version_for_final(self):
71+ version = swift.Version('7.8.9', True)
72+ self.assertEquals(version.pretty_version, '7.8.9')
73+ self.assertEquals(version.canonical_version, '7.8.9')
74+
75+ def test_version_has_dev_suffix_for_non_final(self):
76+ version = swift.Version('7.8.9', False)
77+ self.assertEquals(version.pretty_version, '7.8.9-dev')
78+ self.assertEquals(version.canonical_version, '7.8.9')
79+
80+if __name__ == '__main__':
81+ unittest.main()