File: error_logging_verbosity.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (223 lines) | stat: -rw-r--r-- 6,339 bytes parent folder | download
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
--echo #
--echo # WL#6661: Error logging: Allow control of verbosity
--echo #

# Unfortunately while the order of the requirements was sensible for
# human consumption, it's relatively impractical to test in that order. :(

CALL mtr.add_suppression("option 'log_error_verbosity'");
CALL mtr.add_suppression("--verbose is for use with");

SET @old_log_error_verbosity= @@global.log_error_verbosity;
SET @old_log_timestamps     = @@global.log_timestamps;


--echo
--echo # Spec 1: Nomenclature, no test


--echo
--echo # The following four can be verified using mysqld--help-[not]win.test:
--echo #
--echo # Spec 2a: "--help works"
--echo # Spec 2b: "default verbosity for --help is 1, errors only"
--echo #
--echo # Spec 3a: "--help --verbose works"
--echo # Spec 3b: "default verbosity for --help --verbose is 1, errors only"


--echo
--echo # Spec 4a "new sys-var log_error_verbosity"
--echo # Spec 4d "--log_error_verbosity settable on command-line"
--echo # Spec B  "later options replace earlier ones."
# (pick something low in .opt so we won't have to deal with start-up spam.)
SELECT @@global.log_error_verbosity;

--echo
--echo # Spec 4b "default"
# defaults to highest verbosity
SET GLOBAL log_error_verbosity=DEFAULT;
SELECT @@global.log_error_verbosity;

--echo
--echo # Spec 4c "range"
# turning off even errors is forbidden for now.
SET GLOBAL log_error_verbosity=0;
SELECT @@global.log_error_verbosity;

--echo
--echo # Spec 4c "range"
# there is nothing beyond Notes, so there is no level higher than 3.
SET GLOBAL log_error_verbosity=4;
SELECT @@global.log_error_verbosity;

--echo
--echo # Spec 4d -- see above at 4a, and below in error log

--echo
--echo # Spec 4e "global only"
# It's a global. There is no thread-specific log_error_verbosity.
--error ER_GLOBAL_VARIABLE
SET SESSION log_error_verbosity=DEFAULT;

--echo
--echo # Spec 4e "SUPER required for log_error_verbosity"
--echo # Spec Ed "SUPER required for log_timestamps"
# It's not settable by just anyone.

CREATE USER mysqltest_1;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
connect(user1,localhost,mysqltest_1,,*NO-ONE*);
connection user1;
--echo # as unprivileged user:
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
SET GLOBAL log_error_verbosity=1;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
SET GLOBAL log_timestamps=SYSTEM;
disconnect user1;
--source include/wait_until_disconnected.inc

connection default;
--echo # as root:
DROP USER mysqltest_1;


--echo
--echo # Spec 5 "--verbose without --help throws an error" -- see below in error log


--echo
--echo # Spec 6 "example for things previously governed by log_warnings"
--echo # see error log below for results

SET GLOBAL  init_connect='wombat;';

CREATE USER mysqltest_yeslog;
CREATE USER mysqltest_nolog;

--echo # Spec 6a "log_error_warnings=2+ includes warnings"

SET GLOBAL  log_error_verbosity=2;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
connect(user2,localhost,mysqltest_yeslog,,*NO-ONE*);
connection default;

--echo # Spec 6c "warnings now gagged by log_error_verbosity=1"
SET GLOBAL  log_error_verbosity=1;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
connect(user3,localhost,mysqltest_nolog,,*NO-ONE*);

connection user2;
disconnect user2;
--source include/wait_until_disconnected.inc
connection user3;
disconnect user3;
--source include/wait_until_disconnected.inc

connection default;
DROP USER mysqltest_yeslog;
DROP USER mysqltest_nolog;

SET GLOBAL  init_connect='';


--echo # Spec 6b "log_error_warnings=3  includes notes"
SET GLOBAL  log_error_verbosity=2;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR
connect(user1,localhost,mysqltest_2_nolog,,*NO-ONE*);

SET GLOBAL  log_error_verbosity=3;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR
connect(user1,localhost,mysqltest_3_yeslog,,*NO-ONE*);

SET GLOBAL  log_error_verbosity=DEFAULT;



--echo
--echo # Spec 7 "--log_warning throws deprecation warning" -- now removed


--echo
--echo # Spec 8/Spec 8a "log_warnings sets log_error_verbosity" -- now removed

--echo
--echo # Spec 9 -- no test; limits part shown in Spec 4c/Spec 8


--echo
--echo # Spec A -- see Spec 4c "range" and Spec 8


--echo
--echo # Spec B -- see above at 4a, and below in error log


--echo
--echo # Spec C  "bootstrap" -- no test


--echo
--echo # Spec D  "timestamp format" -- results in log below = regex was matched


--echo
--echo # Spec Ea  "log_timestamps"
# SYSTEM here rather than default; set from command-line.
SELECT      @@global.log_timestamps;
--echo # Spec Eb  "log_timestamps -- values UTC|SYSTEM"
SET GLOBAL  log_timestamps=UTC;
SELECT      @@global.log_timestamps;
SET GLOBAL  log_timestamps=SYSTEM;
SELECT      @@global.log_timestamps;
--echo # Spec Ec  "log_timestamps -- default UTC"
SET GLOBAL  log_timestamps=DEFAULT;
SELECT      @@global.log_timestamps;
--echo # Spec Ed  "SUPER required" -- see 4e
--echo # Spec Ee  "SYSTEM = old behavior" -- no test

--echo
--echo # Spec 4d "--log_error_verbosity settable on command-line"
--echo # Spec 5  "--verbose without --help throws an error"
--echo # Spec 7  "--log_warning throws deprecation warning" -- now removed
--echo # Spec D  "ISO 8601 / RFC 3339 compliant timestamps"
--echo #
--echo # error log:

let GREP_FILE=$MYSQLTEST_VARDIR/tmp/wl6661_log.err;
let GREP_PATTERN=Access denied;

# be very specific with the regex, we've got a format to prove:
--replace_regex /[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][-+Z][0-9:]* *[0-9]* *\[/DATE_TIME [/
--perl
  use strict;
  my $file= $ENV{'GREP_FILE'} or die("grep file not set");
  my $pattern= $ENV{'GREP_PATTERN'} or die("pattern is not set");
  open(FILE, "$file") or die("Unable to open $file: $!");
  while (<FILE>) {
    my $line = $_;
    if ($line =~ /$pattern/) {
      print "$line\n";
    }
  }
  close(FILE);

  rename $file, "$file~";

  open(FILE, ">", "$file") or die("Unable to open file: $!");
  close(FILE);
EOF

--echo
--echo # cleanup
SET GLOBAL log_error_verbosity = @old_log_error_verbosity;
SET GLOBAL log_timestamps      = @old_log_timestamps;
--remove_file $MYSQLTEST_VARDIR/tmp/wl6661_log.err~

FLUSH LOGS;

--echo
--echo #
--echo # end WL#6661