]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
all test_cli_mon tests passing
authorAlfredo Deza <alfredo@deza.pe>
Wed, 17 Jul 2013 18:55:11 +0000 (14:55 -0400)
committerAlfredo Deza <alfredo@deza.pe>
Wed, 17 Jul 2013 18:55:11 +0000 (14:55 -0400)
ceph_deploy/test/test_cli_mon.py

index f4677272cfeabb16cff24c836725530e6e15efc1..16eb165f5dc7801fbc7f1e7f2012df1a8de8eec9 100644 (file)
@@ -9,6 +9,8 @@ from .. import mon
 
 from .directory import directory
 
+def fake_getaddrinfo(*a, **kw):
+    return [[0,0,0,0,'host1']]
 
 def test_help(tmpdir, cli):
     with cli(
@@ -42,15 +44,13 @@ def test_bad_no_mon(tmpdir, cli):
             args=['ceph-deploy', 'mon'],
             stderr=subprocess.PIPE,
             ) as p:
-            got = p.stderr.read()
-            assert got == """\
-ceph-deploy: No hosts specified to deploy to.
-"""
-
-    assert err.value.status == 1
+            result = p.stderr.read()
+    assert 'usage: ceph-deploy mon' in result
+    assert 'too few arguments' in result
+    assert err.value.status == 2
 
 
-def test_simple(tmpdir):
+def test_simple(tmpdir, capsys):
     with tmpdir.join('ceph.conf').open('w') as f:
         f.write("""\
 [global]
@@ -75,29 +75,22 @@ mon initial members = host1
     mock_compiled[mon.create_mon].side_effect = _create_mon
 
     try:
-        with directory(str(tmpdir)):
-            main(
-                args=['-v', 'mon'],
-                namespace=ns,
-                )
+        with mock.patch('socket.getaddrinfo', fake_getaddrinfo):
+            with directory(str(tmpdir)):
+                main(
+                    args=['-v', 'new', 'host1'],
+                    namespace=ns,
+                    )
+                main(
+                    args=['-v', 'mon', 'create', 'host1'],
+                    namespace=ns,
+                    )
     except SystemExit as e:
         raise AssertionError('Unexpected exit: %s', e)
-
-    ns.pushy.assert_called_once_with('ssh+sudo:host1')
-
-    mock_compiled.pop(mon.write_conf).assert_called_once_with(
-        cluster='ceph',
-        conf="""\
-[global]
-fsid = 6ede5564-3cf1-44b5-aa96-1c77b0c3e1d0
-mon_initial_members = host1
-
-""",
-        )
-
-    mock_compiled.pop(mon.create_mon).assert_called_once_with(
-        cluster='ceph',
-        get_monitor_secret=mock.ANY,
-        )
-
-    assert mock_compiled == {}
+    out, err = capsys.readouterr()
+    err = err.lower()
+    assert 'creating new cluster named ceph' in err
+    assert 'monitor host1 at h' in err
+    assert 'resolving host host1' in err
+    assert "monitor initial members are ['host1']" in err
+    assert "monitor addrs are ['h']" in err