From b1a0fd7dc38f4ef7f453043b5dc1bfd546cc0573 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Thu, 28 Mar 2019 11:18:01 -0700 Subject: [PATCH] Add tests for QA:Testcase Remote Logging test case This commit adds server and client tests to cover the remote logging Server test case. Signed-off-by: Adam Williamson --- templates | 54 +++++++++++++++++++++++++++ tests/server_remote_logging_client.pm | 39 +++++++++++++++++++ tests/server_remote_logging_server.pm | 43 +++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 tests/server_remote_logging_client.pm create mode 100644 tests/server_remote_logging_server.pm diff --git a/templates b/templates index 77dbd406..e47a6132 100755 --- a/templates +++ b/templates @@ -831,6 +831,28 @@ }, test_suite => { name => "server_database_client" }, }, + { + machine => { name => "64bit" }, + prio => 20, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "Server-dvd-iso", + version => "*", + }, + test_suite => { name => "server_remote_logging_server" }, + }, + { + machine => { name => "64bit" }, + prio => 20, + product => { + arch => "x86_64", + distri => "fedora", + flavor => "Server-dvd-iso", + version => "*", + }, + test_suite => { name => "server_remote_logging_client" }, + }, { machine => { name => "64bit" }, prio => 40, @@ -5624,6 +5646,38 @@ { key => "WORKER_CLASS", value => "tap" }, ], }, + { + name => "server_remote_logging_server", + settings => [ + { key => "PARALLEL_CANCEL_WHOLE_CLUSTER", value => "0" }, + { key => "POSTINSTALL", value => "server_remote_logging_server" }, + { key => "USER_LOGIN", value => "false" }, + { key => "ROOT_PASSWORD", value => "weakpassword" }, + { key => "START_AFTER_TEST", value => "install_default_upload" }, + { key => "BOOTFROM", value => "c" }, + { key => "HDD_1", value => "disk_%FLAVOR%_%MACHINE%.qcow2" }, + { key => "GRUB_POSTINSTALL", value => "net.ifnames=0 biosdevname=0" }, + { key => "POST_STATIC", value => "10.0.2.112 rsyslogserver.domain.local" }, + { key => "NICTYPE", value => "tap" }, + { key => "WORKER_CLASS", value => "tap" }, + ], + }, + { + name => "server_remote_logging_client", + settings => [ + { key => "POSTINSTALL", value => "server_remote_logging_client" }, + { key => "USER_LOGIN", value => "false" }, + { key => "ROOT_PASSWORD", value => "weakpassword" }, + { key => "START_AFTER_TEST", value => "install_default_upload" }, + { key => "PARALLEL_WITH", value => "server_remote_logging_server" }, + { key => "BOOTFROM", value => "c" }, + { key => "HDD_1", value => "disk_%FLAVOR%_%MACHINE%.qcow2" }, + { key => "GRUB_POSTINSTALL", value => "net.ifnames=0 biosdevname=0" }, + { key => "POST_STATIC", value => "10.0.2.113 rsyslogclient.domain.local" }, + { key => "NICTYPE", value => "tap" }, + { key => "WORKER_CLASS", value => "tap" }, + ], + }, { name => "desktop_update_graphical", settings => [ diff --git a/tests/server_remote_logging_client.pm b/tests/server_remote_logging_client.pm new file mode 100644 index 00000000..ed4832ab --- /dev/null +++ b/tests/server_remote_logging_client.pm @@ -0,0 +1,39 @@ +use base "installedtest"; +use strict; +use testapi; +use lockapi; + +sub run { + my $self=shift; + if (not (check_screen "root_console", 0)) { + $self->root_console(tty=>3); + } + # ensure rsyslog is installed and enabled + script_run "dnf -y install rsyslog", 180; + script_run "systemctl enable --now rsyslog.service"; + # set up forwarding + assert_script_run "printf 'action(type=\"omfwd\"\nTarget=\"10.0.2.112\" Port=\"514\" Protocol=\"udp\")' >> /etc/rsyslog.conf"; + # for debugging + upload_logs "/etc/rsyslog.conf"; + # wait for server to be ready, then restart rsyslog + mutex_lock "rsyslog_server_ready"; + mutex_unlock "rsyslog_server_ready"; + assert_script_run "systemctl restart rsyslog.service"; + # send a test message and tell server we did it + assert_script_run "logger user.warn XXX RSYSLOG TEST MESSAGE"; + sleep 2; + # for debugging + upload_logs "/var/log/messages"; + mutex_create "rsyslog_message_sent"; + # wait for server to tell us it got the message + mutex_lock "rsyslog_message_received"; + mutex_unlock "rsyslog_message_received"; +} + +sub test_flags { + return { fatal => 1 }; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/server_remote_logging_server.pm b/tests/server_remote_logging_server.pm new file mode 100644 index 00000000..3fc4ff7a --- /dev/null +++ b/tests/server_remote_logging_server.pm @@ -0,0 +1,43 @@ +use base "installedtest"; +use strict; +use testapi; +use lockapi; +use mmapi; + +sub run { + my $self=shift; + if (not (check_screen "root_console", 0)) { + $self->root_console(tty=>3); + } + # ensure rsyslog is installed and enabled + script_run "dnf -y install rsyslog", 180; + script_run "systemctl enable --now rsyslog.service"; + # set up imudp module + assert_script_run 'sed -i -e "s,#module(load=\"imudp\"),module(load=\"imudp\"),g" /etc/rsyslog.conf'; + assert_script_run 'sed -i -e "s,#input(type=\"imudp\",input(type=\"imudp\",g" /etc/rsyslog.conf'; + # for debugging + upload_logs "/etc/rsyslog.conf"; + # open firewall port + assert_script_run 'firewall-cmd --permanent --add-port=514/udp'; + assert_script_run 'firewall-cmd --reload'; + # start rsyslog + assert_script_run "systemctl restart rsyslog.service"; + # tell client we're ready and wait for it to send the message + mutex_create("rsyslog_server_ready"); + my $children = get_children(); + my $child_id = (keys %$children)[0]; + mutex_lock('rsyslog_message_sent', $child_id); + mutex_unlock('rsyslog_message_sent'); + # check we got the message + assert_script_run 'grep "XXX RSYSLOG TEST MESSAGE" /var/log/messages'; + # tell child test we were successful + mutex_create("rsyslog_message_received"); +} + +sub test_flags { + return { fatal => 1 }; +} + +1; + +# vim: set sw=4 et: