]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
Update catch_mon_errors and tests 91/head
authorAndrew Woodward <awoodward@mirantis.com>
Wed, 25 Sep 2013 19:18:11 +0000 (12:18 -0700)
committerAndrew Woodward <awoodward@mirantis.com>
Wed, 25 Sep 2013 19:18:11 +0000 (12:18 -0700)
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)
ceph_deploy/mon.py
ceph_deploy/tests/test_mon.py

index 6eb6de5fbf5b41f4f9063b6862764a402420d488..5f50d266b0c565f95295056af2dbcead448f7aff 100644 (file)
@@ -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)
index 8a1ab5c28fb2f0143ecbc683edc14a546ca1a112..35a12983f6845e93f844d07fce5b948c91a961ef 100644 (file)
@@ -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()