Skip to content

Commit 0622602

Browse files
committed
BUG#28900085 - MYSQLXTEST - 'RECVERROR' COMMAND IGNORES IO ERROS
Description =========== The receive-error command ('recverror'), causes that mysqlxtest expects X Protocol error message. All other messages should cause an mysqlxtest-script-error, IO error must cause mysqlxtest-script-fatal error. The command ignores all IO errors, continuing normal execution of the script. Fix === Terminates script execution on IO error. RB: 20898 Reviewed-by: Tomasz Stepniak <[email protected]> Reviewed-by: Grzegorz Szwarc <[email protected]>
1 parent 9d7fc0d commit 0622602

File tree

1 file changed

+28
-23
lines changed
  • plugin/x/tests/driver/processor/commands

1 file changed

+28
-23
lines changed

plugin/x/tests/driver/processor/commands/command.cc

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -451,39 +451,44 @@ Command::Result Command::cmd_recverror(std::istream &input,
451451
const std::string &args) {
452452
xcl::XProtocol::Server_message_type_id msgid;
453453
xcl::XError xerror;
454-
Message_ptr msg(
455-
context->session()->get_protocol().recv_single_message(&msgid, &xerror));
456454

457455
if (args.empty()) {
458456
context->print_error(
459457
"'recverror' command, requires an integer argument.\n");
460458
return Result::Stop_with_failure;
461459
}
462460

463-
if (msg.get()) {
464-
bool failed = false;
465-
try {
466-
const int expected_error_code = mysqlxtest::get_error_code_by_text(args);
467-
if (msg->GetDescriptor()->full_name() != "Mysqlx.Error" ||
468-
expected_error_code !=
469-
static_cast<int>(
470-
static_cast<Mysqlx::Error *>(msg.get())->code())) {
471-
context->print_error(context->m_script_stack, "Was expecting Error ",
472-
args, ", but got:\n");
473-
failed = true;
474-
} else {
475-
context->print("Got expected error:\n");
476-
}
461+
Message_ptr msg(
462+
context->session()->get_protocol().recv_single_message(&msgid, &xerror));
463+
464+
if (nullptr == msg.get()) {
465+
context->print_error(context->m_script_stack, "Was expecting Error ", args,
466+
", but got I/O error:", xerror.error(),
467+
", message:", xerror.what(), "\n");
468+
return Result::Stop_with_failure;
469+
}
477470

478-
context->print(*msg, "\n");
471+
bool failed = false;
472+
try {
473+
const int expected_error_code = mysqlxtest::get_error_code_by_text(args);
474+
if (msg->GetDescriptor()->full_name() != "Mysqlx.Error" ||
475+
expected_error_code !=
476+
static_cast<int>(static_cast<Mysqlx::Error *>(msg.get())->code())) {
477+
context->print_error(context->m_script_stack, "Was expecting Error ",
478+
args, ", but got:\n");
479+
failed = true;
480+
} else {
481+
context->print("Got expected error:\n");
482+
}
479483

480-
if (failed && context->m_options.m_fatal_errors) {
481-
return Result::Stop_with_success;
482-
}
483-
} catch (std::exception &e) {
484-
context->print_error_red(context->m_script_stack, e, '\n');
485-
if (context->m_options.m_fatal_errors) return Result::Stop_with_success;
484+
context->print(*msg, "\n");
485+
486+
if (failed && context->m_options.m_fatal_errors) {
487+
return Result::Stop_with_success;
486488
}
489+
} catch (std::exception &e) {
490+
context->print_error_red(context->m_script_stack, e, '\n');
491+
if (context->m_options.m_fatal_errors) return Result::Stop_with_success;
487492
}
488493

489494
return Result::Continue;

0 commit comments

Comments
 (0)