summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-01-30 15:08:36 +0000
committerGerrit Code Review <review@openstack.org>2019-01-30 15:08:36 +0000
commit034a4837c4929b47b2bf4d738f0f14751be23b5c (patch)
treec6a29fe5ac0ebe1700d4bf695dd8844bb01d0eef
parent53118a29eb5ecda3019facc6c61602eca21a9a90 (diff)
parent52accd6f82893fe167a78eabe8cdf30dfa0bc841 (diff)
Merge "Add test for data migration version"
-rw-r--r--glance/tests/unit/test_data_migration_version.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/glance/tests/unit/test_data_migration_version.py b/glance/tests/unit/test_data_migration_version.py
new file mode 100644
index 0000000..a014838
--- /dev/null
+++ b/glance/tests/unit/test_data_migration_version.py
@@ -0,0 +1,59 @@
1# Copyright 2019 Red Hat, Inc.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import six
17import testtools
18
19from glance.db.migration import CURRENT_RELEASE
20from glance.version import version_info
21
22
23class TestDataMigrationVersion(testtools.TestCase):
24
25 def test_migration_version(self):
26 """Make sure the data migration version info has been updated."""
27
28 release_number = int(version_info.version_string().split('.', 1)[0])
29
30 # by rule, release names must be composed of the 26 letters of the
31 # ISO Latin alphabet (ord('A')==65, ord('Z')==90)
32 release_letter = six.text_type(CURRENT_RELEASE[:1].upper()).encode(
33 'ascii')
34
35 # Convert release letter into an int in [1:26]. The first
36 # glance release was 'Bexar'.
37 converted_release_letter = (ord(release_letter) -
38 ord(u'B'.encode('ascii')) + 1)
39
40 # Project the release number into [1:26]
41 converted_release_number = release_number % 26
42
43 # Prepare for the worst with a super-informative message
44 msg = ('\n\n'
45 'EMERGENCY!\n'
46 'glance.db.migration.CURRENT_RELEASE is out of sync '
47 'with the glance version.\n'
48 ' CURRENT_RELEASE: %s\n'
49 ' glance version: %s\n'
50 'glance.db.migration.CURRENT_RELEASE needs to be '
51 'updated IMMEDIATELY.\n'
52 'The gate will be wedged until the update is made.\n'
53 'EMERGENCY!\n'
54 '\n') % (CURRENT_RELEASE,
55 version_info.version_string())
56
57 self.assertEqual(converted_release_letter,
58 converted_release_number,
59 msg)