Remove Folsom support

This also fix a new bug that make the test fail for our nova notifier.

Change-Id: I8b5172d482bc57a12eac76aa1c754ef306a32f60
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2013-04-09 14:03:08 +02:00
parent 9eddee1fbe
commit b12335501a
7 changed files with 3 additions and 328 deletions

View File

@ -1,9 +1,8 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 New Dream Network, LLC (DreamHost)
# Copyright © 2013 New Dream Network, LLC (DreamHost)
#
# Author: Julien Danjou <julien@danjou.info>
# Doug Hellmann <doug.hellmann@dreamhost.com>
# Author: Doug Hellmann <doug.hellmann@dreamhost.com>
#
# 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
@ -17,14 +16,6 @@
# License for the specific language governing permissions and limitations
# under the License.
__all__ = [
'notify',
'DeletedInstanceStatsGatherer',
'initialize_gatherer',
'instance_info_source',
'_gatherer', # for tests to mock
]
import sys
from nova import notifications

View File

@ -1,28 +0,0 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2013 New Dream Network, LLC (DreamHost)
#
# Author: Doug Hellmann <doug.hellmann@dreamhost.com>
#
# 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.
# NOTE(dhellmann): The implementations of the notifier for folsom and
# grizzly are completely different. Rather than have lots of checks
# throughout the code, the two implementations are placed in separate
# modules and the right version is imported here.
try:
import nova.conductor
except ImportError:
from .folsom import *
else:
from .grizzly import *

View File

@ -1,66 +0,0 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 New Dream Network, LLC (DreamHost)
#
# Author: Julien Danjou <julien@danjou.info>
#
# 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.
__all__ = [
'notify',
'initialize_manager',
]
from nova import db as instance_info_source
from oslo.config import cfg
from ceilometer.compute import manager as compute_manager
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log as logging
# This module runs inside the nova compute
# agent, which only configures the "nova" logger.
# We use a fake logger name in that namespace
# so that messages from this module appear
# in the log file.
LOG = logging.getLogger('nova.ceilometer.notifier')
_agent_manager = None
def initialize_manager(agent_manager=None):
global _agent_manager
if not agent_manager:
cfg.CONF(args=[], project='ceilometer', prog='ceilometer-agent')
# Instantiate a manager
_agent_manager = compute_manager.AgentManager()
else:
_agent_manager = agent_manager
_agent_manager.setup_notifier_task()
def notify(context, message):
global _agent_manager
# Initialize the global config object as though it was in the
# compute agent process so that the ceilometer copy of the rpc
# modules will know how to communicate.
if _agent_manager is None:
initialize_manager()
if message['event_type'] == 'compute.instance.delete.start':
instance_id = message['payload']['instance_id']
LOG.debug(_('polling final stats for %r'), instance_id)
_agent_manager.poll_instance(context,
instance_info_source.instance_get_by_uuid(
context,
instance_id))

View File

