Example #1
0
 def test_is_disabled_5(self, po, log):
     """
     test for AttributeError
     """
     cephprocesses.__grains__ = {'host': 'a_host'}
     po.return_value.communicate.return_value = ("\n", "")
     with pytest.raises(AttributeError):
         ret = cephprocesses.SystemdUnit('ganesha.nfsd').is_disabled
         assert ret is False
         log.error.assert_called_with('Could not decode type->')
Example #2
0
 def test_is_disabled_6(self, po, log):
     """
     stderr
     """
     cephprocesses.__grains__ = {'host': 'a_host'}
     po.return_value.communicate.return_value = ("", "stderr")
     ret = cephprocesses.SystemdUnit('ceph-mon').is_disabled
     assert ret is False
     log.error.assert_called_once_with(
         'Requesting the is-enabled flag from ceph-mon@a_host has resulted in stderr'
     )
Example #3
0
 def test_is_disabled_3(self, po, log):
     """
     po returns 'undefinded\n'
     log should be called. (once)
     """
     cephprocesses.__grains__ = {'host': 'a_host'}
     po.return_value.communicate.return_value = (b"undefined\n ", "")
     ret = cephprocesses.SystemdUnit('ceph-mon').is_disabled
     assert ret is False
     log.info.assert_called_once_with(
         'Expected to get disabled/enabled but got undefined instead')
Example #4
0
 def test_is_disabled_2(self, po, log):
     """
     po returns 'disabled\n'
     log should be called. (once)
     """
     cephprocesses.__grains__ = {'host': 'a_host'}
     po.return_value.communicate.return_value = (b"disabled\n ", "")
     ret = cephprocesses.SystemdUnit('ceph-mon').is_disabled
     assert ret is True
     log.info.assert_called_once_with(
         'Found ceph-mon@a_host to be disabled')
Example #5
0
 def test_is_disabled_4(self, po, log):
     """
     multiple entries in self.service_names
     one is enabled, one is disabled.
     expect to get True
     log should be called. (twice)
     """
     cephprocesses.__grains__ = {'host': 'a_host'}
     po.return_value.communicate.side_effect = [(b"enabled\n ", ""),
                                                (b"disabled\n ", "")]
     ret = cephprocesses.SystemdUnit('ganesha.nfsd').is_disabled
     assert ret is True
     log.info.assert_called_with('Found rpcbind to be disabled')
Example #6
0
 def test_is_disabled_no_service_names(self, popen_mock):
     ret = cephprocesses.SystemdUnit().is_disabled
     assert ret is False
Example #7
0
 def test_service_names_ganesha(self, proc_name):
     obj = cephprocesses.SystemdUnit(proc_name)
     assert obj.service_names == ['nfs-ganesha', 'rpcbind']
Example #8
0
 def test_service_names_lrbd(self, proc_name):
     obj = cephprocesses.SystemdUnit(proc_name)
     assert obj.service_names == ['lrbd']
Example #9
0
 def test_service_names_with_grains_non_default(self, proc_name):
     cephprocesses.__grains__ = {'host': 'a_host'}
     obj = cephprocesses.SystemdUnit(proc_name)
     assert obj.service_names == ['{}@{}'.format('ceph-radosgw', 'a_host')]
Example #10
0
 def test_service_names_osd(self):
     obj = cephprocesses.SystemdUnit('ceph-osd', 1)
     assert obj.service_names == ['ceph-osd@1']
Example #11
0
 def test_service_names_osd_no_id(self):
     obj = cephprocesses.SystemdUnit('ceph-osd')
     assert obj.service_names == []
Example #12
0
 def test_service_names_default_return(self):
     obj = cephprocesses.SystemdUnit()
     assert obj.service_names == []
 def test_service_names_with_grains_default(self, proc_name):
     cephprocesses.__grains__ = {'host': 'a_host'}
     cephprocesses.__salt__ = {'mds.get_name': mds.get_name}
     obj = cephprocesses.SystemdUnit(proc_name)
     assert obj.service_names == ['{}@{}'.format(proc_name, 'a_host')]