Skip to content

Commit

Permalink
ceph-volume tests ensure activate behavior with systemd disabling
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
  • Loading branch information
alfredodeza committed Nov 8, 2018
1 parent 18ddd96 commit 3e80118
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions src/ceph-volume/ceph_volume/tests/devices/simple/test_activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,89 @@ def test_main_spits_help_with_no_arguments(self, capsys):
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):
Expand Down

0 comments on commit 3e80118

Please sign in to comment.