From: Andrew Woodward Date: Wed, 25 Sep 2013 19:18:11 +0000 (-0700) Subject: Update catch_mon_errors and tests X-Git-Tag: v1.2.7~9^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F91%2Fhead;p=ceph-deploy.git Update catch_mon_errors and tests change mon_initial_members test in mon.catch_mon_errors to be able to catch None result correctly add second test to test_mon to ensure both None and not hostname in .. are tested Signed-off-by: Andrew Woodward (awoodward@mirantis.com) --- diff --git a/ceph_deploy/mon.py b/ceph_deploy/mon.py index 6eb6de5..5f50d26 100644 --- a/ceph_deploy/mon.py +++ b/ceph_deploy/mon.py @@ -59,8 +59,7 @@ def catch_mon_errors(conn, logger, hostname, cfg): for mon in monmap.get('mons', [{}]) if mon.get('name') == hostname ] - if mon_initial_members: - if not hostname in mon_initial_members: + if mon_initial_members is None or not hostname in mon_initial_members: logger.warning('%s is not defined in `mon initial members`', hostname) if not mon_in_monmap: logger.warning('monitor %s does not exist in monmap', hostname) diff --git a/ceph_deploy/tests/test_mon.py b/ceph_deploy/tests/test_mon.py index 8a1ab5c..35a1298 100644 --- a/ceph_deploy/tests/test_mon.py +++ b/ceph_deploy/tests/test_mon.py @@ -38,6 +38,16 @@ class TestCatchCommonErrors(object): expected_msg = 'is not defined in `mon initial members`' self.assert_logger_message(self.logger.warning, expected_msg) + def test_warn_if_host_not_in_intial_members(self): + fake_conn = make_fake_conn() + cfg = make_fake_conf() + cfg.add_section('global') + cfg.set('global', 'mon initial members', 'AAAA') + mon.catch_mon_errors(fake_conn, self.logger, 'host', cfg) + expected_msg = 'is not defined in `mon initial members`' + self.assert_logger_message(self.logger.warning, expected_msg) + + def test_warn_if_not_mon_in_monmap(self): fake_conn = make_fake_conn() cfg = make_fake_conf()