regression_test.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. import pytest
  10. from lib389.dseldif import DSEldif
  11. from lib389._constants import DN_CONFIG, LOG_REPLICA, LOG_DEFAULT, LOG_TRACE, LOG_ACL
  12. from lib389.utils import os, logging
  13. from lib389.topologies import topology_st as topo
  14. DEBUGGING = os.getenv("DEBUGGING", default=False)
  15. if DEBUGGING:
  16. logging.getLogger(__name__).setLevel(logging.DEBUG)
  17. else:
  18. logging.getLogger(__name__).setLevel(logging.INFO)
  19. log = logging.getLogger(__name__)
  20. @pytest.mark.bz1460718
  21. @pytest.mark.parametrize("log_level", [(LOG_REPLICA + LOG_DEFAULT), (LOG_ACL + LOG_DEFAULT), (LOG_TRACE + LOG_DEFAULT)])
  22. def test_default_loglevel_stripped(topo, log_level):
  23. """The default log level 16384 is stripped from the log level returned to a client
  24. :id: c300f8f1-aa11-4621-b124-e2be51930a6b
  25. :setup: Standalone instance
  26. :steps: 1. Change the error log level to the default and custom value.
  27. 2. Check if the server returns the new value.
  28. :expectedresults:
  29. 1. Changing the error log level should be successful.
  30. 2. Server should return the new log level.
  31. """
  32. assert topo.standalone.config.set('nsslapd-errorlog-level', str(log_level))
  33. assert topo.standalone.config.get_attr_val_int('nsslapd-errorlog-level') == log_level
  34. @pytest.mark.bz1460718
  35. def test_dse_config_loglevel_error(topo):
  36. """Manually setting nsslapd-errorlog-level to 64 in dse.ldif throws error
  37. :id: 0eeefa17-ec1c-4208-8e7b-44d8fbc38f10
  38. :setup: Standalone instance
  39. :steps: 1. Stop the server, edit dse.ldif file and change nsslapd-errorlog-level value to 64
  40. 2. Start the server and observe the error logs.
  41. :expectedresults:
  42. 1. Server should be successfully stopped and nsslapd-errorlog-level value should be changed.
  43. 2. Server should be successfully started without any errors being reported in the logs.
  44. """
  45. topo.standalone.stop(timeout=10)
  46. dse_ldif = DSEldif(topo.standalone)
  47. try:
  48. dse_ldif.replace(DN_CONFIG, 'nsslapd-errorlog-level', 64)
  49. except:
  50. log.error('Failed to replace cn=config values of nsslapd-errorlog-level')
  51. raise
  52. topo.standalone.start(timeout=10)
  53. assert not topo.standalone.ds_error_log.match(
  54. '.*nsslapd-errorlog-level: ignoring 64 \\(since -d 266354688 was given on the command line\\).*')
  55. if __name__ == '__main__':
  56. # Run isolated
  57. # -s for DEBUG mode
  58. CURRENT_FILE = os.path.realpath(__file__)
  59. pytest.main("-s %s" % CURRENT_FILE)