1160921c2d
The /345_require_online_migration_completion cell database migration added in Ocata prevents anyone from upgrading the cell database schema until they have performed the online instance group data migrations via the "nova-manage db online_data_migrations" command. This means we can remove the compatibility code in the InstanceGroup object which performs a lookup routine in the API database and if not found it falls back to the cell database, which at this point should be empty, therefore making that dead code now. The test_get_by_name and test_get_by_hint tests are moved from _TestInstanceGroupListObject to _TestInstanceGroupObject since they don't have anything to do with InstanceGroupList. A follow up change will remove the now unused main DB API methods for instance groups. Change-Id: Ifbd53b13fa0fef62e0329283b73d587f367e46c2
62 lines
2.5 KiB
Python
62 lines
2.5 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from nova.db.sqlalchemy import api_models
|
|
from nova.db.sqlalchemy import models
|
|
from nova import test
|
|
|
|
|
|
# TODO(mriedem): Drop this test when the "main" DB instance group API
|
|
# methods are all removed.
|
|
class InstanceGroupTablesCompareTestCase(test.NoDBTestCase):
|
|
def _get_column_list(self, model):
|
|
column_list = [m.key for m in model.__table__.columns]
|
|
return column_list
|
|
|
|
def _check_column_list(self,
|
|
columns_new,
|
|
columns_old,
|
|
added=None,
|
|
removed=None):
|
|
for c in added or []:
|
|
columns_new.remove(c)
|
|
for c in removed or []:
|
|
columns_old.remove(c)
|
|
intersect = set(columns_new).intersection(set(columns_old))
|
|
if intersect != set(columns_new) or intersect != set(columns_old):
|
|
return False
|
|
return True
|
|
|
|
def _compare_models(self, m_a, m_b,
|
|
added=None, removed=None):
|
|
added = added or []
|
|
removed = removed or ['deleted_at', 'deleted']
|
|
c_a = self._get_column_list(m_a)
|
|
c_b = self._get_column_list(m_b)
|
|
self.assertTrue(self._check_column_list(c_a, c_b,
|
|
added=added,
|
|
removed=removed))
|
|
|
|
def test_tables_instance_groups(self):
|
|
self._compare_models(api_models.InstanceGroup(),
|
|
models.InstanceGroup())
|
|
|
|
def test_tables_instance_group_policy(self):
|
|
self._compare_models(api_models.InstanceGroupPolicy(),
|
|
models.InstanceGroupPolicy())
|
|
|
|
def test_tables_instance_group_member(self):
|
|
self._compare_models(api_models.InstanceGroupMember(),
|
|
models.InstanceGroupMember(),
|
|
added=['instance_uuid'],
|
|
removed=['deleted_at', 'deleted', 'instance_id'])
|