From 423a9ce2563650ed237317ae1e109017e9bdd051 Mon Sep 17 00:00:00 2001 From: Viktor Ashirov Date: May 14 2019 08:20:32 +0000 Subject: Issue 50164 - Add test for dscreate to basic test suite Bug Description: dscreate tests do not work properly when newer lib389 is used with older 389-ds-base versions. Fix Description: * Unset PYTHONPATH for dscreate if it's set to prevent clobbering system lib389. * Don't run dscreate_test on older versions, where instance-specific sysconfig env file is mentioned in systemd unit file. dscreate no longer creates it and causes dirsrv service fail to start. * Don't check for instance-specific sysconfig env file on removing the instance since it's no longer created. Fixes https://pagure.io/389-ds-base/issue/50164 Reviewed by: mreynolds (Thanks!) --- diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py index 457e808..1e86626 100644 --- a/dirsrvtests/tests/suites/basic/basic_test.py +++ b/dirsrvtests/tests/suites/basic/basic_test.py @@ -1196,12 +1196,16 @@ sample_entries = yes with open(template_file, "w") as template_fd: template_fd.write(template_text) + # Unset PYTHONPATH to avoid mixing old CLI tools and new lib389 + tmp_env = os.environ + if "PYTHONPATH" in tmp_env: + del tmp_env["PYTHONPATH"] try: subprocess.check_call([ 'dscreate', 'from-file', template_file - ]) + ], env=tmp_env) except subprocess.CalledProcessError as e: log.fatal("dscreate failed! Error ({}) {}".format(e.returncode, e.output)) assert False diff --git a/dirsrvtests/tests/suites/setup_ds/dscreate_test.py b/dirsrvtests/tests/suites/setup_ds/dscreate_test.py index c589b4e..1c98b2a 100644 --- a/dirsrvtests/tests/suites/setup_ds/dscreate_test.py +++ b/dirsrvtests/tests/suites/setup_ds/dscreate_test.py @@ -18,7 +18,8 @@ from lib389._constants import * import tempfile -pytestmark = pytest.mark.tier0 +pytestmark = [pytest.mark.tier0, + pytest.mark.skipif(ds_is_older('1.4.1.2'), reason="Needs a compatible systemd unit, see PR#50213")] INSTANCE_PORT = 54321 INSTANCE_SERVERID = 'standalone' diff --git a/dirsrvtests/tests/suites/setup_ds/remove_test.py b/dirsrvtests/tests/suites/setup_ds/remove_test.py index e9f131b..96e58b8 100644 --- a/dirsrvtests/tests/suites/setup_ds/remove_test.py +++ b/dirsrvtests/tests/suites/setup_ds/remove_test.py @@ -52,8 +52,7 @@ def test_basic(topology_st, simple_allocate): inst.get_changelog_dir(), inst.ds_paths.ldif_dir, inst.ds_paths.lock_dir, - inst.ds_paths.log_dir, - "{}/sysconfig/dirsrv-{}".format(inst.ds_paths.sysconf_dir, inst.serverid)] + inst.ds_paths.log_dir] for path in paths: assert not os.path.exists(path)