Skip to content

Commit d8a2956

Browse files
author
Paweł Andruszkiewicz
committed
BUG#37154456 Write compatibility issues and applied fixes to the log file
The compatibility issues found when running a dump with the `ocimds` option set to true are already printed to the Shell log, with this change all issues detected by the upgrade checker are also written there. Change-Id: I50b3f1f9449d48b30c52fed1446e99a0980ad050
1 parent 7e57c81 commit d8a2956

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

modules/util/upgrade_check_formatter.cc

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,40 @@ class Text_upgrade_checker_output : public Upgrade_check_output_formatter {
8484
if (results.empty()) {
8585
print_paragraph("No issues found");
8686
} else if (check.get_description() != nullptr) {
87+
log(check.get_level(), check.get_description());
8788
print_paragraph(check.get_description());
8889
print_doc_links(check.get_doc_link());
8990
m_console->println();
9091
} else {
9192
issue_formater = format_upgrade_issue;
9293
}
9394

94-
for (const auto &issue : results) print_paragraph(issue_formater(issue));
95+
for (const auto &issue : results) {
96+
const auto msg = issue_formater(issue);
97+
log(issue.level, msg.c_str());
98+
print_paragraph(msg);
99+
}
95100
}
96101

97102
void check_error(const Upgrade_check &check, const char *description,
98103
bool runtime_error = true) override {
99104
print_title(check.get_title());
100105
m_console->print(" ");
101-
if (runtime_error) m_console->print_diag("Check failed: ");
106+
107+
if (runtime_error) {
108+
static constexpr auto k_check_failed = "Check failed: ";
109+
log(Upgrade_issue::Level::ERROR, k_check_failed);
110+
m_console->print_diag(k_check_failed);
111+
}
112+
113+
log(Upgrade_issue::Level::ERROR, description);
102114
m_console->println(description);
103115
print_doc_links(check.get_doc_link());
104116
}
105117

106118
void manual_check(const Upgrade_check &check) override {
107119
print_title(check.get_title());
120+
log(check.get_level(), check.get_description());
108121
print_paragraph(check.get_description());
109122
print_doc_links(check.get_doc_link());
110123
}
@@ -148,6 +161,22 @@ class Text_upgrade_checker_output : public Upgrade_check_output_formatter {
148161
}
149162
}
150163

164+
void log(Upgrade_issue::Level level, const char *msg) {
165+
switch (level) {
166+
case Upgrade_issue::Level::ERROR:
167+
log_error("%s", msg);
168+
break;
169+
170+
case Upgrade_issue::Level::WARNING:
171+
log_warning("%s", msg);
172+
break;
173+
174+
case Upgrade_issue::Level::NOTICE:
175+
log_info("%s", msg);
176+
break;
177+
}
178+
}
179+
151180
int m_check_count = 0;
152181
std::shared_ptr<IConsole> m_console;
153182
};

unittest/scripts/auto/py_shell/scripts/util_dump_instance_norecord.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,8 @@ def EXPECT_INCLUDE_EXCLUDE(options, included, excluded, expected_exception = Non
16131613
excluded_tables.append("`{0}`.`{1}`".format(test_schema, table))
16141614

16151615
recreate_verification_schema()
1616+
WIPE_SHELL_LOG()
1617+
16161618
EXPECT_FAIL("Error: Shell Error (52004)", "While 'Validating MySQL HeatWave Service compatibility': Compatibility issues were found", test_output_relative, { "ocimds": True, "excludeSchemas": excluded_schemas, "excludeTables": excluded_tables })
16171619

16181620
# BUG#35663805 print a note to always use the lastest shell
@@ -1624,6 +1626,12 @@ def EXPECT_INCLUDE_EXCLUDE(options, included, excluded, expected_exception = Non
16241626
EXPECT_STDOUT_CONTAINS("NOTE: MySQL Server 5.7 detected, please consider upgrading to 8.0 first.")
16251627
EXPECT_STDOUT_CONTAINS("Checking for potential upgrade issues.")
16261628

1629+
# BUG#37154456 write compatibility issues and applied fixes to the log file
1630+
EXPECT_SHELL_LOG_CONTAINS(strip_restricted_grants(test_user_account, test_privileges).error_no_prefix())
1631+
EXPECT_SHELL_LOG_CONTAINS(comment_data_index_directory(incompatible_schema, incompatible_table_data_directory).fixed_no_prefix())
1632+
if __version_num < 80000:
1633+
EXPECT_SHELL_LOG_CONTAINS("Warning: The new default authentication plugin 'caching_sha2_password' offers more secure password hashing than previously used 'mysql_native_password' (and consequent improved client connection authentication). However, it also has compatibility implications that may affect existing MySQL installations. If your MySQL installation must serve pre-8.0 clients, you may encounter compatibility issues after upgrading unless newly created accounts are created to use 'mysql_native_password'.")
1634+
16271635
EXPECT_STDOUT_CONTAINS(strip_restricted_grants(test_user_account, test_privileges).error())
16281636

16291637
EXPECT_STDOUT_CONTAINS(comment_data_index_directory(incompatible_schema, incompatible_table_data_directory).fixed())

unittest/scripts/setup_py/dump_utils.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,22 @@ class Compatibility_issue:
251251
return self.__error_msg
252252
else:
253253
raise Exception("No error message")
254+
def error_no_prefix(self):
255+
return self.error()[7:]
254256
def warning(self):
255257
if self.__warning_msg:
256258
return self.__warning_msg
257259
else:
258260
raise Exception("No warning message")
261+
def warning_no_prefix(self):
262+
return self.warning()[9:]
259263
def fixed(self):
260264
if self.__fixed_msg:
261265
return self.__fixed_msg
262266
else:
263267
raise Exception("No fixed message")
268+
def fixed_no_prefix(self):
269+
return self.fixed()[6:]
264270

265271
def strip_restricted_grants(user, privileges):
266272
all_privileges = ", ".join(sorted(privileges))

0 commit comments

Comments
 (0)