def test_cache_autosize_invalid_values(topo, invalid_value): """Check that we can't set invalid values to autosize attributes :id: 2f0d01b5-ca91-4dc2-97bc-ad0ac8d08633 :setup: Standalone instance :steps: 1. Stop the instance 2. Set in the cn=config,cn=ldbm database,cn=plugins,cn=config: nsslapd-cache-autosize and nsslapd-cache-autosize-split to invalid values like (-2, 102, invalid_str) 3. Try to start the instance :expectedresults: 1. The instance should stop successfully 2. nsslapd-cache-autosize, nsslapd-cache-autosize-split are successfully set 3. Starting the instance should fail """ config_ldbm = DSLdapObject(topo.standalone, DN_CONFIG_LDBM) autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize') autosize_split_val = config_ldbm.get_attr_val('nsslapd-cache-autosize-split') log.info("Set nsslapd-cache-autosize-split to {}".format(invalid_value)) with pytest.raises(ldap.UNWILLING_TO_PERFORM): config_ldbm.set('nsslapd-cache-autosize-split', invalid_value) topo.standalone.restart() config_ldbm.remove('nsslapd-cache-autosize-split', autosize_split_val) log.info("Set nsslapd-cache-autosize to {}".format(invalid_value)) with pytest.raises(ldap.UNWILLING_TO_PERFORM): config_ldbm.set('nsslapd-cache-autosize', invalid_value) topo.standalone.restart() config_ldbm.remove('nsslapd-cache-autosize', autosize_val)
def _lint_search(self): """Perform a search and make sure an entry is accessible """ dn = self.get_attr_val_utf8('nsslapd-suffix') bename = self.lint_uid() suffix = DSLdapObject(self._instance, dn=dn) try: suffix.get_attr_val('objectclass') except ldap.NO_SUCH_OBJECT: # backend root entry not created yet DSBLE0003['items'] = [ dn, ] DSBLE0003['check'] = f'backends:{bename}:search' yield DSBLE0003 except ldap.LDAPError as e: # Some other error DSBLE0002['detail'] = DSBLE0002['detail'].replace('ERROR', str(e)) DSBLE0002['check'] = f'backends:{bename}:search' DSBLE0002['items'] = [ dn, ] yield DSBLE0002
def test_cache_autosize_basic_sane(topo, autosize_split): """Check that autotuning cachesizes works properly with different values :id: 9dc363ef-f551-446d-8b83-8ac45dabb8df :parametrized: yes :setup: Standalone instance :steps: 1. Set in the cn=config,cn=ldbm database,cn=plugins,cn=config: nsslapd-cache-autosize, nsslapd-cache-autosize-split to the next value pairs: ('0', '0'), ('0', ''), ('0', '40') '' - for deleting the value (set to default) 2. Set in the cn=config,cn=ldbm database,cn=plugins,cn=config: nsslapd-dbcachesize: 0 and some same value 3. Set in the cn=UserRoot,cn=ldbm database,cn=plugins,cn=config: nsslapd-cachememsize: 0 and some same value 4. Restart the instance 5. Check nsslapd-dbcachesize and nsslapd-cachememsize :expectedresults: 1. nsslapd-cache-autosize, nsslapd-cache-autosize-split are successfully set 2. nsslapd-dbcachesize are successfully set 3. nsslapd-cachememsize are successfully set 4. The instance should be successfully restarted 5. nsslapd-dbcachesize and nsslapd-cachememsize should set to value greater than 512KB """ config_ldbm = DSLdapObject(topo.standalone, DN_CONFIG_LDBM) bdb_config_ldbm = DSLdapObject(topo.standalone, DN_CONFIG_LDBM_BDB) userroot_ldbm = DSLdapObject(topo.standalone, DN_USERROOT_LDBM) config_ldbm.set('nsslapd-cache-autosize', '0') # Test with caches with both real values and 0 for cachesize in ('0', '33333333'): if ds_is_older('1.4.2'): dbcachesize_val = config_ldbm.get_attr_val('nsslapd-dbcachesize') autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize') autosize_split_val = config_ldbm.get_attr_val( 'nsslapd-cache-autosize-split') else: dbcachesize_val = bdb_config_ldbm.get_attr_val( 'nsslapd-dbcachesize') autosize_val = bdb_config_ldbm.get_attr_val( 'nsslapd-cache-autosize') autosize_split_val = bdb_config_ldbm.get_attr_val( 'nsslapd-cache-autosize-split') cachenensize_val = userroot_ldbm.get_attr_val('nsslapd-cachememsize') dncachenensize_val = userroot_ldbm.get_attr_val( 'nsslapd-dncachememsize') log.info( "Check nsslapd-dbcachesize and nsslapd-cachememsize before the test" ) log.info("nsslapd-dbcachesize == {}".format(dbcachesize_val)) log.info("nsslapd-cachememsize == {}".format(cachenensize_val)) log.info("nsslapd-cache-autosize == {}".format(autosize_val)) log.info( "nsslapd-cache-autosize-split == {}".format(autosize_split_val)) if autosize_split: log.info("Set nsslapd-cache-autosize-split to {}".format( autosize_split)) config_ldbm.set('nsslapd-cache-autosize-split', autosize_split) else: log.info("Delete nsslapd-cache-autosize-split") try: config_ldbm.remove('nsslapd-cache-autosize-split', autosize_split_val) except ValueError: log.info("nsslapd-cache-autosize-split wasn't found") log.info("Set nsslapd-dbcachesize to {}".format(cachesize)) config_ldbm.set('nsslapd-dbcachesize', cachesize) log.info("Set nsslapd-cachememsize to {}".format(cachesize)) userroot_ldbm.set('nsslapd-cachememsize', cachesize) topo.standalone.restart() if ds_is_older('1.4.2'): dbcachesize_val = config_ldbm.get_attr_val('nsslapd-dbcachesize') autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize') autosize_split_val = config_ldbm.get_attr_val( 'nsslapd-cache-autosize-split') else: dbcachesize_val = bdb_config_ldbm.get_attr_val( 'nsslapd-dbcachesize') autosize_val = bdb_config_ldbm.get_attr_val( 'nsslapd-cache-autosize') autosize_split_val = bdb_config_ldbm.get_attr_val( 'nsslapd-cache-autosize-split') cachenensize_val = userroot_ldbm.get_attr_val('nsslapd-cachememsize') dncachenensize_val = userroot_ldbm.get_attr_val( 'nsslapd-dncachememsize') log.info( "Check nsslapd-dbcachesize and nsslapd-cachememsize in the appropriate range." ) log.info("nsslapd-dbcachesize == {}".format(dbcachesize_val)) log.info("nsslapd-cachememsize == {}".format(cachenensize_val)) log.info("nsslapd-dncachememsize == {}".format(dncachenensize_val)) log.info("nsslapd-cache-autosize == {}".format(autosize_val)) log.info( "nsslapd-cache-autosize-split == {}".format(autosize_split_val)) assert int(dbcachesize_val) >= 512000 assert int(cachenensize_val) >= 512000 assert int(dncachenensize_val) >= 512000
def test_cache_autosize_non_zero(topo, autosize, autosize_split): """Check that autosizing works works properly in different combinations :id: 83fa099c-a6c9-457a-82db-0982b67e8598 :parametrized: yes :setup: Standalone instance :steps: 1. Set in the cn=config,cn=ldbm database,cn=plugins,cn=config: nsslapd-cache-autosize, nsslapd-cache-autosize-split to the next value pairs: ('', ''), ('', '0'), ('10', '40'), ('', '40'), ('10', ''), ('10', '40'), ('10', '0') '' - for deleting the value (set to default) 2. Try to modify nsslapd-dbcachesize and nsslapd-cachememsize to some real value, it should be rejected 3. Restart the instance 4. Check nsslapd-dbcachesize and nsslapd-cachememsize :expectedresults: 1. nsslapd-cache-autosize, nsslapd-cache-autosize-split are successfully set 2. Modify operation should be rejected 3. The instance should be successfully restarted 4. nsslapd-dbcachesize and nsslapd-cachememsize should set to value greater than 512KB """ config_ldbm = DSLdapObject(topo.standalone, DN_CONFIG_LDBM) bdb_config_ldbm = DSLdapObject(topo.standalone, DN_CONFIG_LDBM_BDB) userroot_ldbm = DSLdapObject(topo.standalone, DN_USERROOT_LDBM) cachesize = '33333333' if ds_is_older('1.4.2'): dbcachesize_val = config_ldbm.get_attr_val('nsslapd-dbcachesize') autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize') autosize_split_val = config_ldbm.get_attr_val( 'nsslapd-cache-autosize-split') else: dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize') autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize') autosize_split_val = bdb_config_ldbm.get_attr_val( 'nsslapd-cache-autosize-split') cachenensize_val = userroot_ldbm.get_attr_val('nsslapd-cachememsize') dncachenensize_val = userroot_ldbm.get_attr_val('nsslapd-dncachememsize') log.info( "Check nsslapd-dbcachesize and nsslapd-cachememsize before the test") log.info("nsslapd-dbcachesize == {}".format(dbcachesize_val)) log.info("nsslapd-cachememsize == {}".format(cachenensize_val)) log.info("nsslapd-dncachememsize == {}".format(dncachenensize_val)) log.info("nsslapd-cache-autosize == {}".format(autosize_val)) log.info("nsslapd-cache-autosize-split == {}".format(autosize_split_val)) if autosize: log.info("Set nsslapd-cache-autosize to {}".format(autosize)) config_ldbm.set('nsslapd-cache-autosize', autosize) else: log.info("Delete nsslapd-cache-autosize") try: config_ldbm.remove('nsslapd-cache-autosize', autosize_val) except ValueError: log.info("nsslapd-cache-autosize wasn't found") if autosize_split: log.info( "Set nsslapd-cache-autosize-split to {}".format(autosize_split)) config_ldbm.set('nsslapd-cache-autosize-split', autosize_split) else: log.info("Delete nsslapd-cache-autosize-split") try: config_ldbm.remove('nsslapd-cache-autosize-split', autosize_split_val) except ValueError: log.info("nsslapd-cache-autosize-split wasn't found") log.info("Trying to set nsslapd-cachememsize to {}".format(cachesize)) with pytest.raises(ldap.UNWILLING_TO_PERFORM): userroot_ldbm.set('nsslapd-cachememsize', cachesize) log.info("Trying to set nsslapd-dbcachesize to {}".format(cachesize)) with pytest.raises(ldap.UNWILLING_TO_PERFORM): config_ldbm.set('nsslapd-dbcachesize ', cachesize) topo.standalone.restart() if ds_is_older('1.4.2'): dbcachesize_val = config_ldbm.get_attr_val('nsslapd-dbcachesize') autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize') autosize_split_val = config_ldbm.get_attr_val( 'nsslapd-cache-autosize-split') else: dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize') autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize') autosize_split_val = bdb_config_ldbm.get_attr_val( 'nsslapd-cache-autosize-split') cachenensize_val = userroot_ldbm.get_attr_val('nsslapd-cachememsize') dncachenensize_val = userroot_ldbm.get_attr_val('nsslapd-dncachememsize') log.info( "Check nsslapd-dbcachesize and nsslapd-cachememsize in the appropriate range." ) log.info("nsslapd-dbcachesize == {}".format(dbcachesize_val)) log.info("nsslapd-cachememsize == {}".format(cachenensize_val)) log.info("nsslapd-dncachememsize == {}".format(dncachenensize_val)) log.info("nsslapd-cache-autosize == {}".format(autosize_val)) log.info("nsslapd-cache-autosize-split == {}".format(autosize_split_val)) assert int(dbcachesize_val) >= 512000 assert int(cachenensize_val) >= 512000 assert int(dncachenensize_val) >= 512000