Removed deadline, version, extra & host_aggregate

As we are about to version the Watcher objects, we need to make sure
that upcoming model/object modifications are additive in order to
avoid having to bump the major version of the API. Therefore,
this changeset removes 4 unused DB fields that were exposed in their
associated Watcher objects (i.e. AuditTemplate and Audit).

Change-Id: Ifb0783f21cd66db16b31e3c8e376fc9d6c07dea3
Partially-Implements: blueprint watcher-versioned-objects
This commit is contained in:
Vincent Françoise
2016-10-03 14:38:49 +02:00
parent 750e6bf213
commit ed95d621f4
21 changed files with 50 additions and 184 deletions

View File

@@ -1,52 +0,0 @@
# 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.
"""Tests for custom SQLAlchemy types via Magnum DB."""
from oslo_db import exception as db_exc
from watcher.common import utils as w_utils
from watcher.db import api as dbapi
import watcher.db.sqlalchemy.api as sa_api
from watcher.db.sqlalchemy import models
from watcher.tests.db import base
class SqlAlchemyCustomTypesTestCase(base.DbTestCase):
def setUp(self):
super(SqlAlchemyCustomTypesTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
def test_JSONEncodedDict_default_value(self):
# Create audit_template w/o extra
audit_template1_id = w_utils.generate_uuid()
self.dbapi.create_audit_template({'uuid': audit_template1_id,
'goal_id': "DUMMY"})
audit_template1 = sa_api.model_query(models.AuditTemplate) \
.filter_by(uuid=audit_template1_id).one()
self.assertEqual({}, audit_template1.extra)
def test_JSONEncodedDict_extra_value(self):
# Create audit_template with extra
audit_template2_id = w_utils.generate_uuid()
self.dbapi.create_audit_template({'uuid': audit_template2_id,
'goal_id': "DUMMY",
'extra': {'bar': 'foo'}})
audit_template2 = sa_api.model_query(models.AuditTemplate) \
.filter_by(uuid=audit_template2_id).one()
self.assertEqual('foo', audit_template2.extra['bar'])
def test_JSONEncodedDict_type_check(self):
self.assertRaises(db_exc.DBError,
self.dbapi.create_audit_template,
{'extra': ['this is not a dict']})

View File

@@ -278,7 +278,6 @@ class DbActionPlanTestCase(base.DbTestCase):
id=2,
audit_type='ONESHOT',
uuid=w_utils.generate_uuid(),
deadline=None,
state=ap_objects.State.ONGOING)
action_plan1 = self._create_test_action_plan(
id=1,

View File

@@ -291,13 +291,11 @@ class DbAuditTestCase(base.DbTestCase):
id=1,
audit_type=objects.audit.AuditType.ONESHOT.value,
uuid=w_utils.generate_uuid(),
deadline=None,
state=objects.audit.State.ONGOING)
audit2 = self._create_test_audit(
id=2,
audit_type='CONTINUOUS',
uuid=w_utils.generate_uuid(),
deadline=None,
state=objects.audit.State.PENDING)
res = self.dbapi.get_audit_list(

View File

@@ -273,15 +273,21 @@ class DbAuditTemplateTestCase(base.DbTestCase):
uuid=w_utils.generate_uuid(),
name='My Audit Template 1',
description='Description of my audit template 1',
goal='DUMMY',
extra={'automatic': True})
goal='DUMMY')
audit_template2 = self._create_test_audit_template(
id=2,
uuid=w_utils.generate_uuid(),
name='My Audit Template 2',
description='Description of my audit template 2',
goal='DUMMY',
extra={'automatic': True})
goal='DUMMY')
res = self.dbapi.get_audit_template_list(
self.context, filters={'name': 'My Audit Template 1'})
self.assertEqual([audit_template1['id']], [r.id for r in res])
res = self.dbapi.get_audit_template_list(
self.context, filters={'name': 'Does not exist'})
self.assertEqual([], [r.id for r in res])
res = self.dbapi.get_audit_template_list(
self.context,

View File

@@ -28,12 +28,10 @@ def get_test_audit_template(**kwargs):
'strategy_id': kwargs.get('strategy_id', None),
'name': kwargs.get('name', 'My Audit Template'),
'description': kwargs.get('description', 'Desc. Of My Audit Template'),
'extra': kwargs.get('extra', {'automatic': False}),
'version': kwargs.get('version', 'v1'),
'scope': kwargs.get('scope', []),
'created_at': kwargs.get('created_at'),
'updated_at': kwargs.get('updated_at'),
'deleted_at': kwargs.get('deleted_at'),
'scope': kwargs.get('scope', []),
}
@@ -59,7 +57,6 @@ def get_test_audit(**kwargs):
'uuid': kwargs.get('uuid', '10a47dd1-4874-4298-91cf-eff046dbdb8d'),
'audit_type': kwargs.get('audit_type', 'ONESHOT'),
'state': kwargs.get('state'),
'deadline': kwargs.get('deadline'),
'created_at': kwargs.get('created_at'),
'updated_at': kwargs.get('updated_at'),
'deleted_at': kwargs.get('deleted_at'),