Merge branch '2.3' into 2.4

This commit is contained in:
Markus Mäkelä 2020-07-09 13:54:31 +03:00
commit 0bd41c0f02
No known key found for this signature in database
GPG Key ID: 5CE746D557ACC499
4 changed files with 125 additions and 8 deletions

View File

@ -10,8 +10,7 @@ int main(int argc, char* argv[])
test.repl->connect();
execute_query(test.repl->nodes[0], "CREATE USER 'old'@'%%' IDENTIFIED BY 'old';");
execute_query(test.repl->nodes[0],
"UPDATE mysql.user SET password = OLD_PASSWORD('old') WHERE user = 'old';");
execute_query(test.repl->nodes[0], "SET PASSWORD FOR 'old'@'%%' = OLD_PASSWORD('old')");
execute_query(test.repl->nodes[0], "FLUSH PRIVILEGES");
test.repl->sync_slaves();
@ -27,7 +26,6 @@ int main(int argc, char* argv[])
mysql_close(conn);
execute_query(test.repl->nodes[0], "DROP USER 'old'@'%%'");
test.log_includes(0, "MaxScale does not support these old passwords");
return test.global_result;
}

View File

@ -1,5 +1,6 @@
[maxscale]
threads=4
log_info=1
[server1]
type=server

View File

@ -144,13 +144,13 @@ int main(int argc, char* argv[])
if (Test->verbose)
{
Test->tprintf("DELETE quries without WHERE clause will be blocked during the 15 seconds");
Test->tprintf("DELETE quries without WHERE clause will be blocked during the 30 seconds");
Test->tprintf("Put time to rules.txt: %s", str);
}
Test->maxscales->ssh_node_f(0,
false,
"start_time=`date +%%T`;"
"stop_time=` date --date \"now +15 secs\" +%%T`;"
"stop_time=` date --date \"now +30 secs\" +%%T`;"
"%s sed -i \"s/###time###/$start_time-$stop_time/\" %s/rules/rules.txt",
Test->maxscales->access_sudo[0],
Test->maxscales->access_homedir[0]);
@ -158,20 +158,22 @@ int main(int argc, char* argv[])
Test->maxscales->restart_maxscale(0);
Test->maxscales->connect_rwsplit(0);
sleep(10);
Test->tprintf("Trying 'DELETE FROM t1' and expecting FAILURE");
execute_query_silent(Test->maxscales->conn_rwsplit[0], "DELETE FROM t1");
if (mysql_errno(Test->maxscales->conn_rwsplit[0]) != 1141)
{
Test->add_result(1,
"Query succeded, but fail expected, errono is %d",
"Query succeded, but fail expected, error is %d",
mysql_errno(Test->maxscales->conn_rwsplit[0]));
}
Test->tprintf("Waiting 16 seconds and trying 'DELETE FROM t1', expecting OK");
Test->tprintf("Waiting 30 seconds and trying 'DELETE FROM t1', expecting OK");
Test->stop_timeout();
sleep(16);
sleep(30);
Test->set_timeout(180);
Test->try_query(Test->maxscales->conn_rwsplit[0], "DELETE FROM t1");

116
script/set-change-date Executable file
View File

@ -0,0 +1,116 @@
#!/usr/bin/env python3
#
# Copyright (c) 2018 MariaDB Corporation Ab
#
# Use of this software is governed by the Business Source License included
# in the LICENSE.TXT file and at www.mariadb.com/bsl11.
#
# Change Date: 2024-06-02
#
# On the date above, in accordance with the Business Source License, use
# of this software will be governed by version 2 or later of the General
# Public License.
#
import getopt
import os
import re
import shutil
import sys
import tempfile
# A string literal would be a match and cause an unintended modification.
pattern=" " + "Change Date:" + " .*"
# The Change Date should be in the blurb at the beginning. We will not
# do modifications after this threshold.
line_threshold=20
recd=re.compile(pattern)
def print_usage_and_exit(name, code):
print("usage: " + name + " -c change-date [path]+")
print()
print("If path is a directory, the change date will recursively be set in all ")
print("files in that directory hierarchy.")
sys.exit(code)
def update_change_date_in_file(changedate, filename):
print(filename)
tmp=tempfile.mkstemp()
fout=os.fdopen(tmp[0], "w")
with open(filename) as fin:
modified=False
try:
line=fin.readline()
line_number=1
while line:
match=recd.search(line)
if match:
if line_number <= line_threshold:
# 14 is the length of the pattern up until ".*", that is, we pick of the line
# up until the current change date.
line=line[0:match.span()[0] + 14] + changedate + "\n"
modified=True
else:
print("WARNING: Ignoring 'Change Date' encountered on line " + str(line_number) + ".")
fout.write(line)
line = fin.readline()
line_number=line_number + 1
except UnicodeDecodeError:
print("WARNING: Could not decode file, ignoring.")
modified=False
except:
print("WARNING: Could not read file, ignoring.")
modified=False
fin.close()
fout.close()
if modified:
shutil.copyfile(tmp[1], filename)
os.remove(tmp[1])
def update_change_date_in_dir(changedate, dir):
for file in os.listdir(dir):
path=dir + "/" + file
update_change_date_in_path(changedate, path)
def update_change_date_in_path(changedate, path):
if not os.path.exists(path):
print("WARNING: " + path + " does not exist.")
elif os.path.isdir(path):
update_change_date_in_dir(changedate, path)
elif os.path.isfile(path):
update_change_date_in_file(changedate, path)
else:
print("WARNING: '" + path + "' is not a regular file or directory, ignoring.")
def update_change_date_in_paths(changedate, paths):
for path in paths:
update_change_date_in_path(changedate, path)
def main(argv):
name=argv[0]
try:
opts, args = getopt.getopt(argv[1:], "hc:")
except getopt.GetoptError:
print_usage_and_exit(name, 1)
changedate=''
for opt, arg in opts:
if opt == '-h':
print_usage_and_exit(name, 0)
elif opt == '-c':
changedate = arg
if changedate == '':
print_usage_and_exit(name, 1)
update_change_date_in_paths(changedate, args)
if __name__ == "__main__":
main(sys.argv)