Fixing conflicts
This commit is contained in:
1
Authors
1
Authors
@@ -59,6 +59,7 @@ Mark Washenberger <mark.washenberger@rackspace.com>
|
|||||||
Masanori Itoh <itoumsn@nttdata.co.jp>
|
Masanori Itoh <itoumsn@nttdata.co.jp>
|
||||||
Matt Dietz <matt.dietz@rackspace.com>
|
Matt Dietz <matt.dietz@rackspace.com>
|
||||||
Michael Gundlach <michael.gundlach@rackspace.com>
|
Michael Gundlach <michael.gundlach@rackspace.com>
|
||||||
|
Mike Scherbakov <mihgen@gmail.com>
|
||||||
Monsyne Dragon <mdragon@rackspace.com>
|
Monsyne Dragon <mdragon@rackspace.com>
|
||||||
Monty Taylor <mordred@inaugust.com>
|
Monty Taylor <mordred@inaugust.com>
|
||||||
MORITA Kazutaka <morita.kazutaka@gmail.com>
|
MORITA Kazutaka <morita.kazutaka@gmail.com>
|
||||||
|
|||||||
@@ -536,7 +536,7 @@ class FloatingIpCommands(object):
|
|||||||
for floating_ip in floating_ips:
|
for floating_ip in floating_ips:
|
||||||
instance = None
|
instance = None
|
||||||
if floating_ip['fixed_ip']:
|
if floating_ip['fixed_ip']:
|
||||||
instance = floating_ip['fixed_ip']['instance']['ec2_id']
|
instance = floating_ip['fixed_ip']['instance']['hostname']
|
||||||
print "%s\t%s\t%s" % (floating_ip['host'],
|
print "%s\t%s\t%s" % (floating_ip['host'],
|
||||||
floating_ip['address'],
|
floating_ip['address'],
|
||||||
instance)
|
instance)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
NOVA_KEY_DIR=$(dirname $(readlink -f ${BASH_SOURCE}))
|
NOVARC=$(readlink -f "${BASH_SOURCE:-${0}}" 2>/dev/null) ||
|
||||||
|
NOVARC=$(python -c 'import os,sys; print os.path.abspath(os.path.realpath(sys.argv[1]))' "${BASH_SOURCE:-${0}}")
|
||||||
|
NOVA_KEY_DIR=${NOVARC%/*}
|
||||||
export EC2_ACCESS_KEY="%(access)s:%(project)s"
|
export EC2_ACCESS_KEY="%(access)s:%(project)s"
|
||||||
export EC2_SECRET_KEY="%(secret)s"
|
export EC2_SECRET_KEY="%(secret)s"
|
||||||
export EC2_URL="%(ec2)s"
|
export EC2_URL="%(ec2)s"
|
||||||
|
|||||||
@@ -296,6 +296,7 @@ DEFINE_bool('fake_network', False,
|
|||||||
'should we use fake network devices and addresses')
|
'should we use fake network devices and addresses')
|
||||||
DEFINE_string('rabbit_host', 'localhost', 'rabbit host')
|
DEFINE_string('rabbit_host', 'localhost', 'rabbit host')
|
||||||
DEFINE_integer('rabbit_port', 5672, 'rabbit port')
|
DEFINE_integer('rabbit_port', 5672, 'rabbit port')
|
||||||
|
DEFINE_bool('rabbit_use_ssl', False, 'connect over SSL')
|
||||||
DEFINE_string('rabbit_userid', 'guest', 'rabbit userid')
|
DEFINE_string('rabbit_userid', 'guest', 'rabbit userid')
|
||||||
DEFINE_string('rabbit_password', 'guest', 'rabbit password')
|
DEFINE_string('rabbit_password', 'guest', 'rabbit password')
|
||||||
DEFINE_string('rabbit_virtual_host', '/', 'rabbit virtual host')
|
DEFINE_string('rabbit_virtual_host', '/', 'rabbit virtual host')
|
||||||
|
|||||||
10
nova/log.py
10
nova/log.py
@@ -35,6 +35,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import nova
|
||||||
from nova import flags
|
from nova import flags
|
||||||
from nova import version
|
from nova import version
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ flags.DEFINE_list('default_log_levels',
|
|||||||
'eventlet.wsgi.server=WARN'],
|
'eventlet.wsgi.server=WARN'],
|
||||||
'list of logger=LEVEL pairs')
|
'list of logger=LEVEL pairs')
|
||||||
flags.DEFINE_bool('use_syslog', False, 'output to syslog')
|
flags.DEFINE_bool('use_syslog', False, 'output to syslog')
|
||||||
|
flags.DEFINE_bool('publish_errors', False, 'publish error events')
|
||||||
flags.DEFINE_string('logfile', None, 'output to named file')
|
flags.DEFINE_string('logfile', None, 'output to named file')
|
||||||
|
|
||||||
|
|
||||||
@@ -258,12 +260,20 @@ class NovaRootLogger(NovaLogger):
|
|||||||
else:
|
else:
|
||||||
self.removeHandler(self.filelog)
|
self.removeHandler(self.filelog)
|
||||||
self.addHandler(self.streamlog)
|
self.addHandler(self.streamlog)
|
||||||
|
if FLAGS.publish_errors:
|
||||||
|
self.addHandler(PublishErrorsHandler(ERROR))
|
||||||
if FLAGS.verbose:
|
if FLAGS.verbose:
|
||||||
self.setLevel(DEBUG)
|
self.setLevel(DEBUG)
|
||||||
else:
|
else:
|
||||||
self.setLevel(INFO)
|
self.setLevel(INFO)
|
||||||
|
|
||||||
|
|
||||||
|
class PublishErrorsHandler(logging.Handler):
|
||||||
|
def emit(self, record):
|
||||||
|
nova.notifier.api.notify('nova.error.publisher', 'error_notification',
|
||||||
|
nova.notifier.api.ERROR, dict(error=record.msg))
|
||||||
|
|
||||||
|
|
||||||
def handle_exception(type, value, tb):
|
def handle_exception(type, value, tb):
|
||||||
extra = {}
|
extra = {}
|
||||||
if FLAGS.verbose:
|
if FLAGS.verbose:
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class Connection(carrot_connection.BrokerConnection):
|
|||||||
if new or not hasattr(cls, '_instance'):
|
if new or not hasattr(cls, '_instance'):
|
||||||
params = dict(hostname=FLAGS.rabbit_host,
|
params = dict(hostname=FLAGS.rabbit_host,
|
||||||
port=FLAGS.rabbit_port,
|
port=FLAGS.rabbit_port,
|
||||||
|
ssl=FLAGS.rabbit_use_ssl,
|
||||||
userid=FLAGS.rabbit_userid,
|
userid=FLAGS.rabbit_userid,
|
||||||
password=FLAGS.rabbit_password,
|
password=FLAGS.rabbit_password,
|
||||||
virtual_host=FLAGS.rabbit_virtual_host)
|
virtual_host=FLAGS.rabbit_virtual_host)
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class JsonFilter(HostFilter):
|
|||||||
required_disk = instance_type['local_gb']
|
required_disk = instance_type['local_gb']
|
||||||
query = ['and',
|
query = ['and',
|
||||||
['>=', '$compute.host_memory_free', required_ram],
|
['>=', '$compute.host_memory_free', required_ram],
|
||||||
['>=', '$compute.disk_available', required_disk]
|
['>=', '$compute.disk_available', required_disk],
|
||||||
]
|
]
|
||||||
return (self._full_name(), json.dumps(query))
|
return (self._full_name(), json.dumps(query))
|
||||||
|
|
||||||
|
|||||||
@@ -69,16 +69,16 @@ class FakeZoneAwareScheduler(zone_aware_scheduler.ZoneAwareScheduler):
|
|||||||
class FakeZoneManager(zone_manager.ZoneManager):
|
class FakeZoneManager(zone_manager.ZoneManager):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.service_states = {
|
self.service_states = {
|
||||||
'host1': {
|
'host1': {
|
||||||
'compute': {'ram': 1000}
|
'compute': {'ram': 1000},
|
||||||
},
|
},
|
||||||
'host2': {
|
'host2': {
|
||||||
'compute': {'ram': 2000}
|
'compute': {'ram': 2000},
|
||||||
},
|
},
|
||||||
'host3': {
|
'host3': {
|
||||||
'compute': {'ram': 3000}
|
'compute': {'ram': 3000},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class FakeEmptyZoneManager(zone_manager.ZoneManager):
|
class FakeEmptyZoneManager(zone_manager.ZoneManager):
|
||||||
|
|||||||
205
nova/tests/test_host_filter.py
Normal file
205
nova/tests/test_host_filter.py
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
# Copyright 2011 OpenStack LLC.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 Scheduler Host Filters.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
from nova import exception
|
||||||
|
from nova import flags
|
||||||
|
from nova import test
|
||||||
|
from nova.scheduler import host_filter
|
||||||
|
|
||||||
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
|
||||||
|
class FakeZoneManager:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class HostFilterTestCase(test.TestCase):
|
||||||
|
"""Test case for host filters."""
|
||||||
|
|
||||||
|
def _host_caps(self, multiplier):
|
||||||
|
# Returns host capabilities in the following way:
|
||||||
|
# host1 = memory:free 10 (100max)
|
||||||
|
# disk:available 100 (1000max)
|
||||||
|
# hostN = memory:free 10 + 10N
|
||||||
|
# disk:available 100 + 100N
|
||||||
|
# in other words: hostN has more resources than host0
|
||||||
|
# which means ... don't go above 10 hosts.
|
||||||
|
return {'host_name-description': 'XenServer %s' % multiplier,
|
||||||
|
'host_hostname': 'xs-%s' % multiplier,
|
||||||
|
'host_memory_total': 100,
|
||||||
|
'host_memory_overhead': 10,
|
||||||
|
'host_memory_free': 10 + multiplier * 10,
|
||||||
|
'host_memory_free-computed': 10 + multiplier * 10,
|
||||||
|
'host_other-config': {},
|
||||||
|
'host_ip_address': '192.168.1.%d' % (100 + multiplier),
|
||||||
|
'host_cpu_info': {},
|
||||||
|
'disk_available': 100 + multiplier * 100,
|
||||||
|
'disk_total': 1000,
|
||||||
|
'disk_used': 0,
|
||||||
|
'host_uuid': 'xxx-%d' % multiplier,
|
||||||
|
'host_name-label': 'xs-%s' % multiplier}
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.old_flag = FLAGS.default_host_filter
|
||||||
|
FLAGS.default_host_filter = \
|
||||||
|
'nova.scheduler.host_filter.AllHostsFilter'
|
||||||
|
self.instance_type = dict(name='tiny',
|
||||||
|
memory_mb=50,
|
||||||
|
vcpus=10,
|
||||||
|
local_gb=500,
|
||||||
|
flavorid=1,
|
||||||
|
swap=500,
|
||||||
|
rxtx_quota=30000,
|
||||||
|
rxtx_cap=200)
|
||||||
|
|
||||||
|
self.zone_manager = FakeZoneManager()
|
||||||
|
states = {}
|
||||||
|
for x in xrange(10):
|
||||||
|
states['host%02d' % (x + 1)] = {'compute': self._host_caps(x)}
|
||||||
|
self.zone_manager.service_states = states
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
FLAGS.default_host_filter = self.old_flag
|
||||||
|
|
||||||
|
def test_choose_filter(self):
|
||||||
|
# Test default filter ...
|
||||||
|
hf = host_filter.choose_host_filter()
|
||||||
|
self.assertEquals(hf._full_name(),
|
||||||
|
'nova.scheduler.host_filter.AllHostsFilter')
|
||||||
|
# Test valid filter ...
|
||||||
|
hf = host_filter.choose_host_filter(
|
||||||
|
'nova.scheduler.host_filter.InstanceTypeFilter')
|
||||||
|
self.assertEquals(hf._full_name(),
|
||||||
|
'nova.scheduler.host_filter.InstanceTypeFilter')
|
||||||
|
# Test invalid filter ...
|
||||||
|
try:
|
||||||
|
host_filter.choose_host_filter('does not exist')
|
||||||
|
self.fail("Should not find host filter.")
|
||||||
|
except exception.SchedulerHostFilterNotFound:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_all_host_filter(self):
|
||||||
|
hf = host_filter.AllHostsFilter()
|
||||||
|
cooked = hf.instance_type_to_filter(self.instance_type)
|
||||||
|
hosts = hf.filter_hosts(self.zone_manager, cooked)
|
||||||
|
self.assertEquals(10, len(hosts))
|
||||||
|
for host, capabilities in hosts:
|
||||||
|
self.assertTrue(host.startswith('host'))
|
||||||
|
|
||||||
|
def test_instance_type_filter(self):
|
||||||
|
hf = host_filter.InstanceTypeFilter()
|
||||||
|
# filter all hosts that can support 50 ram and 500 disk
|
||||||
|
name, cooked = hf.instance_type_to_filter(self.instance_type)
|
||||||
|
self.assertEquals('nova.scheduler.host_filter.InstanceTypeFilter',
|
||||||
|
name)
|
||||||
|
hosts = hf.filter_hosts(self.zone_manager, cooked)
|
||||||
|
self.assertEquals(6, len(hosts))
|
||||||
|
just_hosts = [host for host, caps in hosts]
|
||||||
|
just_hosts.sort()
|
||||||
|
self.assertEquals('host05', just_hosts[0])
|
||||||
|
self.assertEquals('host10', just_hosts[5])
|
||||||
|
|
||||||
|
def test_json_filter(self):
|
||||||
|
hf = host_filter.JsonFilter()
|
||||||
|
# filter all hosts that can support 50 ram and 500 disk
|
||||||
|
name, cooked = hf.instance_type_to_filter(self.instance_type)
|
||||||
|
self.assertEquals('nova.scheduler.host_filter.JsonFilter', name)
|
||||||
|
hosts = hf.filter_hosts(self.zone_manager, cooked)
|
||||||
|
self.assertEquals(6, len(hosts))
|
||||||
|
just_hosts = [host for host, caps in hosts]
|
||||||
|
just_hosts.sort()
|
||||||
|
self.assertEquals('host05', just_hosts[0])
|
||||||
|
self.assertEquals('host10', just_hosts[5])
|
||||||
|
|
||||||
|
# Try some custom queries
|
||||||
|
|
||||||
|
raw = ['or',
|
||||||
|
['and',
|
||||||
|
['<', '$compute.host_memory_free', 30],
|
||||||
|
['<', '$compute.disk_available', 300],
|
||||||
|
],
|
||||||
|
['and',
|
||||||
|
['>', '$compute.host_memory_free', 70],
|
||||||
|
['>', '$compute.disk_available', 700],
|
||||||
|
],
|
||||||
|
]
|
||||||
|
|
||||||
|
cooked = json.dumps(raw)
|
||||||
|
hosts = hf.filter_hosts(self.zone_manager, cooked)
|
||||||
|
|
||||||
|
self.assertEquals(5, len(hosts))
|
||||||
|
just_hosts = [host for host, caps in hosts]
|
||||||
|
just_hosts.sort()
|
||||||
|
for index, host in zip([1, 2, 8, 9, 10], just_hosts):
|
||||||
|
self.assertEquals('host%02d' % index, host)
|
||||||
|
|
||||||
|
raw = ['not',
|
||||||
|
['=', '$compute.host_memory_free', 30],
|
||||||
|
]
|
||||||
|
cooked = json.dumps(raw)
|
||||||
|
hosts = hf.filter_hosts(self.zone_manager, cooked)
|
||||||
|
|
||||||
|
self.assertEquals(9, len(hosts))
|
||||||
|
just_hosts = [host for host, caps in hosts]
|
||||||
|
just_hosts.sort()
|
||||||
|
for index, host in zip([1, 2, 4, 5, 6, 7, 8, 9, 10], just_hosts):
|
||||||
|
self.assertEquals('host%02d' % index, host)
|
||||||
|
|
||||||
|
raw = ['in', '$compute.host_memory_free', 20, 40, 60, 80, 100]
|
||||||
|
cooked = json.dumps(raw)
|
||||||
|
hosts = hf.filter_hosts(self.zone_manager, cooked)
|
||||||
|
|
||||||
|
self.assertEquals(5, len(hosts))
|
||||||
|
just_hosts = [host for host, caps in hosts]
|
||||||
|
just_hosts.sort()
|
||||||
|
for index, host in zip([2, 4, 6, 8, 10], just_hosts):
|
||||||
|
self.assertEquals('host%02d' % index, host)
|
||||||
|
|
||||||
|
# Try some bogus input ...
|
||||||
|
raw = ['unknown command', ]
|
||||||
|
cooked = json.dumps(raw)
|
||||||
|
try:
|
||||||
|
hf.filter_hosts(self.zone_manager, cooked)
|
||||||
|
self.fail("Should give KeyError")
|
||||||
|
except KeyError, e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.assertTrue(hf.filter_hosts(self.zone_manager, json.dumps([])))
|
||||||
|
self.assertTrue(hf.filter_hosts(self.zone_manager, json.dumps({})))
|
||||||
|
self.assertTrue(hf.filter_hosts(self.zone_manager, json.dumps(
|
||||||
|
['not', True, False, True, False])))
|
||||||
|
|
||||||
|
try:
|
||||||
|
hf.filter_hosts(self.zone_manager, json.dumps(
|
||||||
|
'not', True, False, True, False))
|
||||||
|
self.fail("Should give KeyError")
|
||||||
|
except KeyError, e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.assertFalse(hf.filter_hosts(self.zone_manager,
|
||||||
|
json.dumps(['=', '$foo', 100])))
|
||||||
|
self.assertFalse(hf.filter_hosts(self.zone_manager,
|
||||||
|
json.dumps(['=', '$.....', 100])))
|
||||||
|
self.assertFalse(hf.filter_hosts(self.zone_manager,
|
||||||
|
json.dumps(
|
||||||
|
['>', ['and', ['or', ['not', ['<', ['>=', ['<=', ['in', ]]]]]]]])))
|
||||||
|
|
||||||
|
self.assertFalse(hf.filter_hosts(self.zone_manager,
|
||||||
|
json.dumps(['=', {}, ['>', '$missing....foo']])))
|
||||||
@@ -18,6 +18,7 @@ import eventlet
|
|||||||
import mox
|
import mox
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from xml.etree.ElementTree import fromstring as xml_to_tree
|
from xml.etree.ElementTree import fromstring as xml_to_tree
|
||||||
@@ -160,6 +161,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
'vcpus': 2,
|
'vcpus': 2,
|
||||||
'project_id': 'fake',
|
'project_id': 'fake',
|
||||||
'bridge': 'br101',
|
'bridge': 'br101',
|
||||||
|
'image_id': '123456',
|
||||||
'instance_type_id': '5'} # m1.small
|
'instance_type_id': '5'} # m1.small
|
||||||
|
|
||||||
def lazy_load_library_exists(self):
|
def lazy_load_library_exists(self):
|
||||||
@@ -280,6 +282,68 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
instance_data = dict(self.test_instance)
|
instance_data = dict(self.test_instance)
|
||||||
self._check_xml_and_container(instance_data)
|
self._check_xml_and_container(instance_data)
|
||||||
|
|
||||||
|
def test_snapshot(self):
|
||||||
|
FLAGS.image_service = 'nova.image.fake.FakeImageService'
|
||||||
|
|
||||||
|
# Only file-based instance storages are supported at the moment
|
||||||
|
test_xml = """
|
||||||
|
<domain type='kvm'>
|
||||||
|
<devices>
|
||||||
|
<disk type='file'>
|
||||||
|
<source file='filename'/>
|
||||||
|
</disk>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
||||||
|
"""
|
||||||
|
|
||||||
|
class FakeVirtDomain(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def snapshotCreateXML(self, *args):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def XMLDesc(self, *args):
|
||||||
|
return test_xml
|
||||||
|
|
||||||
|
def fake_lookup(instance_name):
|
||||||
|
if instance_name == instance_ref.name:
|
||||||
|
return FakeVirtDomain()
|
||||||
|
|
||||||
|
def fake_execute(*args):
|
||||||
|
# Touch filename to pass 'with open(out_path)'
|
||||||
|
open(args[-1], "a").close()
|
||||||
|
|
||||||
|
# Start test
|
||||||
|
image_service = utils.import_object(FLAGS.image_service)
|
||||||
|
|
||||||
|
# Assuming that base image already exists in image_service
|
||||||
|
instance_ref = db.instance_create(self.context, self.test_instance)
|
||||||
|
properties = {'instance_id': instance_ref['id'],
|
||||||
|
'user_id': str(self.context.user_id)}
|
||||||
|
snapshot_name = 'test-snap'
|
||||||
|
sent_meta = {'name': snapshot_name, 'is_public': False,
|
||||||
|
'status': 'creating', 'properties': properties}
|
||||||
|
# Create new image. It will be updated in snapshot method
|
||||||
|
# To work with it from snapshot, the single image_service is needed
|
||||||
|
recv_meta = image_service.create(context, sent_meta)
|
||||||
|
|
||||||
|
self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn')
|
||||||
|
connection.LibvirtConnection._conn.lookupByName = fake_lookup
|
||||||
|
self.mox.StubOutWithMock(connection.utils, 'execute')
|
||||||
|
connection.utils.execute = fake_execute
|
||||||
|
|
||||||
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
|
conn = connection.LibvirtConnection(False)
|
||||||
|
conn.snapshot(instance_ref, recv_meta['id'])
|
||||||
|
|
||||||
|
snapshot = image_service.show(context, recv_meta['id'])
|
||||||
|
self.assertEquals(snapshot['properties']['image_state'], 'available')
|
||||||
|
self.assertEquals(snapshot['status'], 'active')
|
||||||
|
self.assertEquals(snapshot['name'], snapshot_name)
|
||||||
|
|
||||||
def test_multi_nic(self):
|
def test_multi_nic(self):
|
||||||
instance_data = dict(self.test_instance)
|
instance_data = dict(self.test_instance)
|
||||||
network_info = _create_network_info(2)
|
network_info = _create_network_info(2)
|
||||||
@@ -645,6 +709,8 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
count = (0 <= str(e.message).find('Unexpected method call'))
|
count = (0 <= str(e.message).find('Unexpected method call'))
|
||||||
|
|
||||||
|
shutil.rmtree(os.path.join(FLAGS.instances_path, instance.name))
|
||||||
|
|
||||||
self.assertTrue(count)
|
self.assertTrue(count)
|
||||||
|
|
||||||
def test_get_host_ip_addr(self):
|
def test_get_host_ip_addr(self):
|
||||||
|
|||||||
@@ -13,10 +13,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import nova
|
import stubout
|
||||||
|
|
||||||
|
import nova
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import flags
|
from nova import flags
|
||||||
|
from nova import log
|
||||||
from nova import rpc
|
from nova import rpc
|
||||||
import nova.notifier.api
|
import nova.notifier.api
|
||||||
from nova.notifier.api import notify
|
from nova.notifier.api import notify
|
||||||
@@ -24,8 +26,6 @@ from nova.notifier import no_op_notifier
|
|||||||
from nova.notifier import rabbit_notifier
|
from nova.notifier import rabbit_notifier
|
||||||
from nova import test
|
from nova import test
|
||||||
|
|
||||||
import stubout
|
|
||||||
|
|
||||||
|
|
||||||
class NotifierTestCase(test.TestCase):
|
class NotifierTestCase(test.TestCase):
|
||||||
"""Test case for notifications"""
|
"""Test case for notifications"""
|
||||||
@@ -115,3 +115,22 @@ class NotifierTestCase(test.TestCase):
|
|||||||
notify('publisher_id',
|
notify('publisher_id',
|
||||||
'event_type', 'DEBUG', dict(a=3))
|
'event_type', 'DEBUG', dict(a=3))
|
||||||
self.assertEqual(self.test_topic, 'testnotify.debug')
|
self.assertEqual(self.test_topic, 'testnotify.debug')
|
||||||
|
|
||||||
|
def test_error_notification(self):
|
||||||
|
self.stubs.Set(nova.flags.FLAGS, 'notification_driver',
|
||||||
|
'nova.notifier.rabbit_notifier')
|
||||||
|
self.stubs.Set(nova.flags.FLAGS, 'publish_errors', True)
|
||||||
|
LOG = log.getLogger('nova')
|
||||||
|
LOG.setup_from_flags()
|
||||||
|
msgs = []
|
||||||
|
|
||||||
|
def mock_cast(context, topic, data):
|
||||||
|
msgs.append(data)
|
||||||
|
|
||||||
|
self.stubs.Set(nova.rpc, 'cast', mock_cast)
|
||||||
|
LOG.error('foo')
|
||||||
|
self.assertEqual(1, len(msgs))
|
||||||
|
msg = msgs[0]
|
||||||
|
self.assertEqual(msg['event_type'], 'error_notification')
|
||||||
|
self.assertEqual(msg['priority'], 'ERROR')
|
||||||
|
self.assertEqual(msg['payload']['error'], 'foo')
|
||||||
|
|||||||
Reference in New Issue
Block a user