From f6174a9aa17b20dfa772fdaac575c8152defc5d6 Mon Sep 17 00:00:00 2001 From: Amita Sharma Date: Wed, 15 Mar 2017 19:08:09 +0530 Subject: [PATCH] Ticket 47840 - add configure option to disable instance specific scripts Bug Description: [RFE] add setup-ds.pl option to disable instance specific scripts Fix Description: Instead of defining a configure option, we provide a new option in setup-ds.pl, slapd.InstScriptsEnabled?, which defaults to false. All new installs of 389 will NOT install with a inst_dir nor the scripts that are in that directory. https://pagure.io/389-ds-base/issue/47840 Reviewed by: Simon Pichugi --- dirsrvtests/tests/suites/setup_ds/setup_ds_test.py | 129 +++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 dirsrvtests/tests/suites/setup_ds/setup_ds_test.py diff --git a/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py b/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py new file mode 100644 index 0000000..4160967 --- /dev/null +++ b/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py @@ -0,0 +1,129 @@ +import time +import ldap +import logging +import pytest +from lib389 import DirSrv, Entry, tools, tasks +from lib389.tools import DirSrvTools +from lib389._constants import * +from lib389.properties import * +from lib389.tasks import * +from lib389.utils import * +from lib389.topologies import topology_st as topo + +import os + +DEBUGGING = os.getenv("DEBUGGING", default=False) +if DEBUGGING: + logging.getLogger(__name__).setLevel(logging.DEBUG) +else: + logging.getLogger(__name__).setLevel(logging.INFO) +log = logging.getLogger(__name__) + +SCRIPT_SUFFIX = 'dc=script,dc=com' +SCRIPT_SUFFIX1 = 'dc=script1,dc=com' + +def test_slapd_InstScriptsEnabled_default(topo): + """Testing setup-ds.pl with slapd.InstScriptsEnabled option as default + + :ID: 02faac7f-c44d-4a3e-bf2d-1021e51da1ed + :feature: add configure option to disable instance specific scripts + :setup: Create directory server instance using setup-ds.pl without specifying slapd.InstScriptsEnabled option + :steps: 1. Execute setup-ds.pl without mentioning slapd.InstScriptsEnabled option + 2. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. + 3. As default behavior, the script directory should be created. + :assert: As default behavior, the script directory should be created. + If the directory will not be created, the test fails. + """ + + #As the default instance "topology_st.standalone" is created without mentioning slapd.InstScriptsEnabled option + #So, we can use the default instance for this test case + log.info('Using default dirsrv instance to test the default behavior of slapd.InstScriptsEnabled option') + + #checking the presence of instance script directory + log.info('checking the presence of instance script directory, it should be present by default') + assert os.path.exists("/usr/lib64/dirsrv/slapd-standalone_1/") + + +def test_slapd_InstScriptsEnabled_False(topo): + """Testing setup-ds.pl with slapd.InstScriptsEnabled option set as false + + :ID: 02faac7f-c44d-4a3e-bf2d-1021e51da1ed + :feature: add configure option to disable instance specific scripts + :setup: Create directory server instance using setup-ds.pl with slapd.InstScriptsEnabled option set as false + :steps: 1. Execute setup-ds.pl with slapd.InstScriptsEnabled option set as false + 2. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. + 3. The script directory should not have been created. + :assert: The script directory should not have been created. + If the directory will be created, the test fails. + """ + + #create the instance with slapd.InstScriptsEnabled=false + log.info('create the instance with slapd.InstScriptsEnabled=false') + + # Create instance + standalone_script = DirSrv(verbose=False) + + # Args for the instance + args_instance[SER_HOST] = LOCALHOST + args_instance[SER_PORT] = 33333 + args_instance[SER_SERVERID_PROP] = 'standalone_script' + args_instance[SER_CREATION_SUFFIX] = SCRIPT_SUFFIX + args_instance[SER_INST_SCRIPTS_ENABLED] = 'false' + args_standalone_script = args_instance.copy() + standalone_script.allocate(args_standalone_script) + if standalone_script.exists(): + standalone_script.delete() + standalone_script.create() + standalone_script.open() + + + #checking the presence of instance script directory, it should not present + log.info('checking the presence of instance script directory, it should not be present by default') + assert not os.path.exists("/usr/lib64/dirsrv/slapd-standalone_script") + + #remove the instance + standalone_script.delete() + +def test_slapd_InstScriptsEnabled_True(topo): + """Testing setup-ds.pl with slapd.InstScriptsEnabled option set as True + + :ID: 02faac7f-c44d-4a3e-bf2d-1021e51da1ed + :feature: add configure option to disable instance specific scripts + :setup: Create directory server instance using setup-ds.pl with slapd.InstScriptsEnabled option set as True + :steps: 1. Execute setup-ds.pl with slapd.InstScriptsEnabled option set as True + 2. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. + 3. The script directory should be created. + :assert: The script directory should be created. + If the directory will not be created, the test fails. + """ + + #create the instance with slapd.InstScriptsEnabled=false + log.info('create the instance with slapd.InstScriptsEnabled=true') + + # Create instance + standalone_script1 = DirSrv(verbose=False) + + # Args for the instance + args_instance[SER_HOST] = LOCALHOST + args_instance[SER_PORT] = 33334 + args_instance[SER_SERVERID_PROP] = 'standalone_script1' + args_instance[SER_CREATION_SUFFIX] = SCRIPT_SUFFIX1 + args_instance[SER_INST_SCRIPTS_ENABLED] = 'true' + args_standalone_script1 = args_instance.copy() + standalone_script1.allocate(args_standalone_script1) + if standalone_script1.exists(): + standalone_script1.delete() + standalone_script1.create() + standalone_script1.open() + + + #checking the presence of instance script directory, it should be present + log.info('checking the presence of instance script directory, it should be present') + assert os.path.exists("/usr/lib64/dirsrv/slapd-standalone_script1") + +if __name__ == '__main__': + # Run isolated + # -s for DEBUG mode + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s %s" % CURRENT_FILE) + -- 2.5.5