summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Rosmaita <rosmaita.fossdev@gmail.com>2019-01-22 12:22:39 -0500
committerBrian Rosmaita <rosmaita.fossdev@gmail.com>2019-01-24 11:38:50 -0500
commit52accd6f82893fe167a78eabe8cdf30dfa0bc841 (patch)
tree3db9f7ac07f542ac6d0c7b0eabda9c7bf3b0877d
parent437ba3ee9b361b33e8918b804bd35f25a722457c (diff)
Add test for data migration version
Detect when the CURRENT_VERSION constant used by the database migration code is out of sync with the version number of the current release. Change-Id: I9e8b5ee98c6c111aaf065cb310906d6442f5f79a
Notes
Notes (review): Code-Review+2: Abhishek Kekane <akekane@redhat.com> Code-Review+2: Sean McGinnis <sean.mcginnis@gmail.com> Workflow+1: Sean McGinnis <sean.mcginnis@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 30 Jan 2019 15:08:36 +0000 Reviewed-on: https://review.openstack.org/632517 Project: openstack/glance Branch: refs/heads/master
-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)