def test_logrotate_conf_combiner(): all_lrt = LogrotateConfAll([ LogrotateConf( context_wrap(LOGROTATE_CONF_1, path='/etc/logrotate.conf')), LogrotateConf( context_wrap(LOGROTATE_CONF_2, path='/etc/logrotate.d/candlepin')), LogrotateConf( context_wrap(LOGROTATE_CONF_3, path='/etc/logrotate.d/xx')) ]) assert all_lrt.global_options == [ 'weekly', 'rotate', 'create', 'dateext', 'include' ] assert all_lrt['rotate'] == '4' assert '/var/log/httpd/access.log' not in all_lrt assert all_lrt['/var/log/httpd/access.log'] is None assert all_lrt.options_of_logfile('/var/log/httpd/access.log') is None assert all_lrt.configfile_of_logfile('/var/log/httpd/access.log') is None assert '/var/log/candlepin/error.log' in all_lrt assert all_lrt['/var/log/candlepin/candlepin.log']['rotate'] == '52' assert all_lrt.configfile_of_logfile( '/var/log/wtmp') == '/etc/logrotate.conf' assert all_lrt.configfile_of_logfile( '/var/log/candlepin/access.log') == '/etc/logrotate.d/candlepin' assert all_lrt.configfile_of_logfile( '/var/log/maillog') == '/etc/logrotate.d/xx' assert all_lrt.options_of_logfile( '/var/log/maillog')['sharedscripts'] is True
def test_web_xml_doc_examples(): env = { 'all_lrt': LogrotateConfAll([ LogrotateConf( context_wrap(LOGROTATE_MAN_PAGE_DOC_1, path='/etc/logrotate.conf')), LogrotateConf( context_wrap(LOGROTATE_MAN_PAGE_DOC_2, path='/etc/logrotate.d/httpd')), LogrotateConf( context_wrap(LOGROTATE_MAN_PAGE_DOC_3, path='/etc/logrotate.d/newscrit')) ]) } failed, total = doctest.testmod(logrotate_conf, globs=env) assert failed == 0
def test_web_xml_doc_examples(): env = { 'log_rt': LogrotateConf( context_wrap(LOGROTATE_MAN_PAGE_DOC, path='/etc/logrotate.conf')), } failed, total = doctest.testmod(logrotate_conf, globs=env) assert failed == 0
def test_logrotate_conf_1(): log_rt = LogrotateConf( context_wrap(LOGROTATE_CONF_1, path='/etc/logrotate.conf')) assert 'compress' not in log_rt.options assert log_rt['include'] == '/etc/logrotate.d' assert log_rt['/var/log/wtmp']['minsize'] == '1M' assert log_rt.log_files == ['/var/log/wtmp'] assert log_rt['/var/log/wtmp']['create'] == '0664 root utmp'
def test_logrotate_conf_combiner_no_logfile(): all_lrt = LogrotateConfAll([ LogrotateConf( context_wrap(LOGROTATE_CONF_NO_FILE, path='/etc/logrotate.conf')), ]) assert all_lrt.global_options == ['dateext', 'include'] assert all_lrt.log_files == [] assert all_lrt.options_of_logfile('/var/log/httpd/access.log') is None assert all_lrt.configfile_of_logfile('/var/log/httpd/access.log') is None
def test_logrotate_conf_3(): log_rt = LogrotateConf( context_wrap(LOGROTATE_CONF_3, path='/etc/logrotate.conf')) assert log_rt.options == [] assert '/var/log/maillog' in log_rt.log_files assert log_rt['/var/log/cron']['sharedscripts'] is True assert log_rt['/var/log/messages']['postrotate'] == [ '/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true' ]
def test_logrotate_conf_2(): log_rt = LogrotateConf( context_wrap(LOGROTATE_CONF_2, path='/etc/logrotate.conf')) assert log_rt.options == [] assert '/var/log/candlepin/access.log' in log_rt.log_files assert log_rt['/var/log/candlepin/access.log']['rotate'] == '52' assert log_rt['/var/log/candlepin/error.log']['missingok'] is True assert log_rt['/var/log/candlepin/audit.log'][ 'create'] == '0644 tomcat tomcat'