def test_online_import_with_warning(topo, _import_clean): """ Import an ldif file with syntax errors, verify skipped entry warning code :id: 5bf75c47-a283-430e-a65c-3c5fd8dbadb8 :setup: Standalone Instance :steps: 1. Create standalone Instance 2. Create an ldif file with an entry that violates syntax check (empty givenname) 3. Online import of troublesome ldif file :expected results: 1. Successful import with skipped entry warning """ topo.standalone.restart() import_task = ImportTask(topo.standalone) import_ldif1 = _create_syntax_err_ldif(topo) # Importing the offending ldif file - online import_task.import_suffix_from_ldif(ldiffile=import_ldif1, suffix=DEFAULT_SUFFIX) # There is just a single entry in this ldif import_task.wait(5) # Check for the task nsTaskWarning attr, make sure its set to skipped entry code assert import_task.present('nstaskwarning') assert TaskWarning.WARN_SKIPPED_IMPORT_ENTRY == import_task.get_task_warn()
def import_ldif(self, be_name, ldifs, chunk_size=None, encrypted=False, gen_uniq_id=None, only_core=False, include_suffixes=None, exclude_suffixes=None): """Do an import of the suffix""" if not ldifs: raise ValueError("import_ldif: LDIF filename is missing") ldif_paths = [] for ldif in list(ldifs): if not ldif.startswith("/"): if ldif.endswith(".ldif"): ldif = os.path.join(self._instance.ds_paths.ldif_dir, ldif) else: ldif = os.path.join(self._instance.ds_paths.ldif_dir, "%s.ldif" % ldif) ldif_paths.append(ldif) task = ImportTask(self._instance) task_properties = {'nsInstance': be_name, 'nsFilename': ldif_paths} if include_suffixes is not None: task_properties['nsIncludeSuffix'] = include_suffixes if exclude_suffixes is not None: task_properties['nsExcludeSuffix'] = exclude_suffixes if encrypted: task_properties['nsExportDecrypt'] = 'true' if only_core: task_properties['nsImportIndexAttrs'] = 'false' if chunk_size is not None: task_properties['nsImportChunkSize'] = chunk_size if gen_uniq_id is not None: if gen_uniq_id in ("none", "empty" ) or gen_uniq_id.startswith("deterministic"): raise ValueError( "'gen_uniq_id should be none (no unique ID) |" "empty (time-based ID) | deterministic namespace (name-based ID)" ) task_properties['nsUniqueIdGenerator'] = gen_uniq_id task.create(properties=task_properties) return task
def setup_attruniq_index_be_import(topology_st_fn): """Enable Attribute Uniqueness, disable indexes and import 120000 entries to the default backend """ inst = topology_st_fn.standalone inst.config.loglevel([AccessLog.DEFAULT, AccessLog.INTERNAL], service='access') inst.config.set('nsslapd-plugin-logging', 'on') inst.restart() attruniq = AttributeUniquenessPlugin(inst, dn="cn=attruniq,cn=plugins,cn=config") attruniq.create(properties={'cn': 'attruniq'}) for cn in [ 'uid', 'cn', 'sn', 'uidNumber', 'gidNumber', 'homeDirectory', 'givenName', 'description' ]: attruniq.add_unique_attribute(cn) attruniq.add_unique_subtree(DEFAULT_SUFFIX) attruniq.enable_all_subtrees() attruniq.enable() indexes = Indexes(inst) for cn in [ 'uid', 'cn', 'sn', 'uidNumber', 'gidNumber', 'homeDirectory', 'givenName', 'description' ]: indexes.ensure_state(properties={ 'cn': cn, 'nsSystemIndex': 'false', 'nsIndexType': 'none' }) bdb_config = BDB_LDBMConfig(inst) bdb_config.replace("nsslapd-db-locks", "130000") inst.restart() ldif_dir = inst.get_ldif_dir() import_ldif = ldif_dir + '/perf_import.ldif' # Valid online import import_task = ImportTask(inst) dbgen_users(inst, 120000, import_ldif, DEFAULT_SUFFIX, entry_name="userNew") import_task.import_suffix_from_ldif(ldiffile=import_ldif, suffix=DEFAULT_SUFFIX) import_task.wait() assert import_task.is_complete()
def test_stress_search_simple(topology_st): """Test a simple stress test of searches on the directory server. :id: 3786d01c-ea03-4655-a4f9-450693c75863 :setup: Standalone Instance :steps: 1. Create test users 2. Import them 3. Stress test! :expectedresults: 1. Success 2. Success 3. Results are written to /tmp """ inst = topology_st.standalone inst.config.set("nsslapd-verify-filter-schema", "off") # Bump idllimit to test OR worst cases. from lib389.config import LDBMConfig lconfig = LDBMConfig(inst) # lconfig.set("nsslapd-idlistscanlimit", '20000') # lconfig.set("nsslapd-lookthroughlimit", '20000') ldif_dir = inst.get_ldif_dir() import_ldif = ldif_dir + '/basic_import.ldif' dbgen_users(inst, 10000, import_ldif, DEFAULT_SUFFIX) r = ImportTask(inst) r.import_suffix_from_ldif(ldiffile=import_ldif, suffix=DEFAULT_SUFFIX) r.wait() # Run a small to warm up the server's caches ... l = Ldclt(inst) l.search_loadtest(DEFAULT_SUFFIX, "([email protected])", rounds=1) # Now do it for realsies! # l.search_loadtest(DEFAULT_SUFFIX, "(|([email protected])(nonexist=foo))", rounds=10) l.search_loadtest(DEFAULT_SUFFIX, "([email protected])", rounds=10)
def _import_online(topo, no_no): """ Will import ldifs online """ _check_users_before_test(topo, no_no) ldif_dir = topo.standalone.get_ldif_dir() import_ldif = ldif_dir + '/basic_import.ldif' _generate_ldif(topo, no_no) # Online import_task = ImportTask(topo.standalone) import_task.import_suffix_from_ldif(ldiffile=import_ldif, suffix=DEFAULT_SUFFIX) # Wait a bit till the task is created and available for searching time.sleep(0.5) # Good as place as any to quick test the task has some expected attributes if ds_is_newer('1.4.1.2'): assert import_task.present('nstaskcreated') assert import_task.present('nstasklog') assert import_task.present('nstaskcurrentitem') assert import_task.present('nstasktotalitems') assert import_task.present('ttl') import_task.wait() topo.standalone.searchAccessLog('ADD dn="cn=import') topo.standalone.searchErrorsLog('import userRoot: Import complete.') _search_for_user(topo, no_no)
def test_import_perf_after_failure(topo): """Make an import fail by specifying the wrong LDIF file name, then try the import with the correct name. Make sure the import performance is what we expect. :id: d21dc67f-475e-402a-be9e-3eeb9181c156 :setup: Standalone Instance :steps: 1. Build LDIF file 2. Import invalid LDIF filename 3. Import valid LDIF filename 4. Import completes in a timely manner :expectedresults: 1. Success 2. Success 3. Success 4. Success """ ldif_dir = topo.standalone.get_ldif_dir() import_ldif = ldif_dir + '/perf_import.ldif' bad_import_ldif = ldif_dir + '/perf_import_typo.ldif' # Build LDIF file dbgen_users(topo.standalone, 30000, import_ldif, DEFAULT_SUFFIX) # Online import which fails import_task = ImportTask(topo.standalone) import_task.import_suffix_from_ldif(ldiffile=bad_import_ldif, suffix=DEFAULT_SUFFIX) import_task.wait() # Valid online import time.sleep(1) import_task = ImportTask(topo.standalone) import_task.import_suffix_from_ldif(ldiffile=import_ldif, suffix=DEFAULT_SUFFIX) import_task.wait( 30) # If things go wrong import takes a lot longer than this assert import_task.is_complete() # Restart server topo.standalone.restart()