1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
--echo #
--echo # WL#9343: log TNG: log writers
--echo #
--echo # This test verifies the interaction with the 'ix syslog.
--echo # It is disabled by default, to be run manually, so we
--echo # won't spam the test host's syslog on a regular and concurrent
--echo # basis. Besides, we'd have to make an unpleasant amount of
--echo # assumptions about where the logs are located, how they're structured,
--echo # and that we had the privileges to access them.
--echo # This test is therefore provided for convenience, but disabled by
--echo # default, and is not expect to pass on all platforms.
--echo #
--echo # Loading of logging components is now implicit when log_error_services
--echo # is set. Using INSTALL/UNINSTALL is no longer necessary (but possible
--echo # e.g. when you wish to load but not immediately activate a component,
--echo # like we do here for testing).
--echo # Mixing the two (e.g. by using INSTALL and then implicitly loading
--echo # the same component implicitly by setting --log-error-services from
--echo # the command-line on restart as well) results in a warning that we
--echo # failed to load a component (as trying to restore the configuration
--echo # persisted with INSTALL COMPONENT will try to load a component a
--echo # second time that was already loaded implicitly by listing it in
--echo # --log-error-services=...).
--echo #
--echo # on systemd systems: journalctl SYSLOG_IDENTIFIER=mysqld-wl9343
--echo # on syslog systems: grep mysqld-wl9343 /var/log/messages|cut -d: -f4-
--echo #
--source include/have_debug.inc
--source include/linux.inc
--source include/have_log_component.inc
let GREP_START=`SELECT DATE_FORMAT(CONVERT_TZ(SYSDATE(6),'SYSTEM','UTC'),'%Y%m%d%H%i%s%f');`;
SET @@global.log_error_verbosity=3;
let $log_error_= `SELECT @@GLOBAL.log_error`;
if($log_error_ == "stderr")
{
let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err;
}
FLUSH LOGS;
# Send parse-trace to error log; first one with a current timestamp
# to compare against our GREP_START defined above.
SET @@session.debug="+d,parser_stmt_to_error_log";
# Now normalize timestamp and thread_ID on all following lines,
# for less hassle with --regex_replace in test files. Once
# WL#9651 goes live, we can use that to achieve the same thing.
SET @@session.debug="+d,log_error_normalize";
# Log parser statement with System label too.
SET @@session.debug="+d,parser_stmt_to_error_log_with_system_prio";
SELECT @@global.log_error_services;
--echo
# Component not loaded, variable not present
--error ER_UNKNOWN_SYSTEM_VARIABLE
SELECT @@syseventlog.tag;
# Component is not present, INSTALL should succeed
SELECT "*** SWITCHING ERROR LOG TO SYSEVENTLOG ***";
INSTALL COMPONENT "file://component_log_sink_syseventlog";
--echo # default value
SELECT @@global.syseventlog.tag;
--echo # change tag
SET @@global.syseventlog.tag="wl9343";
SELECT @@global.syseventlog.tag;
--echo # use syslog/eventlog as only sink. this should throw a warning.
SET @@global.log_error_services="log_sink_syseventlog";
--echo # show that this sink can log to performance_schema.error_log.
SELECT "log_sink_syseventlog-mark";
SELECT error_code, data
FROM performance_schema.error_log
WHERE DATA LIKE "%log_sink_syseventlog-mark%" LIMIT 1;
SET @@global.log_error_services="log_filter_internal; log_sink_internal; log_sink_syseventlog";
SELECT "logging to syslog";
--echo # change while component is active
SET @@global.syseventlog.tag="wl9343_2";
SELECT @@global.syseventlog.tag;
SET @@global.log_error_services="log_filter_internal; log_sink_internal";
--echo # change while component is loaded, but inactive
SET @@global.syseventlog.tag=DEFAULT;
SELECT @@global.syseventlog.tag;
# Check that SET PERSIST retains variable values
# ---------------------------------------------------------
SET PERSIST syseventlog.include_pid = OFF;
SET PERSIST syseventlog.facility = "local1";
SET PERSIST syseventlog.tag = "wl11828";
# We uninstall the component we explicitly installed above so we can use
# implicitly loading from the command-line below without the server
# complaining that we're mixing both.
UNINSTALL COMPONENT "file://component_log_sink_syseventlog";
--let $log_services="log_filter_internal;log_sink_syseventlog;log_sink_internal"
--let restart_parameters="restart: --no-console --log-error-services=$log_services --syseventlog.tag=override"
--source include/restart_mysqld.inc
# Verify value of the persisted variable
SELECT @@syseventlog.include_pid;
SELECT @@syseventlog.facility;
SELECT @@syseventlog.tag;
RESET PERSIST `syseventlog.include_pid`;
RESET PERSIST `syseventlog.facility`;
RESET PERSIST `syseventlog.tag`;
--echo
# Verify that we accept arguments passed at start-up
--let $log_services="log_filter_internal;log_sink_syseventlog;log_sink_internal"
--let restart_parameters="restart: --no-console --log-error-services=$log_services --syseventlog.include_pid=OFF --syseventlog.facility=local2 --syseventlog.tag=wl11828_2 "
--source include/restart_mysqld.inc
# Verify value of the persisted variable
SELECT @@syseventlog.include_pid;
SELECT @@syseventlog.facility;
SELECT @@syseventlog.tag;
# Verify that we use default settings if invalid arguments are passed
# at start-up
--let LOG_FILE= $MYSQLTEST_VARDIR/tmp/wl11828.err
--let $log_services="log_filter_internal;log_sink_syseventlog;log_sink_internal"
--let restart_parameters="restart: --no-console --log-error=$LOG_FILE --log-error-services=$log_services --syseventlog.include_pid=PIKA --syseventlog.facility=localZ --syseventlog.tag=wl11828/2 "
--replace_result $LOG_FILE LOG_FILE
--source include/restart_mysqld.inc
# Verify value of the persisted variable
SELECT @@syseventlog.include_pid;
SELECT @@syseventlog.facility;
SELECT @@syseventlog.tag;
# Cleanup
SET GLOBAL log_error_services= default;
--echo
# Implicitly load the component.
SET GLOBAL log_error_services= "log_filter_internal;log_sink_syseventlog";
# Now we have the component loaded and active (because of the implicit
# loading), and we have an entry in mysql.component.
# Unfortunately, they don't belong to each other. The component
# framework detects this:
--error ER_COMPONENTS_UNLOAD_CANT_UNREGISTER_SERVICE
UNINSTALL COMPONENT "file://component_log_sink_syseventlog";
# Unload the implicitly loaded component.
SET GLOBAL log_error_services= default;
SET @@session.debug="-d,parser_stmt_to_error_log_with_system_prio";
SET @@session.debug="-d,parser_stmt_to_error_log";
SET @@session.debug="-d,log_error_normalize";
## WL#9651
# SET @@global.log_error_filter_rules=@save_filters;
FLUSH ERROR LOGS;
--perl
use strict;
use JSON;
my $file= $ENV{'LOG_FILE'} or die("logfile not set");
my $result=0;
open(FILE, "$file") or die("Unable to open $file: $!");
while (<FILE>) {
my $line = $_;
if ($line =~ /syseventlog\./) {
$line =~ s/.*\]//;
print $line;
}
}
close(FILE);
EOF
--remove_file $LOG_FILE
--let restart_parameters="restart:"
--source include/restart_mysqld.inc
--echo
--echo ###
--echo ### done
--echo ###
|