-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(search): Fix integration test failures #5991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dranikpg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we need anything except ACL fixes just for the sake of being there
src/server/search/search_family.cc
Outdated
| if (parser.Check("CONTROLLED_VARIABLE")) { | ||
| if (parser.Check("SET")) { | ||
| // Consume variable name and value | ||
| if (parser.HasNext()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these optional? if not please change the code to be more strict.
@BorysTheDev can you help with the advice on how to improve parsing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked Valkey search code.
if (keyword == "SHOW_INFO") {
return vmsdk::info_field::ShowInfo(ctx, itr, options);
} else if (keyword == "PAUSEPOINT") {
return PausePointControlCmd(ctx, itr);
} else if (keyword == "CONTROLLED_VARIABLE") {
return ControlledCmd(ctx, itr);
} else if (keyword == "HELP") {
return HelpCmd(ctx, itr);
} else {
return absl::InvalidArgumentError(absl::StrCat(
"Unknown subcommand: ", *itr.GetStringView(), " try HELP subcommand"));
}
absl::Status ControlledCmd(ValkeyModuleCtx *ctx, vmsdk::ArgsIterator &itr) {
std::string keyword;
VMSDK_RETURN_IF_ERROR(vmsdk::ParseParamValue(itr, keyword));
keyword = absl::AsciiStrToUpper(keyword);
if (keyword == "LIST") {
VMSDK_RETURN_IF_ERROR(CheckEndOfArgs(itr));
auto results = vmsdk::debug::ControlledGetValues();
ValkeyModule_ReplyWithArray(ctx, 2 * results.size());
for (auto &r : results) {
ValkeyModule_ReplyWithCString(ctx, r.first.data());
ValkeyModule_ReplyWithCString(ctx, r.second.data());
}
return absl::OkStatus();
}
std::string test_control_name;
std::string value;
VMSDK_RETURN_IF_ERROR(vmsdk::ParseParamValue(itr, test_control_name));
if (keyword == "GET") {
VMSDK_ASSIGN_OR_RETURN(value,
vmsdk::debug::ControlledGet(test_control_name));
VMSDK_RETURN_IF_ERROR(CheckEndOfArgs(itr));
ValkeyModule_ReplyWithCString(ctx, value.data());
} else if (keyword == "SET") {
VMSDK_RETURN_IF_ERROR(vmsdk::ParseParamValue(itr, value));
VMSDK_RETURN_IF_ERROR(CheckEndOfArgs(itr));
VMSDK_RETURN_IF_ERROR(
vmsdk::debug::ControlledSet(test_control_name, value));
ValkeyModule_ReplyWithSimpleString(ctx, "OK");
} else {
ValkeyModule_ReplyWithError(
ctx, absl::StrCat("Unknown keyword", keyword).data());
}
return absl::OkStatus();
}
So I think we can do the next:
auto cmd = parser.MapNext("HELP", &HelpCmd, "CONTROLLED_VARIABLE", &ControlledCmd,...);
if (parser.TakeError()) {
rb.sendError()
}
return cmd(...);
}
void ControlledCmd(...) {
auto action = parser.MapNext("SET", SET, "GET", GET ...)
switch (action) {
case SET:
parser.Next();
break:
case GET:
....
}
if (parser.TakeError()) {
rb.sendError()
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, this approach adds more bolerplate. I suggest leave the current approach, I guess we will update this command soon fixing failed tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok please add error checking
romange
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
we are not implementing the command, so not need for this boilerplate. I think checking parser for errors is important, also just consume the tokens that must be present. |
Added more strict check. |
Fixes 4 failing integration tests.
What was broken:
@searchACL categoryFT._DEBUGcommand not implementedResults:
Before: 48 failed / 22 passed
After: 44 failed / 26 passed (+4 tests fixed)