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_pools_from_broker_req(self): self.patch_object(ceph_utils.juju_utils, 'get_relation_from_unit') self.get_relation_from_unit.return_value = { 'broker_req': ('{"api-version": 1, "ops": [' '{"op": "create-pool", "name": "cinder-ceph", ' '"compression-mode": null},' '{"op": "create-pool", "name": "cinder-ceph", ' '"compression-mode": "aggressive"}]}'), } self.assertEquals( ceph_utils.get_pools_from_broker_req('anApplication', 'aModelName'), ['cinder-ceph']) self.get_relation_from_unit.assert_called_once_with( 'ceph-mon', 'anApplication', None, model_name='aModelName')