Skip to content

Commit 993b2a2

Browse files
committed
- add LOG(FATAL) and the test for it
- modified variable names Signed-off-by: dancingactor <s990346@gmail.com>
1 parent 4385f94 commit 993b2a2

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

src/ray/rpc/rpc_chaos.cc

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,34 @@ class RpcFailureManager {
8181
return;
8282
}
8383

84-
for (auto &[key, value] : json.items()) {
84+
for (auto &[method, config] : json.items()) {
85+
for (const auto &[config_key, _] : config.items()) {
86+
if (config_key != "num_failures" && config_key != "req_failure_prob" &&
87+
config_key != "req_failure_prob" && config_key != "resp_failure_prob" &&
88+
config_key != "in_flight_failure_prob" &&
89+
config_key != "num_lower_bound_req_failures" &&
90+
config_key != "num_lower_bound_resp_failures" &&
91+
config_key != "num_lower_bound_in_flight_failures") {
92+
RAY_LOG(FATAL) << "Unknown key specified in testing_rpc_failure config: "
93+
<< config_key;
94+
}
95+
}
8596
auto [iter, _] = failable_methods_.emplace(
86-
key,
97+
method,
8798
Failable{
88-
value.value("num_failures", 0L),
89-
value.value("req_failure_prob", 0UL),
90-
value.value("resp_failure_prob", 0UL),
91-
value.value("in_flight_failure_prob", 0UL),
92-
value.value("num_lower_bound_req_failures", 0UL),
93-
value.value("num_lower_bound_resp_failures", 0UL),
94-
value.value("num_lower_bound_in_flight_failures", 0UL),
99+
config.value("num_failures", 0L),
100+
config.value("req_failure_prob", 0UL),
101+
config.value("resp_failure_prob", 0UL),
102+
config.value("in_flight_failure_prob", 0UL),
103+
config.value("num_lower_bound_req_failures", 0UL),
104+
config.value("num_lower_bound_resp_failures", 0UL),
105+
config.value("num_lower_bound_in_flight_failures", 0UL),
95106
});
96107
const auto &failable = iter->second;
97108
RAY_CHECK_LE(failable.req_failure_prob + failable.resp_failure_prob +
98109
failable.in_flight_failure_prob,
99110
100UL);
100-
if (key == "*") {
111+
if (method == "*") {
101112
wildcard_set_ = true;
102113
// The wildcard overrides all other method configurations.
103114
break;

src/ray/rpc/tests/rpc_chaos_test.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,11 @@ TEST(RpcChaosTest, LowerBoundWithWildcard) {
126126
}
127127
}
128128

129+
TEST(RpcChaosTest, TestInvalidJson) {
130+
RayConfig::instance().testing_rpc_failure() =
131+
R"({"*":{"num_failures":-1,"invalid_key":1}})";
132+
ASSERT_DEATH(Init(),
133+
"Unknown key specified in testing_rpc_failure config: invalid_key");
134+
}
135+
129136
} // namespace ray::rpc::testing

0 commit comments

Comments
 (0)