URL: https://github.com/SSSD/sssd/pull/5473 Author: madhuriupadhye Title: #5473: Tests: alltests: Check default debug level of sssd and corresponding logs Action: synchronized
To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/5473/head:pr5473 git checkout pr5473
From 354c581ecee171e9f14b488369af8b3f1d322a6f Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Fri, 22 Jan 2021 15:35:17 +0530 Subject: [PATCH 1/4] Check default debug level of sssd and corresponding logs It consists of five test cases: 1. Check default debug level when sssd start successfully 2. Check default debug level by successful authentication of the user 3. Check default level as 0 and 1 4. Check default level as 2 5. Check SBUS code should not trigger failure message during modules startup Verifies: Issues: #5422 #5425 Bugs: https://bugzilla.redhat.com/show_bug.cgi?id=1893159 https://bugzilla.redhat.com/show_bug.cgi?id=1915319 Signed-off-by: Madhuri Upadhye <mupad...@redhat.com> --- src/tests/multihost/alltests/pytest.ini | 1 + .../alltests/test_default_debug_level.py | 122 ++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 src/tests/multihost/alltests/test_default_debug_level.py diff --git a/src/tests/multihost/alltests/pytest.ini b/src/tests/multihost/alltests/pytest.ini index 7f625aa262..3ddc05302b 100644 --- a/src/tests/multihost/alltests/pytest.ini +++ b/src/tests/multihost/alltests/pytest.ini @@ -23,6 +23,7 @@ markers = fips: Tests related to fips when auth_provider is krb5 ssh: Tests related to ssh responder ldaplibdebuglevel: Test ldap_library_debug_level option + defaultdebuglevel: Test default debug level sssd tier1: tier1 test cases with run time of aproximately 60 minutes tier1_2: tier1 test cases split to keep runtime upto 60 minutes tier2: tier2 test cases diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py new file mode 100644 index 0000000000..1d4f6d7c40 --- /dev/null +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -0,0 +1,122 @@ +from __future__ import print_function +import re +import pytest +from sssd.testlib.common.utils import sssdTools +from sssd.testlib.common.expect import pexpect_ssh +from constants import ds_instance_name + + +@pytest.mark.usefixtures('setup_sssd', 'create_posix_usersgroups') +@pytest.mark.defaultdebuglevel +class TestDefaultDebugLevel(object): + """ Check sssd default debug level """ + @pytest.mark.tier1 + def test_0001_check_default_debug_level(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default debug level by authenticating the + user + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + tools.clear_sssd_cache() + user = 'foo1@%s' % ds_instance_name + client = pexpect_ssh(multihost.client[0].sys_hostname, user, + 'Secret123', debug=False) + client.login(login_timeout=30, sync_multiplier=5, + auto_prompt_reset=False) + log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', + 'sssd_pam.log', 'sssd_implicit_files.log'] + for log in log_list: + log = '/var/log/sssd/%s' % log + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + find1 = re.compile(r'0x0020') + find2 = re.compile(r'0x0010') + find3 = re.compile(r'0x0040') + find4 = re.compile(r'Starting with debug level = 0x0070') + if not (find1.search(log_str) or find2.search(log_str) or + find3.search(log_str)) and find4.search(log_str): + status = 'FAIL' + else: + status = 'PASS' + assert status == 'PASS' + + @pytest.mark.tier1 + def test_0002_bz1893159(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default level as 0 and 1 + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + multihost.client[0].service_sssd('stop') + chmod_cmd = 'chmod 444 /etc/sssd/sssd.conf' + cmd = multihost.client[0].run_command(chmod_cmd, raiseonerr=False) + if cmd.returncode == 1: + status = 'PASS' + tools.remove_sss_cache('/var/log/sssd') + multihost.client[0].run_command('systemctl start sssd', + raiseonerr=False) + slog = '/var/log/sssd/sssd.log' + log_str = multihost.client[0].get_file_contents(slog).decode('utf-8') + find1 = re.compile(r'0x0020') + find2 = re.compile(r'0x0010') + if not find1.search(log_str) and find2.search(log_str): + status = 'FAIL' + else: + status = 'PASS' + restore_sssd = 'chmod 600 /etc/sssd/sssd.conf' + multihost.client[0].run_command(restore_sssd, raiseonerr=False) + assert status == 'PASS' + + @pytest.mark.tier1 + def test_0003_bz1893159(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default level 2 + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + tools.clear_sssd_cache() + cmd_kill = 'kill -SIGUSR2 $(pidof sssd)' + multihost.client[0].run_command(cmd_kill, raiseonerr=False) + log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', + 'sssd_pam.log', 'sssd_implicit_files.log'] + for log in log_list: + log = '/var/log/sssd/%s' % log + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + find = re.compile(r'.0x0040.') + if not find.search(log_str): + status = 'FAIL' + else: + status = 'PASS' + assert status == 'PASS' + + @pytest.mark.tier1 + def test_0004_bz1915319(self, multihost, backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check SBUS code triggers failure message during + modules startup + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + tools.clear_sssd_cache() + log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', + 'sssd_pam.log', 'sssd_implicit_files.log'] + for log in log_list: + log = '/var/log/sssd/%s' % log + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + find = re.compile(r'Unable to remove key.*') + if not find.search(log_str): + status = 'PASS' + else: + status = 'FAIL' + assert status == 'PASS' From b45e804cb01a4ed9e73dcb3e884764c000bf1f43 Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Fri, 29 Jan 2021 11:09:15 +0530 Subject: [PATCH 2/4] Split the first test case in two cases: 1. Check default debug level when sssd start successfully 2. Check default debug level by successful authentication of the user Also change the test number of other test cases Signed-off-by: Madhuri Upadhye <mupad...@redhat.com> --- .../alltests/test_default_debug_level.py | 66 +++++++++++++------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py index 1d4f6d7c40..55275f64bf 100644 --- a/src/tests/multihost/alltests/test_default_debug_level.py +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -13,38 +13,66 @@ class TestDefaultDebugLevel(object): @pytest.mark.tier1 def test_0001_check_default_debug_level(self, multihost, backupsssdconf): """ - @Title: IDM-SSSD-TC: Check default debug level by authenticating the - user + @Title: IDM-SSSD-TC: Check default debug level when sssd start + successfully """ section = "domain/%s" % ds_instance_name domain_params = {'debug_level': ''} tools = sssdTools(multihost.client[0]) tools.sssd_conf(section, domain_params, action='delete') + # stop sssd, delete sssd logs and cache, start sssd + tools.clear_sssd_cache() + log_list = ['sssd', 'sssd_example1', 'sssd_nss', + 'sssd_pam', 'sssd_implicit_files'] + for log_filename in log_list: + log = '/var/log/sssd/%s.log' % log_filename + log_str = multihost.client[0].get_file_contents(log).decode( + 'utf-8') + debug_level = ['0x0080', '0x0100', '0x0200', '0x0400', '0x1000', + '0x2000', '0x4000', '0x10000'] + for level in debug_level: + regex = r'%s' % level + if re.compile(regex).search(log_str): + assert False + else: + assert True + + @pytest.mark.tier1 + def test_0002_check_default_level_with_auth(self, multihost, + backupsssdconf): + """ + @Title: IDM-SSSD-TC: Check default debug level by + successful authentication of the user + """ + section = "domain/%s" % ds_instance_name + domain_params = {'debug_level': ''} + tools = sssdTools(multihost.client[0]) + tools.sssd_conf(section, domain_params, action='delete') + # stop sssd, delete logs and cache, start sssd tools.clear_sssd_cache() user = 'foo1@%s' % ds_instance_name + # Authenticate user client = pexpect_ssh(multihost.client[0].sys_hostname, user, 'Secret123', debug=False) client.login(login_timeout=30, sync_multiplier=5, auto_prompt_reset=False) - log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', - 'sssd_pam.log', 'sssd_implicit_files.log'] - for log in log_list: - log = '/var/log/sssd/%s' % log + log_list = ['sssd', 'sssd_example1', 'sssd_nss', + 'sssd_pam', 'sssd_implicit_files'] + for log_filename in log_list: + log = '/var/log/sssd/%s.log' % log_filename log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') - find1 = re.compile(r'0x0020') - find2 = re.compile(r'0x0010') - find3 = re.compile(r'0x0040') - find4 = re.compile(r'Starting with debug level = 0x0070') - if not (find1.search(log_str) or find2.search(log_str) or - find3.search(log_str)) and find4.search(log_str): - status = 'FAIL' - else: - status = 'PASS' - assert status == 'PASS' + debug_level = ['0x0080', '0x0100', '0x0200', '0x0400', '0x1000', + '0x2000', '0x4000', '0x10000'] + for level in debug_level: + regex = r'%s' % level + if re.compile(regex).search(log_str): + assert False + else: + assert True @pytest.mark.tier1 - def test_0002_bz1893159(self, multihost, backupsssdconf): + def test_0003_bz1893159(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check default level as 0 and 1 """ @@ -73,7 +101,7 @@ def test_0002_bz1893159(self, multihost, backupsssdconf): assert status == 'PASS' @pytest.mark.tier1 - def test_0003_bz1893159(self, multihost, backupsssdconf): + def test_0004_bz1893159(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check default level 2 """ @@ -98,7 +126,7 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): assert status == 'PASS' @pytest.mark.tier1 - def test_0004_bz1915319(self, multihost, backupsssdconf): + def test_0005_bz1915319(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check SBUS code triggers failure message during modules startup From 3d928821a0a645fb42514743f2bb74173b8dd663 Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Fri, 29 Jan 2021 11:20:27 +0530 Subject: [PATCH 3/4] Update the assert statements. Update the test case name five to Check SBUS code should not trigger failure message during modules startup --- .../alltests/test_default_debug_level.py | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py index 55275f64bf..0261267a09 100644 --- a/src/tests/multihost/alltests/test_default_debug_level.py +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -83,8 +83,7 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): multihost.client[0].service_sssd('stop') chmod_cmd = 'chmod 444 /etc/sssd/sssd.conf' cmd = multihost.client[0].run_command(chmod_cmd, raiseonerr=False) - if cmd.returncode == 1: - status = 'PASS' + assert cmd.returncode == 0 tools.remove_sss_cache('/var/log/sssd') multihost.client[0].run_command('systemctl start sssd', raiseonerr=False) @@ -92,13 +91,12 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): log_str = multihost.client[0].get_file_contents(slog).decode('utf-8') find1 = re.compile(r'0x0020') find2 = re.compile(r'0x0010') - if not find1.search(log_str) and find2.search(log_str): - status = 'FAIL' - else: - status = 'PASS' restore_sssd = 'chmod 600 /etc/sssd/sssd.conf' multihost.client[0].run_command(restore_sssd, raiseonerr=False) - assert status == 'PASS' + if not find1.search(log_str) and find2.search(log_str): + assert False + else: + assert True @pytest.mark.tier1 def test_0004_bz1893159(self, multihost, backupsssdconf): @@ -112,39 +110,37 @@ def test_0004_bz1893159(self, multihost, backupsssdconf): tools.clear_sssd_cache() cmd_kill = 'kill -SIGUSR2 $(pidof sssd)' multihost.client[0].run_command(cmd_kill, raiseonerr=False) - log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', - 'sssd_pam.log', 'sssd_implicit_files.log'] - for log in log_list: - log = '/var/log/sssd/%s' % log + log_list = ['sssd', 'sssd_example1', 'sssd_nss', 'sssd_pam', + 'sssd_implicit_files'] + for logfilename in log_list: + log = '/var/log/sssd/%s.log' % logfilename log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') find = re.compile(r'.0x0040.') if not find.search(log_str): - status = 'FAIL' + assert False else: - status = 'PASS' - assert status == 'PASS' + assert True @pytest.mark.tier1 def test_0005_bz1915319(self, multihost, backupsssdconf): """ - @Title: IDM-SSSD-TC: Check SBUS code triggers failure message during - modules startup + @Title: IDM-SSSD-TC: Check SBUS code should not trigger failure + message during modules startup """ section = "domain/%s" % ds_instance_name domain_params = {'debug_level': ''} tools = sssdTools(multihost.client[0]) tools.sssd_conf(section, domain_params, action='delete') tools.clear_sssd_cache() - log_list = ['sssd.log', 'sssd_example1.log', 'sssd_nss.log', - 'sssd_pam.log', 'sssd_implicit_files.log'] + log_list = ['sssd', 'sssd_example1', 'sssd_nss', 'sssd_pam', + 'sssd_implicit_files'] for log in log_list: - log = '/var/log/sssd/%s' % log + log = '/var/log/sssd/%s.log' % log log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') find = re.compile(r'Unable to remove key.*') if not find.search(log_str): - status = 'PASS' + assert True else: - status = 'FAIL' - assert status == 'PASS' + assert False From 25e0afc40b7ac746732e2ba571bb0cab3bba3470 Mon Sep 17 00:00:00 2001 From: Madhuri Upadhye <mupad...@redhat.com> Date: Wed, 3 Feb 2021 22:38:16 +0530 Subject: [PATCH 4/4] Update the first test case to check debug_level is less than 2 Update the second test case by checking sssd log size before and after authetication of user is same Remove unwanted else part of if loop Update marker to tier1_2 Signed-off-by: MadhurisUpadhye <mupad...@redhat.com> --- .../alltests/test_default_debug_level.py | 62 +++++++++---------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/src/tests/multihost/alltests/test_default_debug_level.py b/src/tests/multihost/alltests/test_default_debug_level.py index 0261267a09..cbf811fe9c 100644 --- a/src/tests/multihost/alltests/test_default_debug_level.py +++ b/src/tests/multihost/alltests/test_default_debug_level.py @@ -10,7 +10,7 @@ @pytest.mark.defaultdebuglevel class TestDefaultDebugLevel(object): """ Check sssd default debug level """ - @pytest.mark.tier1 + @pytest.mark.tier1_2 def test_0001_check_default_debug_level(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check default debug level when sssd start @@ -28,21 +28,24 @@ def test_0001_check_default_debug_level(self, multihost, backupsssdconf): log = '/var/log/sssd/%s.log' % log_filename log_str = multihost.client[0].get_file_contents(log).decode( 'utf-8') - debug_level = ['0x0080', '0x0100', '0x0200', '0x0400', '0x1000', - '0x2000', '0x4000', '0x10000'] - for level in debug_level: - regex = r'%s' % level - if re.compile(regex).search(log_str): + log_split = log_str.split("\n") + for index in range(len(log_split)-1): + log_single_line = log_split[index] + pattern = re.compile(r'\] \(0x\d*\): ') + debug_str = pattern.search(log_single_line).group() + # get debug_level in hex from log + value = debug_str[3:-3] + int_debug_level = int(value, 16) + # int('0x0040', 16) is 64 + if int_debug_level > 64: assert False - else: - assert True - @pytest.mark.tier1 + @pytest.mark.tier1_2 def test_0002_check_default_level_with_auth(self, multihost, backupsssdconf): """ - @Title: IDM-SSSD-TC: Check default debug level by - successful authentication of the user + @Title: IDM-SSSD-TC: Check default debug level by checking sssd + log size before and after authetication of user is same """ section = "domain/%s" % ds_instance_name domain_params = {'debug_level': ''} @@ -50,28 +53,25 @@ def test_0002_check_default_level_with_auth(self, multihost, tools.sssd_conf(section, domain_params, action='delete') # stop sssd, delete logs and cache, start sssd tools.clear_sssd_cache() + check_log_size = 'ls -ash /var/log/sssd/' + blog_size = multihost.client[0].run_command(check_log_size, + raiseonerr=False) + split_string = blog_size.stdout_text.split("\n", 1) + before_auth = int(re.search(r'\d+', split_string[0]).group()) user = 'foo1@%s' % ds_instance_name # Authenticate user client = pexpect_ssh(multihost.client[0].sys_hostname, user, 'Secret123', debug=False) client.login(login_timeout=30, sync_multiplier=5, auto_prompt_reset=False) - log_list = ['sssd', 'sssd_example1', 'sssd_nss', - 'sssd_pam', 'sssd_implicit_files'] - for log_filename in log_list: - log = '/var/log/sssd/%s.log' % log_filename - log_str = multihost.client[0].get_file_contents(log).decode( - 'utf-8') - debug_level = ['0x0080', '0x0100', '0x0200', '0x0400', '0x1000', - '0x2000', '0x4000', '0x10000'] - for level in debug_level: - regex = r'%s' % level - if re.compile(regex).search(log_str): - assert False - else: - assert True + alog_size = multihost.client[0].run_command(check_log_size, + raiseonerr=False) + split_string = alog_size.stdout_text.split("\n", 1) + after_auth = int(re.search(r'\d+', split_string[0]).group()) + if before_auth == after_auth: + assert True - @pytest.mark.tier1 + @pytest.mark.tier1_2 def test_0003_bz1893159(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check default level as 0 and 1 @@ -95,10 +95,8 @@ def test_0003_bz1893159(self, multihost, backupsssdconf): multihost.client[0].run_command(restore_sssd, raiseonerr=False) if not find1.search(log_str) and find2.search(log_str): assert False - else: - assert True - @pytest.mark.tier1 + @pytest.mark.tier1_2 def test_0004_bz1893159(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check default level 2 @@ -119,10 +117,8 @@ def test_0004_bz1893159(self, multihost, backupsssdconf): find = re.compile(r'.0x0040.') if not find.search(log_str): assert False - else: - assert True - @pytest.mark.tier1 + @pytest.mark.tier1_2 def test_0005_bz1915319(self, multihost, backupsssdconf): """ @Title: IDM-SSSD-TC: Check SBUS code should not trigger failure @@ -142,5 +138,3 @@ def test_0005_bz1915319(self, multihost, backupsssdconf): find = re.compile(r'Unable to remove key.*') if not find.search(log_str): assert True - else: - assert False
_______________________________________________ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org