def test_del_suffix_import(topo): """Adding a database entry fails if the same database was deleted after an import :id: 652421ef-738b-47ed-80ec-2ceece6b5d77 :feature: Import :setup: Standalone instance :steps: 1. Create a test suffix and add few entries 2. Stop the server and do offline import using ldif2db 3. Delete the suffix backend 4. Add a new suffix with the same database name 5. Check if adding the same database name is a success :expectedresults: Adding database with the same name should be successful """ log.info('Adding suffix:{} and backend: {}'.format(TEST_SUFFIX1, TEST_BACKEND1)) backends = Backends(topo.standalone) backend = backends.create(properties={ 'nsslapd-suffix': TEST_SUFFIX1, 'name': TEST_BACKEND1 }) log.info('Create LDIF file and import it') ldif_dir = topo.standalone.get_ldif_dir() ldif_file = os.path.join(ldif_dir, 'suffix_del1.ldif') dbgen_users(topo.standalone, 10, ldif_file, TEST_SUFFIX1) log.info('Stopping the server and running offline import') topo.standalone.stop() assert topo.standalone.ldif2db(TEST_BACKEND1, TEST_SUFFIX1, None, None, ldif_file) topo.standalone.start() log.info('Deleting suffix-{}'.format(TEST_SUFFIX2)) backend.delete() log.info( 'Adding the same database-{} after deleting it'.format(TEST_BACKEND1)) backends.create(properties={ 'nsslapd-suffix': TEST_SUFFIX1, 'name': TEST_BACKEND1 })
def test_import_be_default(topo): """ Create a backend using the name "default". previously this name was used int :id: 8e507beb-e917-4330-8cac-1ff0eee10508 :feature: Import :setup: Standalone instance :steps: 1. Create a test suffix using the be name of "default" 2. Create an ldif for the "default" backend 3. Import ldif 4. Verify all entries were imported :expectedresults: 1. Success 2. Success 3. Success 4. Success """ log.info('Adding suffix:{} and backend: {}...'.format( TEST_DEFAULT_SUFFIX, TEST_DEFAULT_NAME)) backends = Backends(topo.standalone) backends.create(properties={ 'nsslapd-suffix': TEST_DEFAULT_SUFFIX, 'name': TEST_DEFAULT_NAME }) log.info('Create LDIF file and import it...') ldif_dir = topo.standalone.get_ldif_dir() ldif_file = os.path.join(ldif_dir, 'default.ldif') dbgen_users(topo.standalone, 5, ldif_file, TEST_DEFAULT_SUFFIX) log.info('Stopping the server and running offline import...') topo.standalone.stop() assert topo.standalone.ldif2db(TEST_DEFAULT_NAME, None, None, None, ldif_file) topo.standalone.start() log.info('Verifying entry count after import...') entries = topo.standalone.search_s(TEST_DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, "(objectclass=*)") assert len(entries) > 1 log.info('Test PASSED')
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()
def dbgen_create_users(inst, log, args): """ Create a LDIF of user entries """ if args.number is None or args.suffix is None: """ Interactively get all the info ... """ log.info("Missing required parameters, switching to Interactive mode ...") # Get the suffix args.suffix = get_input(log, "Enter the suffix", "dc=example,dc=com", "dn") # Get the parent args.parent = get_input(log, "Enter the parent entry for the users", "ou=people,dc=example,dc=com", "dn") # Get the number of users to create args.number = get_input(log, "Enter the number of users to create", 100000, "int") # Confirm the RDN attribute args.rdn_cn = get_input(log, "Do you want to use \"cn\" instead of \"uid\" for the entry RDN attribute (yes/no)", False, "bool") # Create generic entries args.generic = get_input(log, "Create generic entries that can be used with \"ldclt\" (yes/no)", False, "bool") # get offset size if args.generic: args.start_idx = get_input(log, "Choose the starting index for the generic user entries", 0, "int") # localize the data args.localize = get_input(log, "Do you want to localize the LDIF data (yes/no)", False, "bool") # Get the output LDIF file name args.ldif_file = get_ldif_file_input(log, default_name=get_ldif_dir(inst) + USERS_LDIF_NAME) else: args.ldif_file = adjust_ldif_name(inst, args.ldif_file) validate_ldif_file(args.ldif_file) display_args(log, args) dbgen_users(inst, args.number, args.ldif_file, args.suffix, generic=args.generic, parent=args.parent, startIdx=args.start_idx, rdnCN=False, pseudol10n=args.localize) log.info(f"Successfully created LDIF file: {args.ldif_file}")
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 test_sss_mr(topo): """Test matching rule/server side sort does not crash DS :id: 48c73d76-1694-420f-ab55-187135f2d260 :setup: Standalone Instance :steps: 1. Add sample entries to the database 2. Perform search using server side control (uid:2.5.13.3) :expectedresults: 1. Success 2. Success """ log.info("Creating LDIF...") ldif_dir = topo.standalone.get_ldif_dir() ldif_file = os.path.join(ldif_dir, 'mr-crash.ldif') dbgen_users(topo.standalone, 5, ldif_file, DEFAULT_SUFFIX) log.info("Importing LDIF...") topo.standalone.stop() assert topo.standalone.ldif2db(DEFAULT_BENAME, None, None, None, ldif_file) topo.standalone.start() log.info( 'Search using server side sorting using undefined mr in the attr...') sort_ctrl = SSSRequestControl(True, ['uid:2.5.13.3']) controls = [sort_ctrl] msg_id = topo.standalone.search_ext(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, "objectclass=*", serverctrls=controls) try: rtype, rdata, rmsgid, response_ctrl = topo.standalone.result3(msg_id) except ldap.OPERATIONS_ERROR: pass log.info("Test PASSED")