chore: don't disable rule that references non-existent bridge
After feedback from QA, we decided to rollback enforcing the rule to be disabled.
This commit is contained in:
parent
5881e34d4e
commit
f17b762596
|
@ -732,7 +732,7 @@ t_scenario_2(Config) ->
|
||||||
%% ===================================================================================
|
%% ===================================================================================
|
||||||
%% Try to create a rule referencing a non-existent bridge. It succeeds, but it's
|
%% Try to create a rule referencing a non-existent bridge. It succeeds, but it's
|
||||||
%% implicitly disabled. Trying to update it later without creating the bridge should
|
%% implicitly disabled. Trying to update it later without creating the bridge should
|
||||||
%% keep it disabled.
|
%% allow it to be enabled.
|
||||||
%% ===================================================================================
|
%% ===================================================================================
|
||||||
BridgeName = <<"scenario2">>,
|
BridgeName = <<"scenario2">>,
|
||||||
RuleTopic = <<"t/scenario2">>,
|
RuleTopic = <<"t/scenario2">>,
|
||||||
|
@ -746,9 +746,9 @@ t_scenario_2(Config) ->
|
||||||
],
|
],
|
||||||
#{overrides => #{enable => true}}
|
#{overrides => #{enable => true}}
|
||||||
),
|
),
|
||||||
?assertNot(is_rule_enabled(RuleId0)),
|
?assert(is_rule_enabled(RuleId0)),
|
||||||
?assertMatch({ok, {{_, 200, _}, _, _}}, enable_rule_http(RuleId0)),
|
?assertMatch({ok, {{_, 200, _}, _, _}}, enable_rule_http(RuleId0)),
|
||||||
?assertNot(is_rule_enabled(RuleId0)),
|
?assert(is_rule_enabled(RuleId0)),
|
||||||
|
|
||||||
%% ===================================================================================
|
%% ===================================================================================
|
||||||
%% Now we create the bridge, and attempt to create a new enabled rule. It should
|
%% Now we create the bridge, and attempt to create a new enabled rule. It should
|
||||||
|
@ -768,13 +768,13 @@ t_scenario_2(Config) ->
|
||||||
],
|
],
|
||||||
#{overrides => #{enable => true}}
|
#{overrides => #{enable => true}}
|
||||||
),
|
),
|
||||||
?assertNot(is_rule_enabled(RuleId0)),
|
?assert(is_rule_enabled(RuleId0)),
|
||||||
?assert(is_rule_enabled(RuleId1)),
|
?assert(is_rule_enabled(RuleId1)),
|
||||||
?assertMatch({ok, {{_, 200, _}, _, _}}, enable_rule_http(RuleId0)),
|
?assertMatch({ok, {{_, 200, _}, _, _}}, enable_rule_http(RuleId0)),
|
||||||
?assert(is_rule_enabled(RuleId0)),
|
?assert(is_rule_enabled(RuleId0)),
|
||||||
|
|
||||||
%% ===================================================================================
|
%% ===================================================================================
|
||||||
%% Creating a rule with mixed existent/non-existent bridges should deny enabling it.
|
%% Creating a rule with mixed existent/non-existent bridges should allow enabling it.
|
||||||
%% ===================================================================================
|
%% ===================================================================================
|
||||||
NonExistentBridgeName = <<"scenario2_not_created">>,
|
NonExistentBridgeName = <<"scenario2_not_created">>,
|
||||||
{ok, #{<<"id">> := RuleId2}} =
|
{ok, #{<<"id">> := RuleId2}} =
|
||||||
|
@ -801,8 +801,8 @@ t_scenario_2(Config) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
?assertNot(is_rule_enabled(RuleId2)),
|
?assert(is_rule_enabled(RuleId2)),
|
||||||
?assertMatch({ok, {{_, 200, _}, _, _}}, enable_rule_http(RuleId2)),
|
?assertMatch({ok, {{_, 200, _}, _, _}}, enable_rule_http(RuleId2)),
|
||||||
?assertNot(is_rule_enabled(RuleId2)),
|
?assert(is_rule_enabled(RuleId2)),
|
||||||
|
|
||||||
ok.
|
ok.
|
||||||
|
|
|
@ -478,20 +478,18 @@ with_parsed_rule(Params = #{id := RuleId, sql := Sql, actions := Actions}, Creat
|
||||||
%% -- calculated fields end
|
%% -- calculated fields end
|
||||||
},
|
},
|
||||||
InputEnable = maps:get(enable, Params, true),
|
InputEnable = maps:get(enable, Params, true),
|
||||||
Enable =
|
|
||||||
case validate_bridge_existence_in_actions(Rule0) of
|
case validate_bridge_existence_in_actions(Rule0) of
|
||||||
ok ->
|
ok ->
|
||||||
InputEnable;
|
ok;
|
||||||
{error, NonExistentBridgeIDs} ->
|
{error, NonExistentBridgeIDs} ->
|
||||||
?SLOG(error, #{
|
?SLOG(error, #{
|
||||||
msg => "action_references_nonexistent_bridges",
|
msg => "action_references_nonexistent_bridges",
|
||||||
rule_id => RuleId,
|
rule_id => RuleId,
|
||||||
nonexistent_bridge_ids => NonExistentBridgeIDs,
|
nonexistent_bridge_ids => NonExistentBridgeIDs,
|
||||||
hint => "this rule will be disabled"
|
hint => "this rule will be disabled"
|
||||||
}),
|
})
|
||||||
false
|
|
||||||
end,
|
end,
|
||||||
Rule = Rule0#{enable => Enable},
|
Rule = Rule0#{enable => InputEnable},
|
||||||
ok = Fun(Rule),
|
ok = Fun(Rule),
|
||||||
{ok, Rule};
|
{ok, Rule};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
|
|
Loading…
Reference in New Issue