|
@@ -79,7 +79,8 @@ groups() ->
|
|
|
SingleOnlyTests = [
|
|
SingleOnlyTests = [
|
|
|
t_broken_bpapi_vsn,
|
|
t_broken_bpapi_vsn,
|
|
|
t_old_bpapi_vsn,
|
|
t_old_bpapi_vsn,
|
|
|
- t_bridges_probe
|
|
|
|
|
|
|
+ t_bridges_probe,
|
|
|
|
|
+ t_auto_restart_interval
|
|
|
],
|
|
],
|
|
|
ClusterLaterJoinOnlyTCs = [t_cluster_later_join_metrics],
|
|
ClusterLaterJoinOnlyTCs = [t_cluster_later_join_metrics],
|
|
|
[
|
|
[
|
|
@@ -550,6 +551,89 @@ t_http_crud_apis(Config) ->
|
|
|
|
|
|
|
|
{ok, 204, <<>>} = request(delete, uri(["bridges", BridgeID]), Config).
|
|
{ok, 204, <<>>} = request(delete, uri(["bridges", BridgeID]), Config).
|
|
|
|
|
|
|
|
|
|
+t_auto_restart_interval(Config) ->
|
|
|
|
|
+ Port = ?config(port, Config),
|
|
|
|
|
+ %% assert we there's no bridges at first
|
|
|
|
|
+ {ok, 200, []} = request_json(get, uri(["bridges"]), Config),
|
|
|
|
|
+
|
|
|
|
|
+ meck:new(emqx_resource, [passthrough]),
|
|
|
|
|
+ meck:expect(emqx_resource, call_start, fun(_, _, _) -> {error, fake_error} end),
|
|
|
|
|
+
|
|
|
|
|
+ %% then we add a webhook bridge, using POST
|
|
|
|
|
+ %% POST /bridges/ will create a bridge
|
|
|
|
|
+ URL1 = ?URL(Port, "path1"),
|
|
|
|
|
+ Name = ?BRIDGE_NAME,
|
|
|
|
|
+ BridgeID = emqx_bridge_resource:bridge_id(?BRIDGE_TYPE_HTTP, Name),
|
|
|
|
|
+ BridgeParams = ?HTTP_BRIDGE(URL1, Name)#{
|
|
|
|
|
+ <<"resource_opts">> => #{<<"auto_restart_interval">> => "1s"}
|
|
|
|
|
+ },
|
|
|
|
|
+ ?check_trace(
|
|
|
|
|
+ begin
|
|
|
|
|
+ ?assertMatch(
|
|
|
|
|
+ {ok, 201, #{
|
|
|
|
|
+ <<"type">> := ?BRIDGE_TYPE_HTTP,
|
|
|
|
|
+ <<"name">> := Name,
|
|
|
|
|
+ <<"enable">> := true,
|
|
|
|
|
+ <<"status">> := _,
|
|
|
|
|
+ <<"node_status">> := [_ | _],
|
|
|
|
|
+ <<"url">> := URL1
|
|
|
|
|
+ }},
|
|
|
|
|
+ request_json(
|
|
|
|
|
+ post,
|
|
|
|
|
+ uri(["bridges"]),
|
|
|
|
|
+ BridgeParams,
|
|
|
|
|
+ Config
|
|
|
|
|
+ )
|
|
|
|
|
+ ),
|
|
|
|
|
+ ?block_until(#{?snk_kind := resource_disconnected_enter}),
|
|
|
|
|
+ ?block_until(#{?snk_kind := resource_auto_reconnect}, 1500)
|
|
|
|
|
+ end,
|
|
|
|
|
+ fun(Trace0) ->
|
|
|
|
|
+ Trace = ?of_kind(resource_auto_reconnect, Trace0),
|
|
|
|
|
+ ?assertMatch([#{}], Trace),
|
|
|
|
|
+ ok
|
|
|
|
|
+ end
|
|
|
|
|
+ ),
|
|
|
|
|
+ %% delete the bridge
|
|
|
|
|
+ {ok, 204, <<>>} = request(delete, uri(["bridges", BridgeID]), Config),
|
|
|
|
|
+ {ok, 200, []} = request_json(get, uri(["bridges"]), Config),
|
|
|
|
|
+
|
|
|
|
|
+ %% auto_retry_interval=infinity
|
|
|
|
|
+ BridgeParams1 = BridgeParams#{
|
|
|
|
|
+ <<"resource_opts">> => #{<<"auto_restart_interval">> => "infinity"}
|
|
|
|
|
+ },
|
|
|
|
|
+ ?check_trace(
|
|
|
|
|
+ begin
|
|
|
|
|
+ ?assertMatch(
|
|
|
|
|
+ {ok, 201, #{
|
|
|
|
|
+ <<"type">> := ?BRIDGE_TYPE_HTTP,
|
|
|
|
|
+ <<"name">> := Name,
|
|
|
|
|
+ <<"enable">> := true,
|
|
|
|
|
+ <<"status">> := _,
|
|
|
|
|
+ <<"node_status">> := [_ | _],
|
|
|
|
|
+ <<"url">> := URL1
|
|
|
|
|
+ }},
|
|
|
|
|
+ request_json(
|
|
|
|
|
+ post,
|
|
|
|
|
+ uri(["bridges"]),
|
|
|
|
|
+ BridgeParams1,
|
|
|
|
|
+ Config
|
|
|
|
|
+ )
|
|
|
|
|
+ ),
|
|
|
|
|
+ ?block_until(#{?snk_kind := resource_disconnected_enter}),
|
|
|
|
|
+ ?block_until(#{?snk_kind := resource_auto_reconnect}, 1500)
|
|
|
|
|
+ end,
|
|
|
|
|
+ fun(Trace0) ->
|
|
|
|
|
+ Trace = ?of_kind(resource_auto_reconnect, Trace0),
|
|
|
|
|
+ ?assertMatch([], Trace),
|
|
|
|
|
+ ok
|
|
|
|
|
+ end
|
|
|
|
|
+ ),
|
|
|
|
|
+ %% delete the bridge
|
|
|
|
|
+ {ok, 204, <<>>} = request(delete, uri(["bridges", BridgeID]), Config),
|
|
|
|
|
+ {ok, 200, []} = request_json(get, uri(["bridges"]), Config),
|
|
|
|
|
+ meck:unload(emqx_resource).
|
|
|
|
|
+
|
|
|
t_http_bridges_local_topic(Config) ->
|
|
t_http_bridges_local_topic(Config) ->
|
|
|
Port = ?config(port, Config),
|
|
Port = ?config(port, Config),
|
|
|
%% assert we there's no bridges at first
|
|
%% assert we there's no bridges at first
|