diff --git a/tests/show_test.py b/tests/show_test.py index ddb59078b2..98433e68e0 100644 --- a/tests/show_test.py +++ b/tests/show_test.py @@ -147,3 +147,26 @@ def test_show_version(): runner = CliRunner() result = runner.invoke(show.cli.commands["version"]) assert "SONiC OS Version: 11" in result.output + + +class TestShowRunningconfiguration(object): + @classmethod + def setup_class(cls): + print('SETUP') + os.environ['UTILITIES_UNIT_TESTING'] = '1' + + @patch('show.main.run_command') + def test_rc_syslog(self, mock_rc): + runner = CliRunner() + + result = runner.invoke( + show.cli.commands['runningconfiguration'].commands['syslog']) + print(result.exit_code) + print(result.output) + + assert result.exit_code == 0 + # mock_rc.assert_called_once_with('date') + + @classmethod + def teardown_class(cls): + print('TEARDOWN') diff --git a/tests/syslog_input/rsyslog.conf b/tests/syslog_input/rsyslog.conf new file mode 100644 index 0000000000..b2a269a816 --- /dev/null +++ b/tests/syslog_input/rsyslog.conf @@ -0,0 +1,77 @@ +############################################################################### +# Managed by Ansible +# file: ansible/roles/acs/templates/rsyslog.conf.j2 +############################################################################### +# +# /etc/rsyslog.conf Configuration file for rsyslog. +# +# For more information see +# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html + + +################# +#### MODULES #### +################# + +$ModLoad imuxsock # provides support for local system logging +$ModLoad imklog # provides kernel logging support +#$ModLoad immark # provides --MARK-- message capability + +# provides UDP syslog reception +$ModLoad imudp +$UDPServerAddress 127.0.0.1 #bind to localhost before udp server run +$UDPServerRun 514 + +# provides TCP syslog reception +#$ModLoad imtcp +#$InputTCPServerRun 514 + + +########################### +#### GLOBAL DIRECTIVES #### +########################### +# +# Use traditional timestamp format. +# To enable high precision timestamps, comment out the following line. +# +#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat + +# Define a custom template +$template SONiCFileFormat,"%timegenerated%.%timegenerated:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" +$ActionFileDefaultTemplate SONiCFileFormat + +template(name="WelfRemoteFormat" type="string" string="%TIMESTAMP% id=firewall time=\"%timereported\ +:::date-year%-%timereported:::date-month%-%timereported:::date-day% %timereported:::date-hour%:%timereported:::date-minute%:%timereported\ +:::date-second%\" fw=\"sonic\" pri=%syslogpriority% msg=\"%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\"\n") + +#Set remote syslog server +*.notice +action(type="omfwd" Target="1.1.1.1" Port="514" Protocol="udp" Device="eth0" Template="SONiCFileFormat") + +# +# Set the default permissions for all log files. +# +$FileOwner root +$FileGroup adm +$FileCreateMode 0640 +$DirCreateMode 0755 +$Umask 0022 + +# +# Where to place spool and state files +# +$WorkDirectory /var/spool/rsyslog + +# +# Include all config files in /etc/rsyslog.d/ +# +$IncludeConfig /etc/rsyslog.d/*.conf + +# +# Suppress duplicate messages and report "message repeated n times" +# +$RepeatedMsgReduction on + +############### +#### RULES #### +############### \ No newline at end of file