From 2b97adfa70ce5d9f25bd59b4b96c2afa4f76936b Mon Sep 17 00:00:00 2001 From: Mateusz Majewski Date: Tue, 18 Aug 2020 14:06:37 +0200 Subject: [PATCH] Enable QoS test in the logger backend This is aggressively hacky and I don't like it, but it's good enough for now. Change-Id: Iee6c3c79ec6a1af2d8073662b955b86a5ad9b0fc --- Makefile.am | 3 +- configs/dlog-logger.conf.qos | 44 ++++++++++++++++++++ configs/dlog-pipe.conf.qos | 96 ++++++++++++++++++++++++++++++++++++++++++++ configs/qos-additions | 6 --- packaging/dlog.spec | 3 +- tests/dlog_test.in | 82 ++++++++++++++++++++++--------------- 6 files changed, 193 insertions(+), 41 deletions(-) create mode 100644 configs/dlog-logger.conf.qos create mode 100644 configs/dlog-pipe.conf.qos delete mode 100644 configs/qos-additions diff --git a/Makefile.am b/Makefile.am index 9da5b39..d9fc485 100644 --- a/Makefile.am +++ b/Makefile.am @@ -647,7 +647,8 @@ data_DATA = \ configs/dlog-logger.conf.alias \ configs/dlog-pipe.conf.cpu \ configs/dlog-logger.conf.cpu \ - configs/qos-additions + configs/dlog-pipe.conf.qos \ + configs/dlog-logger.conf.qos unitdir = $(prefix)/lib/systemd/system nodist_unit_DATA = configs/dlog_logger.service \ diff --git a/configs/dlog-logger.conf.qos b/configs/dlog-logger.conf.qos new file mode 100644 index 0000000..1d0b0ae --- /dev/null +++ b/configs/dlog-logger.conf.qos @@ -0,0 +1,44 @@ +##### Settings used by the logging library +backend=logger +main=/dev/log_main +apps=/dev/log_apps:/dev/log_events: +system=/dev/log_system: +radio=/dev/log_radio: + +main_size=1048576 +apps_size=1048576 +system_size=1048576 +radio_size=1048576 + +plog=1 +debugmode=1 +limiter=1 +limiter|*|*=allow +kmsg=: +syslog=: + +kmsg_write_sock=/var/lib/dlog-tests/kmsg.wr +syslog_write_sock=/var/lib/dlog-tests/syslog.wr + +kmsg_ctl_sock=/var/lib/dlog-tests/kmsg.ctl +syslog_ctl_sock=/var/lib/dlog-tests/syslog.ctl + +kmsg_write_sock_rights=0222 +syslog_write_sock_rights=0222 + +kmsg_ctl_sock_rights=0222 +syslog_ctl_sock_rights=0222 + +kmsg_size=1048576 +syslog_size=1048576 + +util_sorting_time_window=1000 +util_sorting_buffer_size=8192 +dynamic_config_path=/tmp/dlog-filters/ + +qos_file_path=/tmp/dlog-filters/42-qos.conf +qos_refresh_rate_s=5 +qos_max_throughput_logs=50 +qos_threshold_logs=40 +qos_threshold_reapply_logs=5 +qos_method=equal diff --git a/configs/dlog-pipe.conf.qos b/configs/dlog-pipe.conf.qos new file mode 100644 index 0000000..76d5fdf --- /dev/null +++ b/configs/dlog-pipe.conf.qos @@ -0,0 +1,96 @@ +# Lines starting with # are comments and are ignored. +# Empty lines are also ignored. +# Every other line is a config value and has to be in key=value format + +backend=pipe + +##### Settings used by the logging library + +# Platform logging. Whether logging happens at all. +plog=1 + +# Debugmode - whether write platform debug log or not +debugmode=1 + +# Limiter - whether it's enabled and the rules (check the documentation for how to create rules). +limiter=1 +limiter|*|*=allow + +##### Settings used by the logging daemon + +# Sockets that all programs connect to to receive a logging pipe. +main_write_sock=/var/lib/dlog-tests/main.wr +apps_write_sock=/var/lib/dlog-tests/apps.wr +system_write_sock=/var/lib/dlog-tests/system.wr +radio_write_sock=/var/lib/dlog-tests/radio.wr +kmsg_write_sock=/var/lib/dlog-tests/kmsg.wr +syslog_write_sock=/var/lib/dlog-tests/syslog.wr + +# Sockets that administrative programs connect to to manipulate the daemon. +main_ctl_sock=/var/lib/dlog-tests/main.ctl +apps_ctl_sock=/var/lib/dlog-tests/apps.ctl +system_ctl_sock=/var/lib/dlog-tests/system.ctl +radio_ctl_sock=/var/lib/dlog-tests/radio.ctl +kmsg_ctl_sock=/var/lib/dlog-tests/kmsg.ctl +syslog_ctl_sock=/var/lib/dlog-tests/syslog.ctl + +# Permissions for the relevant sockets. +main_write_sock_rights=0222 +apps_write_sock_rights=0222 +system_write_sock_rights=0222 +radio_write_sock_rights=0222 +kmsg_write_sock_rights=0222 +syslog_write_sock_rights=0222 + +main_ctl_sock_rights=0222 +apps_ctl_sock_rights=0222 +system_ctl_sock_rights=0222 +radio_ctl_sock_rights=0222 +kmsg_ctl_sock_rights=0222 +syslog_ctl_sock_rights=0222 + +main_write_sock_owner=log +apps_write_sock_owner=log +system_write_sock_owner=log +radio_write_sock_owner=log +kmsg_write_sock_owner=log +syslog_write_sock_owner=log + +main_ctl_sock_owner=log +apps_ctl_sock_owner=log +system_ctl_sock_owner=log +radio_ctl_sock_owner=log +kmsg_ctl_sock_owner=log +syslog_ctl_sock_owner=log + +main_write_sock_group=log +apps_write_sock_group=log +system_write_sock_group=log +radio_write_sock_group=log +kmsg_write_sock_group=log +syslog_write_sock_group=log + +main_ctl_sock_group=log +apps_ctl_sock_group=log +system_ctl_sock_group=log +radio_ctl_sock_group=log +kmsg_ctl_sock_group=log +syslog_ctl_sock_group=log + +main_size=1048576 +apps_size=1048576 +system_size=1048576 +radio_size=1048576 +kmsg_size=1048576 +syslog_size=1048576 + +util_sorting_time_window=5000 +util_sorting_buffer_size=32000 +dynamic_config_path=/tmp/dlog-filters/ + +qos_file_path=/tmp/dlog-filters/42-qos.conf +qos_refresh_rate_s=5 +qos_max_throughput_logs=50 +qos_threshold_logs=40 +qos_threshold_reapply_logs=5 +qos_method=equal diff --git a/configs/qos-additions b/configs/qos-additions deleted file mode 100644 index 0ce8839..0000000 --- a/configs/qos-additions +++ /dev/null @@ -1,6 +0,0 @@ -qos_file_path=/tmp/dlog-filters/42-qos.conf -qos_refresh_rate_s=5 -qos_max_throughput_logs=50 -qos_threshold_logs=40 -qos_threshold_reapply_logs=5 -qos_method=equal diff --git a/packaging/dlog.spec b/packaging/dlog.spec index 2dc22fa..fd020c2 100644 --- a/packaging/dlog.spec +++ b/packaging/dlog.spec @@ -346,7 +346,8 @@ chsmack -e 'System' %{_libexecdir}/dlog-log-critical %{_datadir}/dlog-logger.conf.alias %{_datadir}/dlog-pipe.conf.cpu %{_datadir}/dlog-logger.conf.cpu -%{_datadir}/qos-additions +%{_datadir}/dlog-pipe.conf.qos +%{_datadir}/dlog-logger.conf.qos %{_sysconfdir}/dlog.conf.d/99-dlog-logger.disable-platform-logging-for-testsuite.conf %dir %attr(755,log,log) /var/lib/dlog-tests %dir %attr(755,log,log) /usr/share/dlog-filters.conf.test diff --git a/tests/dlog_test.in b/tests/dlog_test.in index eb39f5f..82f206a 100644 --- a/tests/dlog_test.in +++ b/tests/dlog_test.in @@ -761,49 +761,65 @@ if [ "$TEST_DYNAMIC_FILTERS" == "true" ]; then # 2 logs from each period are allowed. [[ $(dlogutil --pid $DLOGSEND_PID -d | wc -l) -eq 6 ]] && ok || fail + # TODO: HACK ALERT! + # The following QoS tests make perfect sense for the pipe backend, since we kill the already + # existing dlog_logger and then start the new one, configured with QoS. However, on the logger + # backend this is impossible, as dlog_test uses the global service started by systemd then. + # This means that we have to just launch the second instance and hope nothing breaks. + # This can be improved by not using the global service in the logger backend, and by having it + # completely disabled in the config file -- this way, the tests would be completely uniform. + PREQOS_CONFIG_PATH=$DLOG_CONFIG_PATH + DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.qos" if [ $type == "pipe" ]; then - PREQOS_CONFIG_PATH=$DLOG_CONFIG_PATH - DLOG_CONFIG_PATH="$TESTDIR/qos.conf" - cat $PREQOS_CONFIG_PATH "@datadir@/qos-additions" > $DLOG_CONFIG_PATH kill $LOGGER > /dev/null sleep 1 - dlog_logger -b 99 -t 0 & - LOGGER=$! - sleep 1 + fi + dlog_logger -b 99 -t 0 & + LOGGER=$! + sleep 1 - dlogsend -b main -t DLOG_QOS_TEST0 -c 30 -d 1 -f 2 "A normal app that just wants to log" - LOG_DETAILS="testing if QoS works (1/4)" - [[ $(dlogutil -d DLOG_QOS_TEST0 | wc -l) -eq 30 ]] && ok || fail - kill $LOGGER > /dev/null - sleep 1 - dlog_logger -b 99 -t 0 & - LOGGER=$! - sleep 1 + dlogsend -b main -t DLOG_QOS_TEST0 -c 30 -d 1 -f 2 "A normal app that just wants to log" + LOG_DETAILS="testing if QoS works (1/4)" + [[ $(dlogutil -d DLOG_QOS_TEST0 | wc -l) -eq 30 ]] && ok || fail + kill $LOGGER > /dev/null + sleep 1 + if [ $type == "logger" ]; then + dlogutil -cb main + fi + dlog_logger -b 99 -t 0 & + LOGGER=$! + sleep 1 - dlogsend -b main -t DLOG_QOS_TEST1 -c 300 -d 1 -f 20 "Some log spam" - LOG_DETAILS="testing if QoS works (2/4)" - [[ $(dlogutil -d DLOG_QOS_TEST1 | wc -l) -le 180 ]] && ok || fail - kill $LOGGER > /dev/null - sleep 1 - dlog_logger -b 99 -t 0 & - LOGGER=$! - sleep 1 + dlogsend -b main -t DLOG_QOS_TEST1 -c 300 -d 1 -f 20 "Some log spam" + LOG_DETAILS="testing if QoS works (2/4)" + [[ $(dlogutil -d DLOG_QOS_TEST1 | wc -l) -le 180 ]] && ok || fail + kill $LOGGER > /dev/null + sleep 1 + if [ $type == "logger" ]; then + dlogutil -cb main + fi + dlog_logger -b 99 -t 0 & + LOGGER=$! + sleep 1 - dlogsend -b main -t DLOG_QOS_TEST2 -c 30 -d 1 -f 2 "A normal app that just wants to log" & - DLOGSEND_PID=$! - dlogsend -b main -t DLOG_QOS_TEST3 -c 270 -d 1 -f 18 "Some log spam" - wait $DLOGSEND_PID - LOG_DETAILS="testing if QoS works (3/4)" - [[ $(dlogutil -d DLOG_QOS_TEST2 DLOG_QOS_TEST3 | wc -l) -le 180 ]] && ok || fail - LOG_DETAILS="testing if QoS works (4/4)" - [[ $(dlogutil -d DLOG_QOS_TEST2 | wc -l) -gt 24 ]] && ok || fail + dlogsend -b main -t DLOG_QOS_TEST2 -c 30 -d 1 -f 2 "A normal app that just wants to log" & + DLOGSEND_PID=$! + dlogsend -b main -t DLOG_QOS_TEST3 -c 270 -d 1 -f 18 "Some log spam" + wait $DLOGSEND_PID + LOG_DETAILS="testing if QoS works (3/4)" + [[ $(dlogutil -d DLOG_QOS_TEST2 DLOG_QOS_TEST3 | wc -l) -le 180 ]] && ok || fail + LOG_DETAILS="testing if QoS works (4/4)" + [[ $(dlogutil -d DLOG_QOS_TEST2 | wc -l) -gt 24 ]] && ok || fail - DLOG_CONFIG_PATH=$PREQOS_CONFIG_PATH - kill $LOGGER > /dev/null - sleep 1 + DLOG_CONFIG_PATH=$PREQOS_CONFIG_PATH + kill $LOGGER > /dev/null + sleep 1 + if [ $type == "pipe" ]; then dlog_logger -b 99 -t 0 & LOGGER=$! sleep 1 + else + LOGGER=-1 fi fi fi -- 2.7.4