def test_configure_compression(self): """Enable compression and validate properties flush through to pool.""" if not self.mimic_or_newer: logging.info('Skipping test, Mimic or newer required.') return if self.application_name == 'ceph-osd': # The ceph-osd charm itself does not request pools, neither does # the BlueStore Compression configuration options it have affect # pool properties. logging.info('test does not apply to ceph-osd charm.') return elif self.application_name == 'ceph-radosgw': # The Ceph RadosGW creates many light weight pools to keep track of # metadata, we only compress the pool containing actual data. app_pools = ['.rgw.buckets.data'] else: # Retrieve which pools the charm under test has requested skipping # metadata pools as they are deliberately not compressed. app_pools = [ pool for pool in zaza_ceph.get_pools_from_broker_req( self.application_name, model_name=self.model_name) if 'metadata' not in pool ] ceph_pools_detail = zaza_ceph.get_ceph_pool_details( model_name=self.model_name) logging.debug('BEFORE: {}'.format(ceph_pools_detail)) try: logging.info('Checking Ceph pool compression_mode prior to change') self._assert_pools_properties( app_pools, ceph_pools_detail, {'options': {'compression_mode': 'none'}}) except KeyError: logging.info('property does not exist on pool, which is OK.') logging.info('Changing "bluestore-compression-mode" to "force" on {}' .format(self.application_name)) with self.config_change( {'bluestore-compression-mode': 'none'}, {'bluestore-compression-mode': 'force'}): # Retrieve pool details from Ceph after changing configuration ceph_pools_detail = zaza_ceph.get_ceph_pool_details( model_name=self.model_name) logging.debug('CONFIG_CHANGE: {}'.format(ceph_pools_detail)) logging.info('Checking Ceph pool compression_mode after to change') self._assert_pools_properties( app_pools, ceph_pools_detail, {'options': {'compression_mode': 'force'}}) ceph_pools_detail = zaza_ceph.get_ceph_pool_details( model_name=self.model_name) logging.debug('AFTER: {}'.format(ceph_pools_detail)) logging.debug(juju_utils.get_relation_from_unit( 'ceph-mon', self.application_name, None, model_name=self.model_name)) logging.info('Checking Ceph pool compression_mode after restoring ' 'config to previous value') self._assert_pools_properties( app_pools, ceph_pools_detail, {'options': {'compression_mode': 'none'}})
def test_check_pool_types(self): """Check type of pools created for clients.""" app_pools = [('glance', 'glance'), ('nova-compute', 'nova'), ('cinder-ceph', 'cinder-ceph')] runtime_pool_details = zaza_ceph.get_ceph_pool_details() for app, pool_name in app_pools: juju_pool_config = zaza_model.get_application_config(app).get( 'pool-type') if juju_pool_config: expected_pool_type = juju_pool_config['value'] else: # If the pool-type option is absent assume the default of # replicated. expected_pool_type = zaza_ceph.REPLICATED_POOL_TYPE for pool_config in runtime_pool_details: if pool_config['pool_name'] == pool_name: logging.info('Checking {} is {}'.format( pool_name, expected_pool_type)) expected_pool_code = -1 if expected_pool_type == zaza_ceph.REPLICATED_POOL_TYPE: expected_pool_code = zaza_ceph.REPLICATED_POOL_CODE elif expected_pool_type == zaza_ceph.ERASURE_POOL_TYPE: expected_pool_code = zaza_ceph.ERASURE_POOL_CODE self.assertEqual(pool_config['type'], expected_pool_code) break else: raise CephPoolConfig( "Failed to find config for {}".format(pool_name))
def test_check_pool_types(self): """Check type of pools created for clients.""" app_pools = [ ('glance', 'glance'), ('nova-compute', 'nova'), ('cinder-ceph', 'cinder-ceph')] runtime_pool_details = zaza_ceph.get_ceph_pool_details() for app, pool_name in app_pools: try: app_config = zaza_model.get_application_config(app) except KeyError: logging.info( 'Skipping pool check of %s, application %s not present', pool_name, app) continue rel_id = zaza_model.get_relation_id( app, 'ceph-mon', remote_interface_name='client') if not rel_id: logging.info( 'Skipping pool check of %s, ceph relation not present', app) continue juju_pool_config = app_config.get('pool-type') if juju_pool_config: expected_pool_type = juju_pool_config['value'] else: # If the pool-type option is absent assume the default of # replicated. expected_pool_type = zaza_ceph.REPLICATED_POOL_TYPE for pool_config in runtime_pool_details: if pool_config['pool_name'] == pool_name: logging.info('Checking {} is {}'.format( pool_name, expected_pool_type)) expected_pool_code = -1 if expected_pool_type == zaza_ceph.REPLICATED_POOL_TYPE: expected_pool_code = zaza_ceph.REPLICATED_POOL_CODE elif expected_pool_type == zaza_ceph.ERASURE_POOL_TYPE: expected_pool_code = zaza_ceph.ERASURE_POOL_CODE self.assertEqual( pool_config['type'], expected_pool_code) break else: raise CephPoolConfig( "Failed to find config for {}".format(pool_name))