From 2c80c5cfc20279b1a708cb484673f0485c3bc95f Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Nov 07 2016 10:32:25 +0000 Subject: Ticket 49024 - Fix dbdir paths and adjust test cases Description: Set db_dir properly in all test cases. Replace expected exception ldap.SERVER_DOWN with subprocess.CalledProcessError when server isn't able to start. Set paths to logs properly. https://fedorahosted.org/389/ticket/49024 Reviewed by: nhosoi, wibrown (Thanks!) --- diff --git a/dirsrvtests/tests/suites/dna_plugin/dna_test.py b/dirsrvtests/tests/suites/dna_plugin/dna_test.py index 18b871b..8830d5e 100644 --- a/dirsrvtests/tests/suites/dna_plugin/dna_test.py +++ b/dirsrvtests/tests/suites/dna_plugin/dna_test.py @@ -60,8 +60,8 @@ def topology(request): # Delete each instance in the end def fin(): # This is useful for analysing the test env. - standalone.db2ldif(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX], excludeSuffixes=[], encrypt=False, \ - repl_data=True, outputfile='%s/ldif/%s.ldif' % (standalone.dbdir,SERVERID_STANDALONE )) + standalone.db2ldif(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX], excludeSuffixes=[], encrypt=False, + repl_data=True, outputfile='{}/{}.ldif'.format(standalone.ldifdir, SERVERID_STANDALONE)) standalone.clearBackupFS() standalone.backupFS() standalone.delete() diff --git a/dirsrvtests/tests/tickets/ticket47669_test.py b/dirsrvtests/tests/tickets/ticket47669_test.py index 0f1a643..fd5299c 100644 --- a/dirsrvtests/tests/tickets/ticket47669_test.py +++ b/dirsrvtests/tests/tickets/ticket47669_test.py @@ -85,7 +85,7 @@ def test_ticket47669_init(topology): topology.standalone.simple_bind_s(DN_DM, PASSWORD) try: - changelogdir = "%s/changelog" % topology.standalone.dbdir + changelogdir = os.path.join(topology.standalone.inst_dir, 'changelog') topology.standalone.add_s(Entry((CHANGELOG, {'objectclass': 'top extensibleObject'.split(), 'nsslapd-changelogdir': changelogdir}))) diff --git a/dirsrvtests/tests/tickets/ticket47823_test.py b/dirsrvtests/tests/tickets/ticket47823_test.py index 4d6058a..36bd19a 100644 --- a/dirsrvtests/tests/tickets/ticket47823_test.py +++ b/dirsrvtests/tests/tickets/ticket47823_test.py @@ -14,6 +14,7 @@ import logging import pytest import re import shutil +import subprocess from lib389 import DirSrv, Entry, tools from lib389.tools import DirSrvTools from lib389._constants import * @@ -639,7 +640,7 @@ def test_ticket47823_invalid_config_1(topology): # be sure to restore a valid config before assert _config_file(topology, action='restore') assert not ent - except ldap.SERVER_DOWN: + except subprocess.CalledProcessError: pass # Check the expected error message @@ -690,7 +691,7 @@ def test_ticket47823_invalid_config_2(topology): # be sure to restore a valid config before assert _config_file(topology, action='restore') assert not ent - except ldap.SERVER_DOWN: + except subprocess.CalledProcessError: pass # Check the expected error message @@ -743,7 +744,7 @@ def test_ticket47823_invalid_config_3(topology): # be sure to restore a valid config before assert _config_file(topology, action='restore') assert not ent - except ldap.SERVER_DOWN: + except subprocess.CalledProcessError: pass # Check the expected error message @@ -795,7 +796,7 @@ def test_ticket47823_invalid_config_4(topology): # be sure to restore a valid config before assert _config_file(topology, action='restore') assert not ent - except ldap.SERVER_DOWN: + except subprocess.CalledProcessError: pass # Check the expected error message @@ -846,7 +847,7 @@ def test_ticket47823_invalid_config_5(topology): # be sure to restore a valid config before assert _config_file(topology, action='restore') assert not ent - except ldap.SERVER_DOWN: + except subprocess.CalledProcessError: pass # Check the expected error message @@ -897,7 +898,7 @@ def test_ticket47823_invalid_config_6(topology): # be sure to restore a valid config before assert _config_file(topology, action='restore') assert not ent - except ldap.SERVER_DOWN: + except subprocess.CalledProcessError: pass # Check the expected error message @@ -948,7 +949,7 @@ def test_ticket47823_invalid_config_7(topology): # be sure to restore a valid config before assert _config_file(topology, action='restore') assert not ent - except ldap.SERVER_DOWN: + except subprocess.CalledProcessError: pass # Check the expected error message diff --git a/dirsrvtests/tests/tickets/ticket48266_test.py b/dirsrvtests/tests/tickets/ticket48266_test.py index 82571e9..18d1ba3 100644 --- a/dirsrvtests/tests/tickets/ticket48266_test.py +++ b/dirsrvtests/tests/tickets/ticket48266_test.py @@ -225,8 +225,7 @@ def _get_last_not_replicated_csn(topology): # now retrieve the CSN of the operation we are looking for csn = None topology.master1.stop(timeout=10) - file_path = os.path.join(topology.master1.prefix, "var/log/dirsrv/slapd-%s/access" % topology.master1.serverid) - file_obj = open(file_path, "r") + file_obj = open(topology.master1.accesslog, "r") # First the conn/op of the operation regex = re.compile("MOD dn=\"%s\"" % name) @@ -272,8 +271,7 @@ def _get_first_not_replicated_csn(topology): # now retrieve the CSN of the operation we are looking for csn = None topology.master1.stop(timeout=10) - file_path = os.path.join(topology.master1.prefix, "var/log/dirsrv/slapd-%s/access" % topology.master1.serverid) - file_obj = open(file_path, "r") + file_obj = open(topology.master1.accesslog, "r") # First the conn/op of the operation regex = re.compile("MOD dn=\"%s\"" % name) @@ -298,12 +296,10 @@ def _get_first_not_replicated_csn(topology): def _count_full_session(topology): - file_path = os.path.join(topology.master1.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.master1.serverid) - # # compute the number of 'No more updates' # - file_obj = open(file_path, "r") + file_obj = open(topology.master1.errlog, "r") # pattern to find pattern = ".*No more updates to send.*" regex = re.compile(pattern) @@ -392,8 +388,7 @@ def test_ticket48266_count_csn_evaluation(topology, entries): # Now determine how many times we have skipped 'csn' # no need to stop the server to check the error log - file_path = os.path.join(topology.master1.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.master1.serverid) - file_obj = open(file_path, "r") + file_obj = open(topology.master1.errlog, "r") # find where the last_csn operation was processed pattern = ".*ruv_add_csn_inprogress: successfully inserted csn %s.*" % last_csn diff --git a/dirsrvtests/tests/tickets/ticket48270_test.py b/dirsrvtests/tests/tickets/ticket48270_test.py index 0eeeed4..6324ef3 100644 --- a/dirsrvtests/tests/tickets/ticket48270_test.py +++ b/dirsrvtests/tests/tickets/ticket48270_test.py @@ -96,8 +96,7 @@ def test_ticket48270_homeDirectory_indexed_cis(topology): topology.standalone.tasks.reindex(suffix=SUFFIX, attrname='homeDirectory', args=args) log.info("Check indexing succeeded with a specified matching rule") - file_path = os.path.join(topology.standalone.prefix, "var/log/dirsrv/slapd-%s/errors" % topology.standalone.serverid) - file_obj = open(file_path, "r") + file_obj = open(topology.standalone.errlog, "r") # Check if the MR configuration failure occurs regex = re.compile("unknown or invalid matching rule") diff --git a/dirsrvtests/tests/tickets/ticket48383_test.py b/dirsrvtests/tests/tickets/ticket48383_test.py index c6bebcd..e49c77f 100644 --- a/dirsrvtests/tests/tickets/ticket48383_test.py +++ b/dirsrvtests/tests/tickets/ticket48383_test.py @@ -115,10 +115,12 @@ def test_ticket48383(topology): # stop the server topology.standalone.stop(timeout=30) # Now export and import the DB. It's easier than db2index ... - topology.standalone.db2ldif(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX], excludeSuffixes=[], encrypt=False, \ - repl_data=True, outputfile='%s/ldif/%s.ldif' % (topology.standalone.dbdir,SERVERID_STANDALONE )) + topology.standalone.db2ldif(bename=DEFAULT_BENAME, suffixes=[DEFAULT_SUFFIX], excludeSuffixes=[], + encrypt=False, repl_data=True, + outputfile='{}/{}.ldif'.format(topology.standalone.ldifdir, SERVERID_STANDALONE)) - result = topology.standalone.ldif2db(DEFAULT_BENAME, None, None, False, '%s/ldif/%s.ldif' % (topology.standalone.dbdir,SERVERID_STANDALONE )) + result = topology.standalone.ldif2db(DEFAULT_BENAME, None, None, False, + '{}/{}.ldif'.format(topology.standalone.ldifdir, SERVERID_STANDALONE)) assert(result) diff --git a/dirsrvtests/tests/tickets/ticket48906_test.py b/dirsrvtests/tests/tickets/ticket48906_test.py index e046469..b532500 100644 --- a/dirsrvtests/tests/tickets/ticket48906_test.py +++ b/dirsrvtests/tests/tickets/ticket48906_test.py @@ -160,7 +160,7 @@ def _check_dse_ldif_value(topology, attr=DBLOCK_ATTR_CONFIG, expected_value=DBLO assert(value) def _check_guardian_value(topology, attr=DBLOCK_ATTR_CONFIG, expected_value=None): - guardian_file = topology.standalone.dbdir + '/db/guardian' + guardian_file = os.path.join(topology.standalone.dbdir, 'guardian') assert(os.path.exists(guardian_file)) guardian = open(guardian_file, "r")