def test_get_ceph_context(self, mock_config, mock_config2): config = copy.deepcopy(CHARM_CONFIG) mock_config.side_effect = lambda key: config[key] mock_config2.side_effect = lambda key: config[key] ctxt = ceph_hooks.get_ceph_context() expected = { 'auth_supported': False, 'ceph_cluster_network': '', 'ceph_public_network': '', 'cluster_addr': '10.1.0.1', 'dio': 'true', 'fsid': '1234', 'loglevel': 1, 'mon_hosts': '10.0.0.1 10.0.0.2', 'old_auth': False, 'crush_initial_weight': '0', 'osd_journal_size': 1024, 'osd_max_backfills': 1, 'osd_recovery_max_active': 2, 'osd_from_client': OrderedDict(), 'osd_from_client_conflict': OrderedDict(), 'public_addr': '10.0.0.1', 'short_object_len': True, 'upgrade_in_progress': False, 'use_syslog': 'true', 'bdev_discard': True, 'bluestore': False, 'bluestore_experimental': False, 'bluestore_block_wal_size': 0, 'bluestore_block_db_size': 0 } self.assertEqual(ctxt, expected)
def test_get_ceph_context_w_config_flags_invalid(self, mock_config, mock_config2, _get_rbd_features): config = copy.deepcopy(CHARM_CONFIG) config['config-flags'] = ('{"mon": {"mon sync max retries": 10},' '"foo": "bar"}') mock_config.side_effect = lambda key: config[key] mock_config2.side_effect = lambda key: config[key] ctxt = ceph_hooks.get_ceph_context() expected = { 'auth_supported': False, 'ceph_cluster_network': '', 'ceph_public_network': '', 'cluster_addr': '10.1.0.1', 'dio': 'true', 'fsid': '1234', 'loglevel': 1, 'mon_hosts': '10.0.0.1 10.0.0.2', 'old_auth': False, 'mon': { 'mon sync max retries': 10 }, 'public_addr': '10.0.0.1', 'use_syslog': 'true' } self.assertEqual(ctxt, expected)
def test_get_ceph_context_w_config_flags_invalid(self, mock_config, mock_config2): config = copy.deepcopy(CHARM_CONFIG) config['config-flags'] = ('{"osd": {"osd max write size": 1024},' '"foo": "bar"}') mock_config.side_effect = lambda key: config[key] mock_config2.side_effect = lambda key: config[key] ctxt = ceph_hooks.get_ceph_context() expected = {'auth_supported': False, 'ceph_cluster_network': '', 'ceph_public_network': '', 'cluster_addr': '10.1.0.1', 'dio': 'true', 'fsid': '1234', 'loglevel': 1, 'mon_hosts': '10.0.0.1 10.0.0.2', 'old_auth': False, 'osd': {'osd max write size': 1024}, 'crush_initial_weight': '0', 'osd_journal_size': 1024, 'osd_max_backfills': 1, 'osd_recovery_max_active': 2, 'public_addr': '10.0.0.1', 'short_object_len': True, 'upgrade_in_progress': False, 'use_syslog': 'true', 'bluestore': False, 'bluestore_experimental': False} self.assertEqual(ctxt, expected)
def test_get_ceph_context_bluestore_old(self, mock_config, mock_config2): config = copy.deepcopy(CHARM_CONFIG) config['bluestore'] = True config['bluestore-block-wal-size'] = BLUESTORE_WAL_TEST_SIZE config['bluestore-block-db-size'] = BLUESTORE_DB_TEST_SIZE mock_config.side_effect = lambda key: config[key] mock_config2.side_effect = lambda key: config[key] ctxt = ceph_hooks.get_ceph_context() expected = { 'auth_supported': False, 'ceph_cluster_network': '', 'ceph_public_network': '', 'cluster_addr': '10.1.0.1', 'dio': 'true', 'fsid': '1234', 'loglevel': 1, 'mon_hosts': '10.0.0.1 10.0.0.2', 'old_auth': False, 'crush_initial_weight': '0', 'osd_journal_size': 1024, 'osd_max_backfills': 1, 'osd_recovery_max_active': 2, 'public_addr': '10.0.0.1', 'short_object_len': True, 'upgrade_in_progress': False, 'use_syslog': 'true', 'bluestore': True, 'bluestore_experimental': True, 'bluestore_block_wal_size': BLUESTORE_WAL_TEST_SIZE, 'bluestore_block_db_size': BLUESTORE_DB_TEST_SIZE } self.assertEqual(ctxt, expected)
def test_get_ceph_context(self, mock_config, mock_config2): config = copy.deepcopy(CHARM_CONFIG) mock_config.side_effect = lambda key: config[key] mock_config2.side_effect = lambda key: config[key] ctxt = ceph_hooks.get_ceph_context() expected = {'auth_supported': False, 'ceph_cluster_network': '', 'ceph_public_network': '', 'cluster_addr': '10.1.0.1', 'dio': 'true', 'fsid': '1234', 'loglevel': 1, 'mon_hosts': '10.0.0.1 10.0.0.2', 'old_auth': False, 'crush_initial_weight': '0', 'osd_journal_size': 1024, 'osd_max_backfills': 1, 'osd_recovery_max_active': 2, 'public_addr': '10.0.0.1', 'short_object_len': True, 'upgrade_in_progress': False, 'use_syslog': 'true', 'bdev_discard': True, 'bluestore': False, 'bluestore_experimental': False, 'bluestore_block_wal_size': 0, 'bluestore_block_db_size': 0} self.assertEqual(ctxt, expected)
def test_get_ceph_context_w_config_flags(self, mock_config, mock_config2): config = copy.deepcopy(CHARM_CONFIG) config['config-flags'] = '{"osd": {"osd max write size": 1024}}' mock_config.side_effect = lambda key: config[key] mock_config2.side_effect = lambda key: config[key] ctxt = ceph_hooks.get_ceph_context() expected = { 'auth_supported': False, 'ceph_cluster_network': '', 'ceph_public_network': '', 'cluster_addr': '10.1.0.1', 'dio': 'true', 'fsid': '1234', 'loglevel': 1, 'mon_hosts': '10.0.0.1 10.0.0.2', 'old_auth': False, 'osd': { 'osd max write size': 1024 }, 'osd_journal_size': 1024, 'public_addr': '10.0.0.1', 'short_object_len': True, 'upgrade_in_progress': False, 'use_syslog': 'true' } self.assertEqual(ctxt, expected)
def test_get_ceph_context(self, mock_config, mock_config2): config = copy.deepcopy(CHARM_CONFIG) mock_config.side_effect = lambda key: config[key] mock_config2.side_effect = lambda key: config[key] ctxt = ceph_hooks.get_ceph_context() expected = {'auth_supported': False, 'ceph_cluster_network': '', 'ceph_public_network': '', 'cluster_addr': '10.1.0.1', 'dio': 'true', 'fsid': '1234', 'loglevel': 1, 'mon_hosts': '10.0.0.1 10.0.0.2', 'old_auth': False, 'public_addr': '10.0.0.1', 'use_syslog': 'true'} self.assertEqual(ctxt, expected)
def test_get_ceph_context_w_config_flags(self, mock_config, mock_config2, _get_rbd_features): config = copy.deepcopy(CHARM_CONFIG) config['config-flags'] = '{"mon": {"mon sync max retries": 10}}' mock_config.side_effect = lambda key: config[key] mock_config2.side_effect = lambda key: config[key] ctxt = ceph_hooks.get_ceph_context() expected = {'auth_supported': False, 'ceph_cluster_network': '', 'ceph_public_network': '', 'cluster_addr': '10.1.0.1', 'dio': 'true', 'fsid': '1234', 'loglevel': 1, 'mon_hosts': '10.0.0.1 10.0.0.2', 'old_auth': False, 'mon': {'mon sync max retries': 10}, 'public_addr': '10.0.0.1', 'use_syslog': 'true'} self.assertEqual(ctxt, expected)