From 56dada9b2055f648fd8842f35818a9e41909e575 Mon Sep 17 00:00:00 2001 From: Amita Sharma Date: Tue, 22 Aug 2017 21:38:41 +0530 Subject: [PATCH] Issue 47840: Add docstrings to setup test suite Description: Add and refactor the setup test suite docstrings for creating test plans. Reviewed by: Simon Pichugin --- dirsrvtests/tests/suites/setup_ds/setup_ds_test.py | 111 +++++++++++---------- 1 file changed, 59 insertions(+), 52 deletions(-) diff --git a/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py b/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py index 687af13..21f19d9 100644 --- a/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py +++ b/dirsrvtests/tests/suites/setup_ds/setup_ds_test.py @@ -1,79 +1,86 @@ -import os +""" + :Requirement: Setting up Directory Server with different configurations +""" import pytest -from lib389.tasks import * from lib389.utils import * from lib389._constants import (DEFAULT_SUFFIX, LOCALHOST, SER_HOST, SER_PORT, SER_SERVERID_PROP, SER_CREATION_SUFFIX, SER_INST_SCRIPTS_ENABLED, - PORT_STANDALONE, args_instance) + PORT_STANDALONE, args_instance, ReplicaRole) from lib389 import DirSrv DEBUGGING = os.getenv("DEBUGGING", default=False) if DEBUGGING: - logging.getLogger(__name__).setLevel(logging.DEBUG) + logging.getLogger(__name__).setLevel(logging.DEBUG) else: - logging.getLogger(__name__).setLevel(logging.INFO) + logging.getLogger(__name__).setLevel(logging.INFO) log = logging.getLogger(__name__) def create_instance(config_attr): - log.info('create_instance - Installs the instance and Sets the value of InstScriptsEnabled to true OR false.') - - log.info("Set up the instance and set the config_attr") - # Create instance - standalone = DirSrv(verbose=False) - - # Args for the instance - args_instance[SER_HOST] = LOCALHOST - args_instance[SER_PORT] = PORT_STANDALONE - args_instance[SER_SERVERID_PROP] = 'standalone' - args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX - args_instance[SER_INST_SCRIPTS_ENABLED] = config_attr - args_standalone = args_instance.copy() - standalone.allocate(args_standalone) - if standalone.exists(): - standalone.delete() - standalone.create() - standalone.open() - return standalone + log.info('create_instance - Installs the instance and Sets the value of InstScriptsEnabled to true OR false.') + + log.info("Set up the instance and set the config_attr") + instance_data = generate_ds_params(1, ReplicaRole.STANDALONE) + # Create instance + standalone = DirSrv(verbose=False) + + # Args for the instance + args_instance[SER_HOST] = instance_data[SER_HOST] + args_instance[SER_PORT] = instance_data[SER_PORT] + args_instance[SER_SERVERID_PROP] = instance_data[SER_SERVERID_PROP] + args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX + args_instance[SER_INST_SCRIPTS_ENABLED] = config_attr + args_standalone = args_instance.copy() + standalone.allocate(args_standalone) + if standalone.exists(): + standalone.delete() + standalone.create() + standalone.open() + return standalone @pytest.mark.parametrize("config_attr", ('true', 'false')) def test_slapd_InstScriptsEnabled(config_attr): - """Try to set InstScriptsEnabled attribute - to various config_attrs as default, true and false + """Tests InstScriptsEnabled attribute with "True" and "False" options - :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 as "True" and "False" - :steps: 1. Execute setup-ds.pl with slapd.InstScriptsEnabled option as "True" and "False" one by one - 2. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. - 3. The script directory should be created if slapd.InstScriptsEnabled option is "True" - 4. The script directory should not be created if slapd.InstScriptsEnabled option is "False" - :expectedresults: The script directory should be created - if slapd.InstScriptsEnabled option is "True" and not if it is "Fasle" - """ + :id: 02faac7f-c44d-4a3e-bf2d-1021e51da1ed - log.info('set SER_INST_SCRIPTS_ENABLED to {}'.format(config_attr)) - standalone = create_instance(config_attr) + :setup: Standalone instance with slapd.InstScriptsEnabled option as "True" and "False" - # Checking the presence of instance script directory when SER_INST_SCRIPTS_ENABLED is set to true and false - if config_attr == 'true': - log.info('checking the presence of instance script directory when SER_INST_SCRIPTS_ENABLED is set to true') - assert os.listdir('/usr/lib64/dirsrv/slapd-standalone') + :steps: + 1. Execute setup-ds.pl with slapd.InstScriptsEnabled option as "True". + 2. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. + 3. Execute setup-ds.pl with slapd.InstScriptsEnabled option as "False". + 4. Check if /usr/lib64/dirsrv/slapd-instance instance script directory is created or not. - elif config_attr == 'false': - log.info('checking instance script directory does not present when SER_INST_SCRIPTS_ENABLED is set to false') - assert not os.path.exists("/usr/lib64/dirsrv/slapd-standalone") + :expectedresults: + 1. Instance should be created. + 2. /usr/lib64/dirsrv/slapd-instance instance script directory should be created. + 3. Instance should be created. + 4. /usr/lib64/dirsrv/slapd-instance instance script directory should not be created. + """ - # Remove instance - standalone.delete() + log.info('set SER_INST_SCRIPTS_ENABLED to {}'.format(config_attr)) + standalone = create_instance(config_attr) + + # Checking the presence of instance script directory when SER_INST_SCRIPTS_ENABLED is set to true and false + if config_attr == 'true': + log.info('checking the presence of instance script directory when SER_INST_SCRIPTS_ENABLED is set to true') + assert os.listdir('/usr/lib64/dirsrv/slapd-standalone') + + elif config_attr == 'false': + log.info('checking instance script directory does not present when SER_INST_SCRIPTS_ENABLED is set to false') + assert not os.path.exists("/usr/lib64/dirsrv/slapd-standalone") + + # Remove instance + standalone.delete() if __name__ == '__main__': - # Run isolated - # -s for DEBUG mode - CURRENT_FILE = os.path.realpath(__file__) - pytest.main("-s %s" % CURRENT_FILE) + # Run isolated + # -s for DEBUG mode + CURRENT_FILE = os.path.realpath(__file__) + pytest.main("-s %s" % CURRENT_FILE) + -- 2.9.4