@ -1,195 +0,0 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 New Dream Network, LLC (DreamHost)
#
# Author: Julien Danjou <julien@danjou.info>
#
# 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 ceilometer.compute.nova_notifier
"""
# FIXME(dhellmann): Temporarily disable these tests so we can get a
# fix to go through Jenkins.
import nose.plugins.skip
raise nose.SkipTest('Skipping until config conflict in notifier is fixed')
# FIXME(dhellmann)
import mock
import datetime
from stevedore import extension
from stevedore.tests import manager as test_manager
from ceilometer.compute import manager
from nova.tests import fake_network
# XXX Folsom compat
from nova import flags
nova_CONF = flags.FLAGS
from nova import db
from nova import context
from nova import service # For nova_CONF.compute_manager
from nova.compute import vm_states
# Needed for flags option, but Essex does not have it
try:
from nova.openstack.common.notifier import api as notifier_api
except ImportError:
notifier_api = None
from ceilometer import counter
from ceilometer.tests import base
from ceilometer.tests import skip
from ceilometer.compute import nova_notifier
from ceilometer.openstack.common import importutils
class TestNovaNotifier(base.TestCase):
class Pollster(object):
counters = []
test_data = counter.Counter(
name='test',
type=counter.TYPE_CUMULATIVE,
unit='',
volume=1,
user_id='test',
project_id='test',
resource_id='test_run_tasks',
timestamp=datetime.datetime.utcnow().isoformat(),
resource_metadata={'name': 'Pollster',
},
)
def get_counters(self, manager, instance):
self.counters.append((manager, instance))
return [self.test_data]
def get_counter_names(self):
return ['test']
def fake_db_instance_get(self, context, id_):
if self.instance['uuid'] == id_:
return mock.MagicMock(name=self.instance['name'],
id=self.instance['uuid'])
@staticmethod
def do_nothing(*args, **kwargs):
pass
@staticmethod
def fake_db_instance_system_metadata_get(context, uuid):
return dict(meta_a=123, meta_b="foobar")
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
@skip.skip_unless(notifier_api, "Notifier API not found")
def setUp(self):
super(TestNovaNotifier, self).setUp()
nova_CONF.compute_driver = 'nova.virt.fake.FakeDriver'
nova_CONF.notification_driver = [nova_notifier.__name__]
nova_CONF.rpc_backend = 'ceilometer.openstack.common.rpc.impl_fake'
self.compute = importutils.import_object(nova_CONF.compute_manager)
self.context = context.get_admin_context()
fake_network.set_stub_network_methods(self.stubs)
self.instance = {"name": "instance-1",
"id": 1,
"image_ref": "FAKE",
"user_id": "FAKE",
"project_id": "FAKE",
"display_name": "FAKE NAME",
"hostname": "abcdef",
"reservation_id": "FAKE RID",
"instance_type_id": 1,
"architecture": "x86",
"memory_mb": "1024",
"root_gb": "20",
"ephemeral_gb": "0",
"vcpus": 1,
"host": "fakehost",
"availability_zone":
"1e3ce043029547f1a61c1996d1a531a4",
"created_at": '2012-05-08 20:23:41',
"os_type": "linux",
"kernel_id": "kernelid",
"ramdisk_id": "ramdiskid",
"vm_state": vm_states.ACTIVE,
"access_ip_v4": "someip",
"access_ip_v6": "someip",
"metadata": {},
"uuid": "144e08f4-00cb-11e2-888e-5453ed1bbb5f",
"system_metadata": {}}
self.stubs.Set(db, 'instance_info_cache_delete', self.do_nothing)
self.stubs.Set(db, 'instance_destroy', self.do_nothing)
self.stubs.Set(db, 'instance_system_metadata_get',
self.fake_db_instance_system_metadata_get)
self.stubs.Set(db, 'block_device_mapping_get_all_by_instance',
lambda context, instance: {})
self.stubs.Set(db, 'instance_update_and_get_original',
lambda context, uuid, kwargs: (self.instance,
self.instance))
agent_manager = manager.AgentManager()
agent_manager.pollster_manager = \
test_manager.TestExtensionManager([
extension.Extension('test',
None,
None,
self.Pollster(),
),
])
nova_notifier.initialize_manager(agent_manager)
def tearDown(self):
self.Pollster.counters = []
super(TestNovaNotifier, self).tearDown()
nova_notifier._agent_manager = None
def test_notifications(self):
# Folsom compatibility check
try:
import nova.conductor.api
except ImportError:
# Folsom does not have nova.conductor, and it is safe to
# call this method directly, but not safe to mock it
# because mock.patch() fails to find the original.
self.stubs.Set(db, 'instance_get_by_uuid',
self.fake_db_instance_get)
self.compute.terminate_instance(self.context,
instance=self.instance)
else:
# Under Grizzly, Nova has moved to no-db access on the
# compute node. The compute manager uses RPC to talk to
# the conductor. We need to disable communication between
# the nova manager and the remote system since we can't
# expect the message bus to be available, or the remote
# controller to be there if the message bus is online.
@mock.patch.object(self.compute, 'conductor_api')
# The code that looks up the instance uses a global
# reference to the API, so we also have to patch that to
# return our fake data.
@mock.patch.object(nova.conductor.api.API,
'instance_get_by_uuid',
self.fake_db_instance_get)
def run_test(*omit_args):
self.compute.terminate_instance(self.context,
instance=self.instance)
run_test()
self.assertTrue(self.Pollster.counters)
self.assertTrue(self.Pollster.counters[0])
self.assertEqual(self.Pollster.counters[0][0],
nova_notifier._agent_manager)
self.assertEqual(self.Pollster.counters[0][1].id,
self.instance['uuid'])
self.assertEqual(len(self.Pollster.counters), 1)

View File

@ -1,17 +0,0 @@
http://tarballs.openstack.org/nova/nova-stable-folsom.tar.gz
nose
unittest2
coverage
mock
mox
# NOTE(dhellmann): Ming is necessary to provide the Mongo-in-memory
# implementation of MongoDB.
# NOTE(jd): the support for finalize in map reduce in MIM is not yet merged
# git+http://git.naquadah.org/git/~jd/merciless.git#egg=Ming
http://tarballs.openstack.org/glance/glance-stable-folsom.tar.gz
setuptools-git>=0.4
# 1.7.4 is the Folsom release
http://tarballs.openstack.org/swift/swift-stable-folsom.tar.gz
# Swift dep that is not necessary if we depend on swift>1.7.5
netifaces
python-spidermonkey

12
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
envlist = py26,py27,py26-folsom,py27-folsom,pep8,hacking
envlist = py26,py27,pep8,hacking
[testenv]
deps = -r{toxinidir}/tools/test-requires
@ -43,16 +43,6 @@ deps = -r{toxinidir}/tools/test-requires
sphinxcontrib-httpdomain
commands = {posargs}
[testenv:py26-folsom]
basepython = python2.6
deps = -r{toxinidir}/tools/test-requires-folsom
-r{toxinidir}/tools/pip-requires
[testenv:py27-folsom]
basepython = python2.7
deps = -r{toxinidir}/tools/test-requires-folsom
-r{toxinidir}/tools/pip-requires
[testenv:pyflakes]
deps = -r{toxinidir}/tools/test-requires
-r{toxinidir}/tools/pip-requires