#################################################################### # The aim of this test is to provide mysqld options related to # # error logging on the command line and verify their behaviour. # # # # Creation Date: 2017-03-02 # # Author: Srikanth B R # # # #################################################################### ##================================================================## # 1 - Tests to check error log verbosity on command line # ##================================================================## --source include/have_log_bin.inc # Setup CREATE TABLE t1(a int); # 1.1 Set log_error_verbosity= 1 #------------------------------- --let LOG_FILE1= $MYSQLTEST_VARDIR/tmp/test1.err --let restart_parameters="restart: --log-error=$LOG_FILE1 --log-error-verbosity=1 --binlog-format=statement" --replace_result $LOG_FILE1 LOG_FILE1 --source include/restart_mysqld.inc # Run commands which lead to entry of warnings/notes in the error log # Warning - unsafe statement to binlog INSERT INTO t1 SELECT FOUND_ROWS(); # Note - Access denied --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con1,localhost,unknown_user,,*NO-ONE*); # 1.2 Set log_error_verbosity= 2 #------------------------------- --let LOG_FILE2= $MYSQLTEST_VARDIR/tmp/test2.err --let restart_parameters="restart: --log-error=$LOG_FILE2 --log-error-verbosity=2 --binlog-format=statement" --replace_result $LOG_FILE2 LOG_FILE2 --source include/restart_mysqld.inc # Run commands which lead to entry of warnings/notes in the error log # Warning - unsafe statement to binlog INSERT INTO t1 SELECT FOUND_ROWS(); # Note - Access denied --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con2,localhost,unknown_user,,*NO-ONE*); # 1.3 Set log_error_verbosity= 3 #------------------------------- --let LOG_FILE3= $MYSQLTEST_VARDIR/tmp/test3.err --let restart_parameters="restart: --log-error=$LOG_FILE3 --log-error-verbosity=3 --binlog-format=statement" --replace_result $LOG_FILE3 LOG_FILE3 --source include/restart_mysqld.inc # Run commands which lead to entry of warnings/notes in the error log # Warning - unsafe statement to binlog INSERT INTO t1 SELECT FOUND_ROWS(); # Note - Access denied --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con3,localhost,unknown_user,,*NO-ONE*); # Cleanup DROP TABLE t1; ##================================================================## # 2 - Tests to check error log verbosity during initialization # ##================================================================## # 2.1. Invalid verbosity with --initialize(reverts to # minimum - 1) #----------------------------------------------------- --let LOG_FILE4 = $MYSQLTEST_VARDIR/tmp/bootstrap1.err --let CMD1= $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLTEST_VARDIR/tmp/new_datadir --log-error=$LOG_FILE4 --log-error-verbosity=-1 --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:23200@1' 2>&1 --exec $CMD1 --force-rmdir $MYSQLTEST_VARDIR/tmp/new_datadir # 2.2. Set verbosity to 1 explicitly with --initialize #----------------------------------------------------- --let LOG_FILE5 = $MYSQLTEST_VARDIR/tmp/bootstrap3.err --let CMD3 = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLTEST_VARDIR/tmp/new_datadir --log-error=$LOG_FILE5 --log-error-verbosity=1 --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:23200@1' 2>&1 --exec $CMD3 --force-rmdir $MYSQLTEST_VARDIR/tmp/new_datadir # 2.3. Set verbosity to 2 explicitly with --initialize #----------------------------------------------------- --let LOG_FILE6 = $MYSQLTEST_VARDIR/tmp/bootstrap2.err --let CMD2 = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLTEST_VARDIR/tmp/new_datadir --log-error=$LOG_FILE6 --log-error-verbosity=2 --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:23200@1' 2>&1 --exec $CMD2 --force-rmdir $MYSQLTEST_VARDIR/tmp/new_datadir # 2.4. Set verbosity to 7 with --initialize (adjusted # to 3) #----------------------------------------------------- --let LOG_FILE7 = $MYSQLTEST_VARDIR/tmp/bootstrap4.err --let CMD4 = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLTEST_VARDIR/tmp/new_datadir --log-error=$LOG_FILE7 --log-error-verbosity=7 --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:23200@1' 2>&1 --exec $CMD4 --force-rmdir $MYSQLTEST_VARDIR/tmp/new_datadir ##================================================================## # 3 - WL#9344: Logging services: error messages # ##================================================================## # 3.1. Test giving an empty lc-messages-dir and verify that the # server makes use of builtin english messages when the # language files (errmsg.sys) are not found #-------------------------------------------------------------- --let LOG_FILE8 = $MYSQLTEST_VARDIR/tmp/wl9344.err --let $MSG_DIR = $MYSQLTEST_VARDIR/tmp/empty_lcmsgsdir --mkdir $MSG_DIR --let restart_parameters="restart: --log-error=$LOG_FILE8 --lc-messages-dir=$MSG_DIR --log-error-verbosity=3" --replace_result $LOG_FILE8 LOG_FILE8 $MSG_DIR MSG_DIR --source include/restart_mysqld.inc --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con4,localhost,unknown_user,,*NO-ONE*); --rmdir $MSG_DIR # Related: # # Bug#26576922: SERVER DOESN'T ALWAYS FALL BACK TO DEFAULT ERROR MESSAGES # # Test giving an empty lc-messages and verify that the # server makes use of builtin english messages when the # language files (errmsg.sys) are not found #-------------------------------------------------------------- --let LOG_FILE8B = $MYSQLTEST_VARDIR/tmp/bug26576922.err --mkdir $MSG_DIR --let restart_parameters="restart: --log-error=$LOG_FILE8B --lc-messages=invalid_arg1 --lc-time-names=invalid_arg2" --replace_result $LOG_FILE8B LOG_FILE8B $MSG_DIR MSG_DIR --source include/restart_mysqld.inc --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con4,localhost,unknown_user,,*NO-ONE*); --rmdir $MSG_DIR ##================================================================## # 4 - WL#9323: Logging services: Improved Error logging in 8.0 # ##================================================================## # 4.1 Provide invalid value 'abcd' to --log-error-services # -------------------------------------------------------- # Below check is to see that the server doesn't abort --let LOG_FILE9= $MYSQLTEST_VARDIR/tmp/test9.err --let restart_parameters="restart: --log-error=$LOG_FILE9 --log-error-verbosity=3 --log-error-services=abcd " --replace_result $LOG_FILE9 LOG_FILE9 --source include/restart_mysqld.inc SELECT @@GLOBAL.LOG_ERROR_SERVICES; # If we fail with ER_WRONG_VALUE_FOR_VAR here, then the server has started # despite of an invalid value for log-error-services: it has in fact rejected # that value and is using the default (as it should), but shows the (illegal) # value from start-up on SELECT (which it shouldn't): SET GLOBAL LOG_ERROR_SERVICES=@@GLOBAL.LOG_ERROR_SERVICES; # Verify that log_error_services is reset to default with a message # in the error log --let SEARCH_FILE= $LOG_FILE9 --let SEARCH_PATTERN= \[Warning\].*Cannot set services "abcd" requested in --log-error-services, using defaults --source include/search_pattern.inc # 4.2 Provide 'log_sink_json' to --log-error-services without # installing the json writer component #------------------------------------------------------------- # Below check is to see that the server doesn't abort and that # log_error_services is reset to default --let LOG_FILE10= $MYSQLTEST_VARDIR/tmp/test10.err --let restart_parameters="restart: --log-error=$LOG_FILE10 --log-error-verbosity=3 --log-error-services=log_sink_json " --replace_result $LOG_FILE10 LOG_FILE10 --source include/restart_mysqld.inc --let SEARCH_FILE= $LOG_FILE10 --let SEARCH_PATTERN= \[Warning\].*Cannot set services "log_sink_json" requested in --log-error-services, using defaults --source include/search_pattern.inc # 4.3 Install the json writer component and provide its service # to --log-error-services # ------------------------------------------------------------- INSTALL COMPONENT "file://component_log_sink_json"; --let LOG_FILE11= $MYSQLTEST_VARDIR/tmp/test11.err --let LOG_FILE11j= $MYSQLTEST_VARDIR/tmp/test11.err.00.json --let $log_services="log_filter_internal;log_sink_internal;log_sink_json" --let restart_parameters="restart: --no-console --log-error=$LOG_FILE11 --log-error-services=$log_services --log-error-verbosity=3" --replace_result $LOG_FILE11 LOG_FILE11 --source include/restart_mysqld.inc --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con5,localhost,unknown_user,,*NO-ONE*); SET GLOBAL log_error_services= default; UNINSTALL COMPONENT "file://component_log_sink_json"; ##================================================================## # 5 - WL#9323: Logging services: log filter (configuration engine) # ##================================================================## # 5.1 Check that option --dragnet.log_error_filter_rules does # not exist when the component isn't loaded # ------------------------------------------------------------ --let LOG_FILE12 = $MYSQLTEST_VARDIR/tmp/test12.err --let CMD12 = $MYSQLD --no-defaults --lc-messages-dir=$MYSQL_SHAREDIR --innodb_dedicated_server=OFF --initialize-insecure --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLTEST_VARDIR/tmp/new_datadir --log-error=$LOG_FILE12 --dragnet.log_error_filter_rules=a --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:23200@1' 2>&1 # mysqld aborts if the option is used without loading the component --error 1 --exec $CMD12 --force-rmdir $MYSQLTEST_VARDIR/tmp/new_datadir --let SEARCH_FILE= $LOG_FILE12 --let SEARCH_PATTERN= \[ERROR\].*unknown variable 'dragnet.log_error_filter_rules=a' --source include/search_pattern.inc # 5.2 a) Pass --dragnet.log-error-filter-rules through command # line # b) Set dragnet.log_error_filter_rules to include a throttle # for number of times ER_ACCESS_DENIED_ERROR appears in the # error log and exceed the throttle limit # ------------------------------------------------------------- INSTALL COMPONENT "file://component_log_filter_dragnet"; --let $log_services="log_filter_internal;log_filter_dragnet;log_sink_internal" --let LOG_FILE13= $MYSQLTEST_VARDIR/tmp/test13.err --let restart_parameters="restart: --no-console --log-error=$LOG_FILE13 --log-error-services=$log_services --dragnet.log-error-filter-rules=" --replace_result $LOG_FILE13 LOG_FILE13 --source include/restart_mysqld.inc # Validate parameters passed through command line SELECT @@log_error_services; SELECT @@dragnet.log_error_filter_rules; SET @saved_log_error_verbosity= @@global.log_error_verbosity; # Enable logging NOTE's to test throttling SET GLOBAL log_error_verbosity= 3; # Throttle 'Access denied' messages in error log to three # entries per hour SET GLOBAL dragnet.log_error_filter_rules="IF err_code==ER_ACCESS_DENIED_ERROR_WITH_PASSWORD THEN throttle 3/3600."; --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con6,localhost,unknown_user,,*NO-ONE*); --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con6,localhost,unknown_user,,*NO-ONE*); --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con6,localhost,unknown_user,,*NO-ONE*); --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con6,localhost,unknown_user,,*NO-ONE*); --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con6,localhost,unknown_user,,*NO-ONE*); SET GLOBAL log_error_verbosity= @saved_log_error_verbosity; # 5.3 Check that SET PERSIST retains error log filter rules # --------------------------------------------------------- SET PERSIST dragnet.log_error_filter_rules= "IF prio>INFORMATION THEN drop."; --let LOG_FILE14= $MYSQLTEST_VARDIR/tmp/test14.err --let $log_services="log_filter_internal;log_filter_dragnet;log_sink_internal" --let restart_parameters="restart: --no-console --log-error=$LOG_FILE14 --log-error-services=$log_services " --replace_result $LOG_FILE14 LOG_FILE14 --source include/restart_mysqld.inc # Verify value of the persisted variable SELECT @@global.dragnet.log_error_filter_rules; RESET PERSIST `dragnet.log_error_filter_rules`; # Cleanup SET GLOBAL log_error_services= default; UNINSTALL COMPONENT "file://component_log_filter_dragnet"; --let $MYSQLD_DATADIR= `select @@datadir` --remove_file $MYSQLD_DATADIR/mysqld-auto.cnf # 6 Verify that we use default settings if an invalid rule-set # is passed at start-up # --------------------------------------------------------- INSTALL COMPONENT "file://component_log_filter_dragnet"; # Invalid filter config given in mysqld command line --let LOG_FILE15= $MYSQLTEST_VARDIR/tmp/test15.err --let restart_parameters="restart: --no-console --log-error=$LOG_FILE15 --dragnet.log_error_filter_rules=invalid" --replace_result $LOG_FILE15 LOG_FILE15 --source include/restart_mysqld.inc # Component will use default value due to the wrong configuration SELECT @@global.dragnet.log_error_filter_rules; # SET @@global.dragnet.log_error_filter_rules= DEFAULT; # SELECT @@global.dragnet.log_error_filter_rules; UNINSTALL COMPONENT "file://component_log_filter_dragnet"; ##==========================================================## # 7 - WL#11393: Logging services: log-error-suppression-list # ##==========================================================## # 7.1 Pass --log-error-suppression-list through command line # ---------------------------------------------------------- --let LOG_FILE16= $MYSQLTEST_VARDIR/tmp/test16.err --let restart_parameters="restart: --no-console --log-error=$LOG_FILE16 --log-error-suppression-list=ER_ACCESS_DENIED_ERROR_WITH_PASSWORD " --replace_result $LOG_FILE16 LOG_FILE16 --source include/restart_mysqld.inc # Validate parameters passed through command line SELECT @@global.log_error_suppression_list; # 7.2 Set --log-error-suppression-list to include a suppression # for ER_ACCESS_DENIED_ERROR, then cause that condition to occur. # ------------------------------------------------------------------- SET @saved_log_error_verbosity= @@global.log_error_verbosity; # Enable logging NOTE's to test throttling SET GLOBAL log_error_verbosity= 3; # Try to log in without proper credentials, cause ACCESS DENIED, filter it --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con6,localhost,unknown_user_filtered,,*NO-ONE*); # Unset suppression list, logging ACCESS DENIED is now allowed! SET @@global.log_error_suppression_list=""; SELECT @@global.log_error_suppression_list; # Try to log in without proper credentials, cause ACCESS DENIED, log it --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --error ER_ACCESS_DENIED_ERROR connect(con6,localhost,unknown_user_unfiltered,,*NO-ONE*); SET GLOBAL log_error_verbosity= @saved_log_error_verbosity; SET @@global.log_error_suppression_list=DEFAULT; # 7.3 Check that SET PERSIST retains error suppression list # --------------------------------------------------------- SET PERSIST log_error_suppression_list= "MY-10000"; --let LOG_FILE17= $MYSQLTEST_VARDIR/tmp/test17.err --let restart_parameters="restart: --no-console --log-error=$LOG_FILE17 " --replace_result $LOG_FILE17 LOG_FILE17 --source include/restart_mysqld.inc # Verify value of the persisted variable SELECT @@global.log_error_suppression_list; RESET PERSIST `log_error_suppression_list`; # Cleanup SET GLOBAL log_error_suppression_list= DEFAULT; SET GLOBAL log_error_services= DEFAULT; --let $MYSQLD_DATADIR= `select @@datadir` --remove_file $MYSQLD_DATADIR/mysqld-auto.cnf # 7.4 Verify that we use default settings if an invalid # suppression list is passed at start-up # -------------------------------------------------------------- # Invalid filter config given in mysqld command line --let LOG_FILE18= $MYSQLTEST_VARDIR/tmp/test18.err --let restart_parameters="restart: --no-console --log-error=$LOG_FILE18 --log_error_suppression_list=invalid" --replace_result $LOG_FILE18 LOG_FILE18 --source include/restart_mysqld.inc # Server will use default value due to the wrong configuration SELECT @@global.log_error_suppression_list; # Verify that a message is written to the error log --let SEARCH_FILE= $LOG_FILE18 --let SEARCH_PATTERN= log_error_suppression_list: Could not add suppression rule for code .invalid. --source include/search_pattern.inc # WL#11875: Verify that we restore PERSISTed log settings at start-up # before flushing buffered events # -------------------------------------------------------------- INSTALL COMPONENT "file://component_log_sink_json"; INSTALL COMPONENT "file://component_log_filter_dragnet"; --let LOG_FILE19= $MYSQLTEST_VARDIR/tmp/test19.err --let LOG_FILE19j= $MYSQLTEST_VARDIR/tmp/test19.err.00.json SET PERSIST dragnet.log_error_filter_rules="IF EXISTS msg THEN drop."; --let $log_services="log_filter_dragnet;log_sink_json" --let restart_parameters="restart: --log-error-services=$log_services --log-error=$LOG_FILE19" --replace_result $LOG_FILE19 LOG_FILE19 --source include/restart_mysqld.inc --echo # JSON error log content - begin --cat_file $LOG_FILE19j --echo # JSON error log content - end RESET PERSIST `dragnet.log_error_filter_rules`; SET GLOBAL log_error_services= DEFAULT; UNINSTALL COMPONENT "file://component_log_sink_json"; UNINSTALL COMPONENT "file://component_log_filter_dragnet"; --remove_file $MYSQLD_DATADIR/mysqld-auto.cnf ##===============================================================## # Validate error logs for the above cases # ##===============================================================## --echo --echo Reading error logs for validation --echo --------------------------------- --perl use strict; use JSON; # Entries matching the below patterns are logged before the # option '--log-error-verbosity' is processed. Hence, they # need to be ignored during verbosity checks. my @ignore_patterns=(); my $ignore_regex= scalar(@ignore_patterns)? "(". join('|', @ignore_patterns). ")": ""; # -------- # TEST 1.1 # -------- my $file= $ENV{'LOG_FILE1'} or die("logfile1 not set"); my $result=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; next if $ignore_regex and $line =~ /$ignore_regex/; if ($line =~ /\[Note\]/ or $line =~ /\[Warning\]/) { # '[Warning] Changed limits' is shown in-spite of verbosity being 1 print; $result=1; } } close(FILE); if($result) { print "[ FAIL ] Error log contains WARNING's/NOTE's even with --log-error-verbosity=1\n"; } else { print "[ PASS ] Error log does not contain WARNING's/NOTE's with --log-error-verbosity=1\n"; } # -------- # TEST 1.2 # -------- $file= $ENV{'LOG_FILE2'} or die("log file2 not set"); my $result_note=0; my $result_warning=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; next if $ignore_regex and $line =~ /$ignore_regex/; if ($line =~ /\[Note\]/) { $result_note=1; print; } if ($line =~ /\[Warning\]/) { $result_warning=1; } } close(FILE); if($result_note) { print "[ FAIL ] Error log contains NOTE's even with --log-error-verbosity=2\n"; } elsif (!$result_warning) { print "[ FAIL ] Error log does not WARNING's with --log-error-verbosity=2\n"; } else { print "[ PASS ] Error log does not contain NOTE's with --log-error-verbosity=2\n"; } # -------- # TEST 1.3 # -------- $file= $ENV{'LOG_FILE3'} or die("log file3 not set"); $result_note=0; $result_warning=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; if ($line =~ /\[Note\]/) { $result_note=1; } elsif ($line =~ /\[Warning\]/) { $result_warning=1; } } close(FILE); if($result_note and $result_warning) { print "[ PASS ] Error log contains NOTE's & WARNING's with --log-error-verbosity=3\n"; } else { print "[ FAIL ] Error log does not include WARNING's AND/OR NOTE's with --log-error-verbosity=3\n"; } # -------- # TEST 2.1 # -------- $file= $ENV{'LOG_FILE4'} or die("log file4 not set"); $result=0; my $verbosity_adjust_message_logged= 0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; next if $ignore_regex and $line =~ /$ignore_regex/; if ($line =~ /\[Note\]/) { print; $result=1; } elsif ($line =~ /\[Warning\]/) { if ( $line =~ /option 'log_error_verbosity': value -1 adjusted to 1/) { $verbosity_adjust_message_logged=1; } else { $result=1; print; } } } close(FILE); if($result) { print "[ FAIL ] Error log contains NOTE's and/or WARNING's with --log-error-verbosity=-1 during initialization\n"; } else { if ($verbosity_adjust_message_logged) { print "[ FAIL ] Error log does contain a warning that log_error_verbosity is adjusted to 1 from -1\n"; } else { # WL#11875 FR1: ("log-filtering applies to early, buffered logging") print "[ PASS ] Error log does not contain NOTE's or WARNING's with --log-error-verbosity=-1 (adjusted to 1) during initialization\n"; } } # -------- # TEST 2.2 # -------- $file= $ENV{'LOG_FILE5'} or die("log file5 not set"); $result=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; next if $ignore_regex and $line =~ /$ignore_regex/; if ($line =~ /\[Note\]/ or $line =~ /\[Warning\]/) { print; $result=1; } } close(FILE); if($result) { print "[ FAIL ] Error log contains WARNING's/NOTE's even with --log-error-verbosity=1 during initialization\n"; } else { print "[ PASS ] Error log does not contain WARNING's/NOTE's with --log-error-verbosity=1 during initialization\n"; } # -------- # TEST 2.3 # -------- my $file= $ENV{'LOG_FILE6'} or die("log file6 not set"); my $result=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; next if $ignore_regex and $line =~ /$ignore_regex/; if ($line =~ /\[Note\]/) { print; $result=1; } } close(FILE); if($result) { print "[ FAIL ] Error log contains NOTE's even with --log-error-verbosity=2 during initialization\n"; } else { print "[ PASS ] Error log does not contain NOTE's with --log-error-verbosity=2 during initialization\n"; } # -------- # TEST 2.4 # -------- $file= $ENV{'LOG_FILE7'} or die("log file7 not set"); $result=1; $verbosity_adjust_message_logged= 0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; if ($line =~ /\[Note\]/) { $result=0; } if ($line =~ /\[Warning\].*'log_error_verbosity': unsigned value 7 adjusted to 3/) { $verbosity_adjust_message_logged= 1; } } close(FILE); if($result) { print "[ FAIL ] Error log does not include NOTE's with --log-error-verbosity=7 (adjusted to 3) during initialization.\n"; } else { if ($verbosity_adjust_message_logged) { print "[ PASS ] Error log contains NOTE's with --log-error-verbosity=7 (adjusted to 3) during initialization.\n"; } else { print "[ FAIL ] Error log does not contain a warning that log_error_verbosity is adjusted to 3 from 7\n"; } } # -------- # TEST 3.1 # -------- $file= $ENV{'LOG_FILE8'} or die("log file8 not set"); $result=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; if ($line =~ /\[Note\] \[[^]]*\] \[[^]]*\] Access denied for user \'unknown_user\'/) { $result=1; } } close(FILE); if($result) { print "[ PASS ] Error log contains a NOTE with compiled-in message 'Access denied' when lc_messages_dir does not contain error messages\n"; } else { print "[ FAIL ] Error log does not contain a NOTE with compiled-in message 'Access denied' when lc_messages_dir does not contain error messages\n"; } # -------- # TEST 4.3 # -------- my $file= $ENV{'LOG_FILE11j'}; open(FILE,"$file") or die("Unable to open $file $!\n"); my @log_lines=; close(FILE); # Test for validity of the json docs in error log my $string = "[\n".join("", @log_lines)."\n]"; $string =~ s/\}\n\{/\},\n\{/g ; my $parsed_json; my $success=1; $parsed_json = decode_json $string; unless ( $parsed_json ) { print "[ FAIL ] Error while parsing the error log as a json document:\n$@\n"; $success=0; } if($success) { print "[ PASS ] Error log successfully parsed as a json document\n"; for my $item( @$parsed_json ){ if ( $item->{'msg'} =~ /Access denied for user \'unknown_user\'/) { print "[ PASS ] Expected entry found in the json error log: " . $item->{'msg'} . "\n"; } # WL#11875 FR1: ("loaded logging components used for buffered logging") # WL#11875 FR2: ("all key/value pairs saved in early, buffered logging") if ( $item->{'err_symbol'} =~ /ER_STARTING_AS/ && exists($item->{'buffered'})) { print "[ PASS ] Expected entry found in the json error log: " . $item->{'err_symbol'} . "\n"; } } } # -------- # TEST 5.1 # -------- my $file= $ENV{'LOG_FILE13'} or die("log file13 not set"); my $result=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; if ($line =~ /\[Note\] \[[^]]*\] \[[^]]*\] Access denied for user \'unknown_user\'/) { $result= $result + 1; } } close(FILE); if ($result == 3) { print "[ PASS ] Error log messages throttled at three for 'Access denied' messages\n"; } else { if ($result > 3) { print "[ FAIL ] Error log has $result 'Access denied' messages despite being throttled at 3\n"; } else { print "[ FAIL ] Error log does not contain expected number of 'Access denied' messages\n"; } } # -------- # TEST 7.1 # -------- my $file= $ENV{'LOG_FILE16'} or die("log file16 not set"); my $result=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; if ($line =~ /\[Note\] \[[^]]*\] \[[^]]*\] Access denied for user \'unknown_user_filtered\'/) { $result= 1; print "[ FAIL ] Offender: $line\n"; } } close(FILE); if ($result == 1) { print "[ FAIL ] Error log has $result 'Access denied' message(s) despite of them being in the supression list\n"; } else { print "[ PASS ] 'Access denied' messages filtered as per suppression list\n"; } my $result=0; open(FILE, "$file") or die("Unable to open $file: $!"); while () { my $line = $_; if ($line =~ /\[Note\] \[[^]]*\] \[[^]]*\] Access denied for user \'unknown_user_unfiltered\'/) { $result= 1; } } close(FILE); if ($result == 1) { print "[ PASS ] 'Access denied' messages not filtered, as per suppression list.\n"; } else { print "[ FAIL ] 'Access denied' messages filtered despite of them not being in the supression list!\n"; } EOF # Cleanup --remove_file $LOG_FILE1 --remove_file $LOG_FILE2 --remove_file $LOG_FILE3 --remove_file $LOG_FILE4 --remove_file $LOG_FILE6 --remove_file $LOG_FILE5 --remove_file $LOG_FILE7 --remove_file $LOG_FILE8 --remove_file $LOG_FILE8B --remove_file $LOG_FILE9 --remove_file $LOG_FILE10 --remove_file $LOG_FILE11 --remove_file $LOG_FILE11j --remove_file $LOG_FILE12 --remove_file $LOG_FILE13 --remove_file $LOG_FILE14 --remove_file $LOG_FILE15 --remove_file $LOG_FILE16 --remove_file $LOG_FILE17 --remove_file $LOG_FILE18 --remove_file $LOG_FILE19 --remove_file $LOG_FILE19j # Restart server after this test since it enables binary # logging and may affect further tests --source include/force_restart.inc