def test_get_service_info_unavailable(self, mock_helper): mock_helper.return_value = mock.MagicMock() mock_helper.return_value.ps.return_value = [] mock_helper.return_value.dpkg_l.return_value = [] inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(actual['release'], 'unknown')
def test_get_ceph_pg_imbalance_unavailable(self, mock_helper): mock_helper.return_value = mock.MagicMock() mock_helper.return_value.ceph_osd_df_tree.return_value = [] inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertFalse('osd-pgs-suboptimal' in actual) self.assertFalse('osd-pgs-near-limit' in actual)
def test_get_ceph_pg_imbalance(self, mock_helper): result = self.setup_fake_cli_osds_imbalanced_pgs(mock_helper) inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(actual['osd-pgs-suboptimal'], result['osd-pgs-suboptimal']) self.assertEqual(actual['osd-pgs-near-limit'], result['osd-pgs-near-limit'])
def test_get_local_osd_info(self): fsid = "48858aa1-71a3-4f0e-95f3-a07d1d9a6749" expected = { 0: { 'dev': '/dev/mapper/crypt-{}'.format(fsid), 'fsid': fsid, 'rss': '317M' } } inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(actual["local-osds"], expected)
def test_ceph_cluster_info_large_omap_pgs(self, mock_cli): expected = { '2.f': { 'pool': 'foo', 'last_scrub_stamp': '2021-09-16T21:26:00.00', 'last_deep_scrub_stamp': '2021-09-16T21:26:00.00' } } mock_cli.return_value = mock.MagicMock() mock_cli.return_value.ceph_pg_dump_json_decoded.return_value = \ PG_DUMP_JSON_DECODED inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(actual['large-omap-pgs'], expected)
def test_get_service_info(self): svc_info = { 'systemd': { 'enabled': [ 'ceph-crash', 'ceph-mgr', 'ceph-mon', ], 'disabled': ['ceph-mds', 'ceph-osd', 'ceph-radosgw', 'ceph-volume'], 'generated': ['radosgw'], 'masked': ['ceph-create-keys'] }, 'ps': ['ceph-crash (1)', 'ceph-mgr (1)', 'ceph-mon (1)'] } inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(actual['services'], svc_info) self.assertEqual(actual['release'], 'octopus') self.assertEqual(actual['status'], 'HEALTH_WARN')
def test_get_package_info(self): inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) expected = [ 'ceph 15.2.14-0ubuntu0.20.04.2', 'ceph-base 15.2.14-0ubuntu0.20.04.2', 'ceph-common 15.2.14-0ubuntu0.20.04.2', 'ceph-mds 15.2.14-0ubuntu0.20.04.2', 'ceph-mgr 15.2.14-0ubuntu0.20.04.2', 'ceph-mgr-modules-core 15.2.14-0ubuntu0.20.04.2', 'ceph-mon 15.2.14-0ubuntu0.20.04.2', 'ceph-osd 15.2.14-0ubuntu0.20.04.2', 'python3-ceph-argparse 15.2.14-0ubuntu0.20.04.2', 'python3-ceph-common 15.2.14-0ubuntu0.20.04.2', 'python3-cephfs 15.2.14-0ubuntu0.20.04.2', 'python3-rados 15.2.14-0ubuntu0.20.04.2', 'python3-rbd 15.2.14-0ubuntu0.20.04.2', 'radosgw 15.2.14-0ubuntu0.20.04.2' ] self.assertEqual(actual["dpkg"], expected)
def test_get_network_info(self): expected = { 'cluster': { 'eth0@if17': { 'addresses': ['10.0.0.123'], 'hwaddr': '00:16:3e:ae:9e:44', 'state': 'UP', 'speed': '10000Mb/s' } }, 'public': { 'eth0@if17': { 'addresses': ['10.0.0.123'], 'hwaddr': '00:16:3e:ae:9e:44', 'state': 'UP', 'speed': '10000Mb/s' } } } inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(actual['network'], expected)
def test_get_network_info(self): expected = { 'cluster': { 'br-ens3': { 'addresses': ['10.0.0.128'], 'hwaddr': '22:c2:7b:1c:12:1b', 'state': 'UP', 'speed': 'unknown' } }, 'public': { 'br-ens3': { 'addresses': ['10.0.0.128'], 'hwaddr': '22:c2:7b:1c:12:1b', 'state': 'UP', 'speed': 'unknown' } } } inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(actual['network'], expected)
def test_ceph_cluster_info(self): expected = { 'crush-rules': { 'replicated_rule': { 'id': 0, 'pools': [ 'device_health_metrics (1)', 'glance (2)', 'cinder-ceph (3)', 'nova (4)' ], 'type': 'replicated' } }, 'versions': { 'mgr': ['15.2.14'], 'mon': ['15.2.14'], 'osd': ['15.2.14'] } } inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(actual['crush-rules'], expected['crush-rules']) self.assertEqual(actual['versions'], expected['versions'])
def test_get_ceph_versions_unavailable(self, mock_helper): mock_helper.return_value = mock.MagicMock() mock_helper.return_value.ceph_versions.return_value = [] inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertIsNone(actual.get('versions'))
def test_get_ceph_versions(self): result = {'mgr': ['15.2.14'], 'mon': ['15.2.14'], 'osd': ['15.2.14']} inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(actual['versions'], result)
def test_get_local_osd_ids(self): inst = ceph_summary.CephSummary() actual = self.part_output_to_actual(inst.output) self.assertEqual(list(actual['local-osds'].keys()), [0])