def test_crushmap_mixed_buckets(self, mock_helper):
     mock_helper.return_value = mock.MagicMock()
     mock_helper.return_value.ceph_osd_crush_dump_json_decoded.\
         return_value = json.loads(CEPH_OSD_CRUSH_DUMP)
     cluster = ceph_core.CephCluster()
     buckets = cluster.crush_map.crushmap_mixed_buckets
     self.assertEqual(buckets, ['default'])
 def test_ceph_daemon_versions_unique_not(self, mock_cli):
     mock_cli.return_value = mock.MagicMock()
     mock_cli.return_value.ceph_versions.return_value = \
         CEPH_VERSIONS_MISMATCHED_MINOR_MONS_UNALIGNED.split('\n')
     result = {
         'mgr': ['15.2.11'],
         'mon': ['15.2.11', '15.2.10'],
         'osd': ['15.2.11', '15.2.13']
     }
     cluster = ceph_core.CephCluster()
     self.assertEqual(cluster.ceph_daemon_versions_unique(), result)
     self.assertFalse(cluster.ceph_versions_aligned)
     self.assertFalse(cluster.mon_versions_aligned_with_cluster)
 def test_crush_rules(self):
     cluster = ceph_core.CephCluster()
     expected = {
         'replicated_rule': {
             'id':
             0,
             'type':
             'replicated',
             'pools': [
                 'device_health_metrics (1)', 'glance (2)',
                 'cinder-ceph (3)', 'nova (4)'
             ]
         }
     }
     self.assertEqual(cluster.crush_map.rules, expected)
 def test_check_crushmap_non_equal_buckets(self, mock_helper):
     test_data_path = ('sos_commands/ceph_mon/json_output/'
                       'ceph_osd_crush_dump_--format_'
                       'json-pretty.unbalanced')
     osd_crush_dump_path = os.path.join(HotSOSConfig.DATA_ROOT,
                                        test_data_path)
     osd_crush_dump = json.load(open(osd_crush_dump_path))
     mock_helper.return_value = mock.MagicMock()
     mock_helper.return_value.ceph_osd_crush_dump_json_decoded.\
         return_value = osd_crush_dump
     cluster = ceph_core.CephCluster()
     buckets = cluster.crush_map.crushmap_equal_buckets
     self.assertEqual(buckets, [{
         'domain': 'rack',
         'root': 'default',
         'ruleid': 0
     }])
 def test_crushmap_no_mixed_buckets(self):
     cluster = ceph_core.CephCluster()
     buckets = cluster.crush_map.crushmap_mixed_buckets
     self.assertEqual(buckets, [])
 def test_ceph_daemon_versions_unique(self):
     result = {'mgr': ['15.2.14'], 'mon': ['15.2.14'], 'osd': ['15.2.14']}
     cluster = ceph_core.CephCluster()
     self.assertEqual(cluster.ceph_daemon_versions_unique(), result)
     self.assertTrue(cluster.ceph_versions_aligned)
     self.assertTrue(cluster.mon_versions_aligned_with_cluster)
 def test_mon_release_name(self):
     release_names = ceph_core.CephCluster().daemon_release_names('mon')
     self.assertEqual(release_names, {'octopus': 3})
 def test_cluster_osd_ids(self):
     cluster = ceph_core.CephCluster()
     self.assertEqual([osd.id for osd in cluster.osds], [0, 1, 2])
 def test_rgw_versions(self):
     versions = ceph_core.CephCluster().daemon_versions('rgw')
     self.assertEqual(versions, {})
 def test_mon_versions(self):
     versions = ceph_core.CephCluster().daemon_versions('mon')
     self.assertEqual(versions, {'15.2.14': 3})
 def test_health_status(self):
     health = ceph_core.CephCluster().health_status
     self.assertEqual(health, 'HEALTH_WARN')
 def test_cluster_osds(self):
     cluster_osds = ceph_core.CephCluster().osds
     self.assertEqual([ceph_core.CephOSD],
                      list(set([type(obj) for obj in cluster_osds])))
 def test_cluster_mons(self):
     cluster_mons = ceph_core.CephCluster().mons
     self.assertEqual([ceph_core.CephMon],
                      list(set([type(obj) for obj in cluster_mons])))