]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests ensure activate behavior with systemd disabling 25012/head
authorAlfredo Deza <alfredo@deza.pe>
Thu, 8 Nov 2018 19:14:17 +0000 (14:14 -0500)
committerAlfredo Deza <adeza@redhat.com>
Fri, 9 Nov 2018 19:59:49 +0000 (14:59 -0500)
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
(cherry picked from commit 3e80118ccaccaa61e92b01f4f389d6056401d8a7)

src/ceph-volume/ceph_volume/tests/devices/simple/test_activate.py

index da3b955a054713142ad8c8b954994b41e35fbe84..a275bdd00689cd3f6c6fa4147eeca74a416c804c 100644 (file)
@@ -23,6 +23,89 @@ class TestActivate(object):
         assert 'Activate OSDs by mounting devices previously configured' in stdout
 
 
+class TestEnableSystemdUnits(object):
+
+    def test_nothing_is_activated(self, tmpfile, is_root, capsys):
+        json_config = tmpfile(contents='{}')
+        activation = activate.Activate(['--no-systemd', '--file', json_config, '0', '1234'], from_trigger=True)
+        activation.activate = lambda x: True
+        activation.main()
+        activation.enable_systemd_units('0', '1234')
+        out, err = capsys.readouterr()
+        assert 'Skipping enabling of `simple`' in out
+        assert 'Skipping masking of ceph-disk' in out
+        assert 'Skipping enabling and starting OSD simple' in out
+
+    def test_no_systemd_flag_is_true(self, tmpfile, is_root):
+        json_config = tmpfile(contents='{}')
+        activation = activate.Activate(['--no-systemd', '--file', json_config, '0', '1234'], from_trigger=True)
+        activation.activate = lambda x: True
+        activation.main()
+        assert activation.skip_systemd is True
+
+    def test_no_systemd_flag_is_false(self, tmpfile, is_root):
+        json_config = tmpfile(contents='{}')
+        activation = activate.Activate(['--file', json_config, '0', '1234'], from_trigger=True)
+        activation.activate = lambda x: True
+        activation.main()
+        assert activation.skip_systemd is False
+
+    def test_masks_ceph_disk(self, tmpfile, is_root, monkeypatch, capture):
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.mask_ceph_disk', capture)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.enable_volume', lambda *a: True)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.enable_osd', lambda *a: True)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.start_osd', lambda *a: True)
+
+        json_config = tmpfile(contents='{}')
+        activation = activate.Activate(['--file', json_config, '0', '1234'], from_trigger=False)
+        activation.activate = lambda x: True
+        activation.main()
+        activation.enable_systemd_units('0', '1234')
+        assert len(capture.calls) == 1
+
+    def test_enables_simple_unit(self, tmpfile, is_root, monkeypatch, capture):
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.mask_ceph_disk', lambda *a: True)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.enable_volume', capture)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.enable_osd', lambda *a: True)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.start_osd', lambda *a: True)
+
+        json_config = tmpfile(contents='{}')
+        activation = activate.Activate(['--file', json_config, '0', '1234'], from_trigger=False)
+        activation.activate = lambda x: True
+        activation.main()
+        activation.enable_systemd_units('0', '1234')
+        assert len(capture.calls) == 1
+        assert capture.calls[0]['args'] == ('0', '1234', 'simple')
+
+    def test_enables_osd_unit(self, tmpfile, is_root, monkeypatch, capture):
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.mask_ceph_disk', lambda *a: True)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.enable_volume', lambda *a: True)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.enable_osd', capture)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.start_osd', lambda *a: True)
+
+        json_config = tmpfile(contents='{}')
+        activation = activate.Activate(['--file', json_config, '0', '1234'], from_trigger=False)
+        activation.activate = lambda x: True
+        activation.main()
+        activation.enable_systemd_units('0', '1234')
+        assert len(capture.calls) == 1
+        assert capture.calls[0]['args'] == ('0',)
+
+    def test_starts_osd_unit(self, tmpfile, is_root, monkeypatch, capture):
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.mask_ceph_disk', lambda *a: True)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.enable_volume', lambda *a: True)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.enable_osd', lambda *a: True)
+        monkeypatch.setattr('ceph_volume.systemd.systemctl.start_osd', capture)
+
+        json_config = tmpfile(contents='{}')
+        activation = activate.Activate(['--file', json_config, '0', '1234'], from_trigger=False)
+        activation.activate = lambda x: True
+        activation.main()
+        activation.enable_systemd_units('0', '1234')
+        assert len(capture.calls) == 1
+        assert capture.calls[0]['args'] == ('0',)
+
+
 class TestValidateDevices(object):
 
     def test_filestore_missing_journal(self):