Debian Codegraph @

dirsrvtests/tests/suites/ds_logs/regression_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2017 Red Hat, Inc.
3 # All rights reserved.
4 #
5 # License: GPL (version 3 or any later version).
6 # See LICENSE for details.
7 # --- END COPYRIGHT BLOCK ---
8 #
9
10 import pytest
11 from lib389.dseldif import DSEldif
12 from lib389._constants import DN_CONFIG, LOG_REPLICA, LOG_DEFAULT, LOG_TRACE, LOG_ACL
13 from lib389.utils import os, logging
14 from test389.topologies import topology_st as topo
15
16 pytestmark = pytest.mark.tier2
17
18 DEBUGGING = os.getenv("DEBUGGING", default=False)
19 if DEBUGGING:
20 logging.getLogger(__name__).setLevel(logging.DEBUG)
21 else:
22 logging.getLogger(__name__).setLevel(logging.INFO)
23 log = logging.getLogger(__name__)
24
25
26 @pytest.mark.parametrize("log_level", [(LOG_REPLICA + LOG_DEFAULT), (LOG_ACL + LOG_DEFAULT), (LOG_TRACE + LOG_DEFAULT)])
27 def test_default_loglevel_stripped(topo, log_level):
28 """The default log level 16384 is stripped from the log level returned to a client
29
30 :id: c300f8f1-aa11-4621-b124-e2be51930a6b
31 :parametrized: yes
32 :setup: Standalone instance
33
34 :steps: 1. Change the error log level to the default and custom value.
35 2. Check if the server returns the new value.
36
37 :expectedresults:
38 1. Changing the error log level should be successful.
39 2. Server should return the new log level.
40 """
41
42 assert topo.standalone.config.set('nsslapd-errorlog-level', str(log_level))
43 assert topo.standalone.config.get_attr_val_int('nsslapd-errorlog-level') == log_level
44
45
46 def test_dse_config_loglevel_error(topo):
47 """Manually setting nsslapd-errorlog-level to 64 in dse.ldif throws error
48
49 :id: 0eeefa17-ec1c-4208-8e7b-44d8fbc38f10
50
51 :setup: Standalone instance
52
53 :steps: 1. Stop the server, edit dse.ldif file and change nsslapd-errorlog-level value to 64
54 2. Start the server and observe the error logs.
55
56 :expectedresults:
57 1. Server should be successfully stopped and nsslapd-errorlog-level value should be changed.
58 2. Server should be successfully started without any errors being reported in the logs.
59 """
60
61 topo.standalone.stop(timeout=10)
62 dse_ldif = DSEldif(topo.standalone)
63 try:
64 dse_ldif.replace(DN_CONFIG, 'nsslapd-errorlog-level', 64)
65 except:
66 log.error('Failed to replace cn=config values of nsslapd-errorlog-level')
67 raise
68 topo.standalone.start(timeout=10)
69 assert not topo.standalone.ds_error_log.match(
70 '.*nsslapd-errorlog-level: ignoring 64 \\(since -d 266354688 was given on the command line\\).*')
71
72
73 if __name__ == '__main__':
74 # Run isolated
75 # -s for DEBUG mode
76 CURRENT_FILE = os.path.realpath(__file__)
77 pytest.main("-s %s" % CURRENT_FILE)