fix(native): Fix copy-paste bug in veloxQueryConfigOperation log message and add tests#27236
Conversation
Reviewer's GuideFixes the veloxQueryConfig setProperty response message to correctly reference "velox query config" instead of "system property" and adds focused tests for the veloxQueryConfig operation endpoint, including URL parsing, success paths, and error handling. Sequence diagram for veloxQueryConfig setProperty operation responsesequenceDiagram
actor Admin
participant HttpServer
participant PrestoServerOperations
participant SystemConfig
Admin->>HttpServer: HTTP POST /v1/cluster/veloxQueryConfig/setProperty?name=n&value=v
HttpServer->>PrestoServerOperations: veloxQueryConfigOperation(op)
PrestoServerOperations->>SystemConfig: instance()
SystemConfig-->>PrestoServerOperations: SystemConfig
PrestoServerOperations->>SystemConfig: setProperty(name, value)
SystemConfig-->>PrestoServerOperations: oldValue
PrestoServerOperations-->>HttpServer: "Have set velox query config property '{}' to '{}'. Old value was '{}'." (formatted)
HttpServer-->>Admin: HTTP 200 with updated message
Class diagram for veloxQueryConfig operation handlingclassDiagram
class PrestoServerOperations {
+veloxQueryConfigOperation(op: ServerOperation) string
}
class ServerOperation {
+target: string
+action: string
+params: map
+targetString(target: int) string
+actionString(action: int) string
}
class SystemConfig {
-instance_: SystemConfig
+instance() SystemConfig
+setProperty(name: string, value: string) string
+getProperty(name: string, defaultValue: string) string
}
PrestoServerOperations --> ServerOperation : uses
PrestoServerOperations --> SystemConfig : updates config
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="presto-native-execution/presto_cpp/main/tests/ServerOperationTest.cpp" line_range="279-286" />
<code_context>
+ &httpMessage);
+ EXPECT_EQ(std::stoi(getPropertyResponse), folly::hardware_concurrency());
+
+ // Setting a registered property returns a message with "velox query config"
+ // wording (verifying the copy-paste bug fix from systemConfigOperation).
+ httpMessage.setQueryParam("name", "shutdown-onset-sec");
+ httpMessage.setQueryParam("value", "42");
+ auto setPropertyResponse = serverOperation.veloxQueryConfigOperation(
+ {.target = ServerOperation::Target::kVeloxQueryConfig,
+ .action = ServerOperation::Action::kSetProperty},
+ &httpMessage);
+ EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos);
+ EXPECT_NE(
+ setPropertyResponse.find("shutdown-onset-sec"), std::string::npos);
+ EXPECT_NE(setPropertyResponse.find("42"), std::string::npos);
+
+ // Verify the property was set by reading it back.
</code_context>
<issue_to_address>
**suggestion (testing):** Also assert that the response no longer contains the old "system property" wording
To better protect against regressions of the original copy‑paste bug, add a negative assertion that the `setProperty` response does not contain "system property", e.g.:
```cpp
EXPECT_EQ(
setPropertyResponse.find("system property"),
std::string::npos);
```
This complements the positive check for "velox query config" and guards against reintroducing the old wording.
```suggestion
auto setPropertyResponse = serverOperation.veloxQueryConfigOperation(
{.target = ServerOperation::Target::kVeloxQueryConfig,
.action = ServerOperation::Action::kSetProperty},
&httpMessage);
EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos);
EXPECT_NE(
setPropertyResponse.find("shutdown-onset-sec"), std::string::npos);
EXPECT_NE(setPropertyResponse.find("42"), std::string::npos);
EXPECT_EQ(
setPropertyResponse.find("system property"), std::string::npos);
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| auto setPropertyResponse = serverOperation.veloxQueryConfigOperation( | ||
| {.target = ServerOperation::Target::kVeloxQueryConfig, | ||
| .action = ServerOperation::Action::kSetProperty}, | ||
| &httpMessage); | ||
| EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos); | ||
| EXPECT_NE( | ||
| setPropertyResponse.find("shutdown-onset-sec"), std::string::npos); | ||
| EXPECT_NE(setPropertyResponse.find("42"), std::string::npos); |
There was a problem hiding this comment.
suggestion (testing): Also assert that the response no longer contains the old "system property" wording
To better protect against regressions of the original copy‑paste bug, add a negative assertion that the setProperty response does not contain "system property", e.g.:
EXPECT_EQ(
setPropertyResponse.find("system property"),
std::string::npos);This complements the positive check for "velox query config" and guards against reintroducing the old wording.
| auto setPropertyResponse = serverOperation.veloxQueryConfigOperation( | |
| {.target = ServerOperation::Target::kVeloxQueryConfig, | |
| .action = ServerOperation::Action::kSetProperty}, | |
| &httpMessage); | |
| EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos); | |
| EXPECT_NE( | |
| setPropertyResponse.find("shutdown-onset-sec"), std::string::npos); | |
| EXPECT_NE(setPropertyResponse.find("42"), std::string::npos); | |
| auto setPropertyResponse = serverOperation.veloxQueryConfigOperation( | |
| {.target = ServerOperation::Target::kVeloxQueryConfig, | |
| .action = ServerOperation::Action::kSetProperty}, | |
| &httpMessage); | |
| EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos); | |
| EXPECT_NE( | |
| setPropertyResponse.find("shutdown-onset-sec"), std::string::npos); | |
| EXPECT_NE(setPropertyResponse.find("42"), std::string::npos); | |
| EXPECT_EQ( | |
| setPropertyResponse.find("system property"), std::string::npos); |
…age and add tests (prestodb#27236) Summary: Fix a copy-paste bug in `PrestoServerOperations::veloxQueryConfigOperation()` where the `kSetProperty` handler's response message incorrectly said "system property" instead of "velox query config property". This was caused by the function being copied from `systemConfigOperation()` without updating the log message. Add comprehensive tests for the `veloxQueryConfig` operation endpoint: - URL path parsing for veloxQueryConfig/setProperty and veloxQueryConfig/getProperty - Getting an unknown property returns "<default>" (unlike systemConfig which throws) - Getting a known registered property returns its value - Setting a property returns a message with correct "velox query config" wording - Round-trip set + get verification - Error cases: missing 'name' and missing 'value' parameters Differential Revision: D94800584
c91d4e0 to
3e3b393
Compare
Summary:
Fix a copy-paste bug in
PrestoServerOperations::veloxQueryConfigOperation()where thekSetPropertyhandler's response message incorrectly said "system property" instead of "velox query config property". This was caused by the function being copied fromsystemConfigOperation()without updating the log message.Add comprehensive tests for the
veloxQueryConfigoperation endpoint:Summary by Sourcery
Fix the velox query config server operation messaging and extend coverage of its HTTP endpoint behavior.
Bug Fixes:
Tests: